Spaces:
Sleeping
Sleeping
Create app.py
Browse files1234567891011121314151617181920212223242526272829303132333435import gradio as grfrom gtts import gTTSimport osimport time
def read_hindi_text(text): if not text.strip(): return "❌ Please enter some text!"
# Generate TTS tts = gTTS(text=text, lang='hi', slow=False) filename = "hindi_output.mp3" tts.save(filename)
# Play audio try: os.system("start " + filename) # Windows # os.system("afplay " + filename) # Mac # os.system("xdg-open " + filename) # Linux output_message = f"✅ Hindi Text saved as '{filename}' and playing now!" except Exception as e: output_message = f"⚠️ Error playing the file: {str(e)}" return output_message
# Gradio interfaceiface = gr.Interface( fn=read_hindi_text, inputs=gr.Textbox(lines=4, placeholder="यहाँ हिंदी टेक्स्ट लिखें..."), outputs="text", title="Hindi Text-to-Speech", description="हिंदी टेक्स्ट डालें और 'Read' बटन दबाएँ। टेक्स्ट को आवाज़ में बदला जाएगा।")
iface.launch()app.pyAdded+35