Add Gunicorn support for production in Vosk service and update requirements
This commit is contained in:
80
vosk/test_files/test_service.py
Normal file
80
vosk/test_files/test_service.py
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify Vosk service is working properly.
|
||||
"""
|
||||
|
||||
import requests
|
||||
import time
|
||||
import json
|
||||
|
||||
def test_service_health():
|
||||
"""Test if the service is responding"""
|
||||
try:
|
||||
response = requests.get("http://localhost:5000/", timeout=5)
|
||||
if response.status_code == 200:
|
||||
print("✅ Service is healthy!")
|
||||
print(f"Response: {response.json()}")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Service returned status {response.status_code}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"❌ Service not responding: {e}")
|
||||
return False
|
||||
|
||||
def test_batch_processing():
|
||||
"""Test batch processing functionality"""
|
||||
try:
|
||||
# Create a simple test batch
|
||||
test_data = {
|
||||
'references': json.dumps(['test sentence 1', 'test sentence 2'])
|
||||
}
|
||||
|
||||
# Create dummy audio files (you'll need real audio files for actual testing)
|
||||
files = {
|
||||
'audio0': ('test1.wav', b'dummy_audio_data', 'audio/wav'),
|
||||
'audio1': ('test2.wav', b'dummy_audio_data', 'audio/wav')
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
"http://localhost:5000/batch_confirm",
|
||||
data=test_data,
|
||||
files=files,
|
||||
timeout=30
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
print("✅ Batch processing endpoint is working!")
|
||||
print(f"Response: {response.json()}")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Batch processing failed: {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Batch processing error: {e}")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Main test function"""
|
||||
print("🔍 Testing Vosk service...")
|
||||
|
||||
# Wait for service to be ready
|
||||
print("⏳ Waiting for service to be ready...")
|
||||
for i in range(30):
|
||||
if test_service_health():
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
print("❌ Service did not become ready within 30 seconds")
|
||||
return
|
||||
|
||||
# Test batch processing
|
||||
print("\n🧪 Testing batch processing...")
|
||||
test_batch_processing()
|
||||
|
||||
print("\n✅ Service testing complete!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user