File size: 999 Bytes
48c2af7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
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()