wedyanessam commited on
Commit
568d66f
·
verified ·
1 Parent(s): 1f3027b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -1,24 +1,27 @@
1
  import gradio as gr
 
2
  from LLM.llm import generate_reply
3
  from TTS_X.tts import generate_voice
4
 
5
- def chat_and_tts(user_input):
6
- reply = generate_reply(user_input)
7
- audio = generate_voice(reply)
8
- return reply, audio
 
 
 
9
 
10
- # واجهة Gradio
11
  with gr.Blocks() as demo:
12
- gr.Markdown("## 🤖💬 Chat & TTS Assistant using OpenAI (GPT + Nova Voice)")
13
 
14
- with gr.Row():
15
- txt = gr.Textbox(label="📝 اكتب سؤالك أو طلبك")
16
- btn = gr.Button("أرسل")
 
17
 
18
- with gr.Row():
19
- reply_output = gr.Textbox(label="🧠 الرد النصي")
20
- audio_output = gr.Audio(label="🔊 الصوت الناتج")
21
 
22
- btn.click(fn=chat_and_tts, inputs=txt, outputs=[reply_output, audio_output])
23
 
24
  demo.launch()
 
 
1
  import gradio as gr
2
+ from SST.sst import speech_to_text
3
  from LLM.llm import generate_reply
4
  from TTS_X.tts import generate_voice
5
 
6
+ def process(audio):
7
+
8
+ user_text = speech_to_text(audio)
9
+ reply = generate_reply(user_text)
10
+ reply_audio = generate_voice(reply)
11
+
12
+ return user_text, reply, reply_audio
13
 
 
14
  with gr.Blocks() as demo:
15
+ gr.Markdown("## 🗣️➡️💬➡️🔊 من صوتك إلى رد منطوق!")
16
 
17
+ audio_input = gr.Audio(label="🎤 ارفع صوتك", type="filepath")
18
+ user_text = gr.Textbox(label="📜 النص المسموع")
19
+ reply_text = gr.Textbox(label="🤖 رد المساعد")
20
+ reply_audio = gr.Audio(label="🔊 الرد بالصوت")
21
 
22
+ btn = gr.Button("ابدأ")
 
 
23
 
24
+ btn.click(process, inputs=audio_input, outputs=[user_text, reply_text, reply_audio])
25
 
26
  demo.launch()
27
+