File size: 981 Bytes
e87f3ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
from pipeline.translation import translate_to_tamil
from pipeline.tts import generate_tamil_speech
import soundfile as sf
import os
import time
import gc

def run_test():
    print("Testing translation...")
    english_text = "Hello, how are you? I am very happy to meet you."
    tamil_text = translate_to_tamil(english_text)
    print(f"English: {english_text}")
    print(f"Tamil (encoded): {tamil_text.encode('utf-8')}")
    
    print("Waiting for memory to clear...")
    gc.collect()
    time.sleep(5)
    
    print("Testing TTS...")
    style = "Maya's voice is that of a young, cheerful Tamil girl speaking excitedly."
    sample_rate, audio_data = generate_tamil_speech(tamil_text, style)
    
    output_file = "test_output.wav"
    sf.write(output_file, audio_data, sample_rate)
    
    if os.path.exists(output_file):
        print(f"Success! Audio saved to {output_file}")
    else:
        print("Failed to save audio.")

if __name__ == "__main__":
    run_test()