wedyanessam commited on
Commit
cac46bd
·
verified ·
1 Parent(s): 0b1265a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -1,16 +1,21 @@
1
  import gradio as gr
2
- from TTS.tts import text_to_speech
3
 
4
- def tts_interface(text):
5
- audio, sr = text_to_speech(text)
6
- return (sr, audio)
 
 
7
 
8
- demo = gr.Interface(
9
- fn=tts_interface,
10
- inputs=gr.Textbox(label="اكتب النص العربي هنا"),
11
- outputs=gr.Audio(label="الصوت الناتج"),
12
- title="تحويل النص إلى صوت بالعربية (MMS TTS)"
13
- )
14
-
15
- if __name__ == "__main__":
16
- demo.launch()
 
 
 
 
1
  import gradio as gr
2
+ from TTS.tts import generate_voice
3
 
4
+ def inference(text, speaker_wav):
5
+ if speaker_wav is None:
6
+ return "يرجى رفع ملف صوت لشخص تريد تقليد صوته", None
7
+ output_path = generate_voice(text, speaker_wav.name, language="ar")
8
+ return "تم التحويل بنجاح", output_path
9
 
10
+ gr.Interface(
11
+ fn=inference,
12
+ inputs=[
13
+ gr.Textbox(label="النص العربي"),
14
+ gr.Audio(source="upload", type="file", label="ملف صوت للشخص (WAV)")
15
+ ],
16
+ outputs=[
17
+ gr.Textbox(label="النتيجة"),
18
+ gr.Audio(label="الصوت الناتج")
19
+ ],
20
+ title="🔊 تحويل نص إلى صوت باستخدام XTTS v2"
21
+ ).launch()