Spaces:
No application file
No application file
File size: 643 Bytes
b396e94 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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}") |