Parler_TTS_API / TEST_INSTRUCTIONS.md
aspirant312's picture
Add comprehensive test suite for TTS API audio validation
b483241
|
Raw
History Blame Contribute Delete
2.41 kB
# Testing the TTS API
## How to Run Tests
### 1. Start the API server
```bash
python api.py
```
The API will start on `http://localhost:7860`
### 2. In another terminal, run the test suite
```bash
python test_api.py
```
## What the Tests Check
The test suite validates:
1. **Health Check** - Verifies the API is running and returns model information
2. **Speakers Endpoint** - Confirms available speakers are listed
3. **Input Validation** - Tests error handling for:
- Empty text
- Invalid speakers
4. **Audio Generation** - Tests TTS generation with:
- Different speakers (Divya, Rani, Generic Female, etc.)
- Urdu text input
- Audio quality validation (format, duration, size)
5. **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
============================================================
1. Testing health check...
✓ Health check passed
Available speakers: ['Divya', 'Rani', 'Rohit', 'Aman', 'Generic Female', 'Generic Male']
Sample rate: 24000 Hz
2. Testing speakers endpoint...
✓ Speakers endpoint passed
Speakers: ['Divya', 'Rani', 'Rohit', 'Aman', 'Generic Female', 'Generic Male']
3. Testing input validation...
✓ Empty text validation passed
✓ Invalid speaker validation passed
4. 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:
```bash
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.