ASG Models commited on
Commit
d6d1977
·
verified ·
1 Parent(s): 421118f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -13
app.py CHANGED
@@ -185,24 +185,35 @@ from gradio_multimodalchatbot import MultimodalChatbot
185
  from gradio.data_classes import FileData
186
  import tempfile
187
  import soundfile as sf
 
188
  def add_message(history, message):
189
 
190
  if message["text"] is not None:
191
- sr,response_audio = genrate_speech(message["text"],'asg2024/vits-ar-sa-huba')
192
- with tempfile.TemporaryFile() as temp_file:
193
- filename='temp'+str(temp_file.name)+'.wav'
194
- sf.write(filename,response_audio, sr,format='WAV')
195
- user_msg1 = {"text": message["text"],
196
- "files": [{"file":FileData(path=filename)}]}
197
 
198
 
199
- txt_ai=get_answer_ai(message["text"] )
200
- sr,response_audio = genrate_speech(txt_ai,'asg2024/vits-ar-sa-huba')
201
- with tempfile.TemporaryFile() as temp_file:
202
- filename='temp'+str(temp_file.name)+'.wav'
203
- sf.write(filename,response_audio, sr,format='WAV')
204
- bot_msg1 = {"text": txt_ai,
205
- "files": [{"file":FileData(path=filename)}]}
 
 
 
 
 
 
 
 
 
 
206
  history.append([user_msg1, bot_msg1])
207
 
208
  # history.append((gr.Audio(response_audio,scale=1,streaming=True),None))
 
185
  from gradio.data_classes import FileData
186
  import tempfile
187
  import soundfile as sf
188
+ from gradio_client import Client
189
  def add_message(history, message):
190
 
191
  if message["text"] is not None:
192
+ # sr,response_audio = genrate_speech(message["text"],'asg2024/vits-ar-sa-huba')
193
+ # with tempfile.TemporaryFile() as temp_file:
194
+ # filename='temp'+str(temp_file.name)+'.wav'
195
+ # sf.write(filename,response_audio, sr,format='WAV')
196
+ # user_msg1 = {"text": message["text"],
197
+ # "files": [{"file":FileData(path=filename)}]}
198
 
199
 
200
+ # txt_ai=get_answer_ai(message["text"] )
201
+ # sr,response_audio = genrate_speech(txt_ai,'asg2024/vits-ar-sa-huba')
202
+ # with tempfile.TemporaryFile() as temp_file:
203
+ # filename='temp'+str(temp_file.name)+'.wav'
204
+ # sf.write(filename,response_audio, sr,format='WAV')
205
+ # bot_msg1 = {"text": txt_ai,
206
+ # "files": [{"file":FileData(path=filename)}]}
207
+ client = Client("asg2024/wasm-speeker-sa")
208
+ result = client.predict(
209
+ text="سلام عليكم",
210
+ model_choice="asg2024/vits-ar-sa-huba",
211
+ api_name="/process_audio"
212
+ )
213
+ user_msg1 = {"text": message["text"],
214
+ "files": [{"file":FileData(path=result[0])}]}
215
+ bot_msg1 = {"text": result[2],
216
+ "files": [{"file":FileData(path=result[1])}]}
217
  history.append([user_msg1, bot_msg1])
218
 
219
  # history.append((gr.Audio(response_audio,scale=1,streaming=True),None))