Spaces:
Sleeping
Testing the TTS API
How to Run Tests
1. Start the API server
python api.py
The API will start on http://localhost:7860
2. In another terminal, run the test suite
python test_api.py
What the Tests Check
The test suite validates:
- Health Check - Verifies the API is running and returns model information
- Speakers Endpoint - Confirms available speakers are listed
- Input Validation - Tests error handling for:
- Empty text
- Invalid speakers
- Audio Generation - Tests TTS generation with:
- Different speakers (Divya, Rani, Generic Female, etc.)
- Urdu text input
- Audio quality validation (format, duration, size)
- Audio Output - Saves generated audio files to
test_outputs/for manual inspection
Test Output
Each test run generates:
- Console output with test results
- WAV audio files in
test_outputs/directory for listening/verification
Example output: ```
TTS API Test Suite
Testing health check... ✓ Health check passed Available speakers: ['Divya', 'Rani', 'Rohit', 'Aman', 'Generic Female', 'Generic Male'] Sample rate: 24000 Hz
Testing speakers endpoint... ✓ Speakers endpoint passed Speakers: ['Divya', 'Rani', 'Rohit', 'Aman', 'Generic Female', 'Generic Male']
Testing input validation... ✓ Empty text validation passed ✓ Invalid speaker validation passed
Testing TTS generation with different speakers... ✓ TTS generation successful Text: سلام دنیا Speaker: Divya Audio shape: (123456,) Sample rate: 24000 Hz Duration: 5.14 seconds Audio size: 246.91 KB Saved to: test_outputs/test_Divya_12_chars.wav
## Testing with CUDA
If you want to verify CUDA is being used:
1. Check the API startup logs - it should show:
Using device: cuda GPU: NVIDIA GeForce RTX 4090 (or your GPU name)
2. Monitor GPU usage while tests run:
```bash
nvidia-smi
Manual Testing
You can also test manually with curl:
curl -X POST "http://localhost:7860/tts" \
-H "Content-Type: application/json" \
-d '{
"text": "سلام دنیا",
"speaker": "Divya",
"pitch": "Moderate",
"rate": "Moderate"
}' \
--output test_audio.wav
Then play the audio file to verify quality.