#!/usr/bin/env python3 """ Manual download script for Gigaspeech model Use this if the automatic download fails """ import os import urllib.request import tarfile def download_gigaspeech_manual(): """Manually download and extract Gigaspeech model""" url = "https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-gigaspeech-2023-12-12.tar.bz2" model_dir = "models/sherpa-onnx-zipformer-gigaspeech-2023-12-12" print("šŸ”½ Manual Gigaspeech Model Download") print("=" * 50) # Check if already exists expected_files = [ "encoder-epoch-30-avg-9.onnx", "decoder-epoch-30-avg-9.onnx", "joiner-epoch-30-avg-9.onnx", "tokens.txt" ] if all(os.path.exists(os.path.join(model_dir, f)) for f in expected_files): print("āœ… Model already exists!") return True try: # Create models directory os.makedirs("models", exist_ok=True) # Download file tar_filename = "models/gigaspeech_temp.tar.bz2" print(f"šŸ“„ Downloading from: {url}") print("ā³ This may take a few minutes (~120MB)...") def progress_hook(block_num, block_size, total_size): if total_size > 0: percent = min(100, (block_num * block_size * 100) // total_size) print(f"\ršŸ“Š Progress: {percent}%", end="", flush=True) urllib.request.urlretrieve(url, tar_filename, progress_hook) print("\nāœ… Download completed!") # Extract print("šŸ“‚ Extracting files...") with tarfile.open(tar_filename, 'r:bz2') as tar: tar.extractall("models") # Clean up os.remove(tar_filename) # Verify if all(os.path.exists(os.path.join(model_dir, f)) for f in expected_files): print("āœ… Extraction successful!") print("\nšŸ“ Model files:") for f in expected_files: file_path = os.path.join(model_dir, f) size = os.path.getsize(file_path) / (1024*1024) # MB print(f" āœ“ {f}: {size:.1f} MB") print(f"\nšŸŽ‰ Gigaspeech model ready!") print(f"šŸ“ Location: {os.path.abspath(model_dir)}") print("\nšŸš€ You can now start your server with:") print(" python app.py") return True else: print("āŒ Some files are missing after extraction") return False except Exception as e: print(f"āŒ Download failed: {e}") return False if __name__ == "__main__": print("Manual Gigaspeech Model Downloader") print("Use this if automatic download fails") print() success = download_gigaspeech_manual() if success: print("\nšŸŽÆ SUCCESS! Your English-only ASR model is ready!") print("āœ… 100% English-only") print("āœ… Large vocabulary (GigaSpeech)") print("āœ… Perfect for multiple kids") print("āœ… Fast Zipformer architecture") else: print("\nāš ļø Manual download failed.") print("You can try:") print("1. Check your internet connection") print("2. Run the script again") print("3. Use a different ASR model (SherpaWhisperTinyEN)")