| 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 (Edge-TTS fallback)...") |
| style = "Lustful & Passionate (Maya)" |
| sample_rate, audio_data = generate_tamil_speech(tamil_text, style, mode="Cloud APIs (Fast & Lightweight ⚡)") |
| |
| output_file = "test_output.wav" |
| sf.write(output_file, audio_data, sample_rate) |
| |
| if os.path.exists(output_file): |
| print(f"Success! Cloud/fallback audio saved to {output_file}") |
| else: |
| print("Failed to save cloud audio.") |
|
|
| print("\nTesting TTS (Premium Young Female)...") |
| sample_rate_mms, audio_data_mms = generate_tamil_speech( |
| tamil_text, |
| style, |
| mode="Premium Young Female (Maya 👧)" |
| ) |
| |
| output_file_mms = "test_output_premium.wav" |
| sf.write(output_file_mms, audio_data_mms, sample_rate_mms) |
| |
| if os.path.exists(output_file_mms): |
| print(f"Success! Premium young female audio saved to {output_file_mms}") |
| else: |
| print("Failed to save premium audio.") |
|
|
| if __name__ == "__main__": |
| run_test() |
|
|