Spaces:
Sleeping
Sleeping
ASG Models
commited on
Update app.py
Browse files
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 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
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 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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))
|