| """ | |
| Test script for TTS provider initialization and generate_tts behavior. | |
| Run with USE_TTS_STUB=1 to exercise the local stub, or without to test client-init error path. | |
| """ | |
| import os | |
| import sys | |
| # Ensure project root is on sys.path so imports from repository root work | |
| ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
| if ROOT not in sys.path: | |
| sys.path.insert(0, ROOT) | |
| from tts_provider import generate_tts | |
| def main(): | |
| print('ENV: USE_TTS_STUB =', os.environ.get('USE_TTS_STUB')) | |
| svc = [ | |
| {'speaker': 'A', 'voice_config': {'prebuilt_voice_config': {'voice_name': 'Kore'}}}, | |
| {'speaker': 'B', 'voice_config': {'prebuilt_voice_config': {'voice_name': 'Puck'}}} | |
| ] | |
| audio, err, provider = generate_tts('Hello world from test_tts_client', speaker_voice_configs=svc) | |
| print('\nResult:') | |
| print(' audio_bytes_present =', bool(audio)) | |
| print(' error =', repr(err)) | |
| print(' provider =', provider) | |
| if __name__ == '__main__': | |
| main() | |