Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from TTS.api import TTS | |
| import os | |
| # ✅ Correct model name format for local loading | |
| MODEL_NAME = "tts_models/ur/mai/mai_400k" | |
| # ✅ Load TTS model | |
| tts = TTS(MODEL_NAME) | |
| # ✅ Text-to-Speech function | |
| def tts_fn(text): | |
| output_path = "output.wav" | |
| tts.tts_to_file(text=text, file_path=output_path) | |
| return output_path | |
| # ✅ Gradio interface | |
| iface = gr.Interface( | |
| fn=tts_fn, | |
| inputs=gr.Textbox(label="اردو متن درج کریں", lines=3, placeholder="مثلاً: میرا نام نجم علی ہے"), | |
| outputs=gr.Audio(type="filepath", label="آواز"), | |
| title="اردو TTS ایپ (Coqui)", | |
| description="یہ ایپ کوکی کا اردو TTS ماڈل استعمال کرتی ہے۔" | |
| ) | |
| iface.launch() | |