voice / test.py
rahulrana0001's picture
Initial commit: Multilingual Tamil TTS with Comic Reader Mode
e87f3ac
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()