Fix Tamil translation: remove corrupted entries, add conversational idioms and Unicode-aware spoken Tamil grammar
2cb8002 Download test.py from ranaspark/voice: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/spaces/ranaspark/voice/resolve/main/test.py
- Command line
-
hf download hf://spaces/ranaspark/voice/test.py
-
curl -L -o test.py https://huggingface.co/spaces/ranaspark/voice/resolve/main/test.py
1.69 kB
| from pipeline.translation import translate_to_tamil | |
| from pipeline.tts import generate_tamil_speech | |
| from app import save_audio_to_mp3 | |
| import os | |
| import sys | |
| import time | |
| import gc | |
| if sys.stdout and hasattr(sys.stdout, "reconfigure"): | |
| sys.stdout.reconfigure(encoding='utf-8') | |
| 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: {tamil_text}") | |
| print("Waiting for memory to clear...") | |
| gc.collect() | |
| time.sleep(2) | |
| print("Testing TTS (Edge-TTS fallback)...") | |
| style = "Young Female (Maya - Expressive 👧)" | |
| sample_rate, audio_data = generate_tamil_speech(tamil_text, style, mode="Cloud APIs (Fast & Lightweight ⚡)") | |
| if sample_rate and audio_data is not None: | |
| output_file = save_audio_to_mp3(sample_rate, audio_data) | |
| if os.path.exists(output_file): | |
| print(f"Success! Cloud audio saved to MP3: {output_file}") | |
| else: | |
| print("Failed to generate 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 👧)" | |
| ) | |
| if sample_rate_mms and audio_data_mms is not None: | |
| output_file_mms = save_audio_to_mp3(sample_rate_mms, audio_data_mms) | |
| if os.path.exists(output_file_mms): | |
| print(f"Success! Premium young female audio saved to MP3: {output_file_mms}") | |
| else: | |
| print("Failed to generate premium audio.") | |
| if __name__ == "__main__": | |
| run_test() | |