Spaces:
Runtime error
Runtime error
ASG Models
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -196,22 +196,28 @@ def add_message(history, message):
|
|
| 196 |
"files": [{"file":FileData(path=filename)}]}
|
| 197 |
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
# history.append((gr.Audio(response_audio,scale=1,streaming=True),None))
|
| 203 |
return history
|
| 204 |
|
| 205 |
def bot(history,message):
|
| 206 |
-
if message["text"] is not None:
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
|
| 216 |
|
| 217 |
|
|
|
|
| 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.NamedTemporaryFile(delete=True) as temp_file:
|
| 202 |
+
filename=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))
|
| 209 |
return history
|
| 210 |
|
| 211 |
def bot(history,message):
|
| 212 |
+
# if message["text"] is not None:
|
| 213 |
+
# txt_ai=get_answer_ai(message["text"] )
|
| 214 |
+
# sr,response_audio = genrate_speech(txt_ai,'asg2024/vits-ar-sa-huba')
|
| 215 |
+
# with tempfile.NamedTemporaryFile(delete=True) as temp_file:
|
| 216 |
+
# filename=temp_file.name+'.wav'
|
| 217 |
+
# sf.write(filename,response_audio, sr,format='WAV')
|
| 218 |
+
# bot_msg1 = {"text": txt_ai,
|
| 219 |
+
# "files": [{"file":FileData(path=filename)}]}
|
| 220 |
+
# history[-1][1]=bot_msg1
|
| 221 |
|
| 222 |
|
| 223 |
|