mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
79 lines
No EOL
2.7 KiB
Python
79 lines
No EOL
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify Gigaspeech model download from GitHub
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import urllib.request
|
|
import tarfile
|
|
|
|
def test_gigaspeech_download():
|
|
"""Test downloading Gigaspeech model from GitHub"""
|
|
|
|
model_dir = "models/sherpa-onnx-zipformer-gigaspeech-2023-12-12"
|
|
url = "https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-gigaspeech-2023-12-12.tar.bz2"
|
|
|
|
print("🔍 Testing Gigaspeech model download from GitHub...")
|
|
print(f"URL: {url}")
|
|
print(f"Target directory: {model_dir}")
|
|
|
|
# Check if model already exists
|
|
expected_files = [
|
|
"encoder-epoch-30-avg-9.onnx",
|
|
"decoder-epoch-30-avg-9.onnx",
|
|
"joiner-epoch-30-avg-9.onnx",
|
|
"tokens.txt"
|
|
]
|
|
|
|
all_exist = all(os.path.exists(os.path.join(model_dir, f)) for f in expected_files)
|
|
|
|
if all_exist:
|
|
print("✅ All model files already exist!")
|
|
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")
|
|
return True
|
|
|
|
print("📥 Model files not found, testing download...")
|
|
|
|
try:
|
|
# Create directory
|
|
os.makedirs(model_dir, exist_ok=True)
|
|
|
|
# Test URL accessibility
|
|
print("🌐 Testing URL accessibility...")
|
|
response = urllib.request.urlopen(url)
|
|
content_length = response.headers.get('Content-Length')
|
|
if content_length:
|
|
size_mb = int(content_length) / (1024*1024)
|
|
print(f"✅ URL accessible, file size: {size_mb:.1f} MB")
|
|
else:
|
|
print("✅ URL accessible")
|
|
response.close()
|
|
|
|
print("✅ GitHub download test successful!")
|
|
print("\n🎉 The Gigaspeech model can be downloaded from GitHub!")
|
|
print("Your server should be able to download it automatically.")
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"❌ Download test failed: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
print("Testing Gigaspeech model availability...")
|
|
success = test_gigaspeech_download()
|
|
|
|
if success:
|
|
print("\n🎯 CONFIRMED: Gigaspeech model is available!")
|
|
print("✅ English-only model")
|
|
print("✅ Large vocabulary (GigaSpeech dataset)")
|
|
print("✅ Perfect for multiple kids")
|
|
print("✅ GitHub download working")
|
|
print("\nYour server should start successfully now!")
|
|
else:
|
|
print("\n⚠️ There might be a network issue.")
|
|
print("Try running your server - it will attempt the download.") |