Spaces:
No application file
No application file
from gtts import gTTS | |
from deep_translator import GoogleTranslator | |
def text_to_speech(text): | |
""" Converts text into both English and Hindi speech using gTTS (Cloud-based TTS). """ | |
# β Translate English to Hindi | |
translated_text = GoogleTranslator(source="en", target="hi").translate(text) | |
# β Hindi Voice (Using gTTS) | |
hindi_tts = gTTS(text=translated_text, lang="hi") | |
hindi_file = "output_hindi.mp3" | |
hindi_tts.save(hindi_file) | |
return hindi_file | |
# if __name__ == "__main__": | |
# text = input("Enter text: ") | |
# hindi_file = text_to_speech(text) | |
# print(f"Hindi audio saved to: {hindi_file}") |