Spaces:
Runtime error
Runtime error
change history
Browse files
app.py
CHANGED
@@ -26,18 +26,20 @@ def run_model(text):
|
|
26 |
|
27 |
|
28 |
|
29 |
-
def
|
30 |
|
31 |
txt = p(audio)["text"]
|
|
|
|
|
32 |
response = run_model(txt)
|
33 |
# Remove all text from SOURCES: to the end of the string
|
34 |
trimmed_response = response.split("SOURCES:")[0]
|
35 |
myobj = gTTS(text=trimmed_response, lang='en', slow=False)
|
36 |
-
myobj.save(
|
37 |
# split audio by / and keep the last element
|
38 |
# audio = audio.split("/")[-1]
|
39 |
# audio = audio + ".wav"
|
40 |
-
history.append(( (audio, ) , (
|
41 |
print(history)
|
42 |
return history
|
43 |
|
@@ -62,7 +64,7 @@ with gr.Blocks() as demo:
|
|
62 |
bot, chatbot, chatbot
|
63 |
)
|
64 |
|
65 |
-
audio.change(fn=
|
66 |
bot, chatbot, chatbot
|
67 |
)
|
68 |
|
|
|
26 |
|
27 |
|
28 |
|
29 |
+
def get_output(history, audio):
|
30 |
|
31 |
txt = p(audio)["text"]
|
32 |
+
history.append(( (audio, ) , txt))
|
33 |
+
audio_path = 'response.wav'
|
34 |
response = run_model(txt)
|
35 |
# Remove all text from SOURCES: to the end of the string
|
36 |
trimmed_response = response.split("SOURCES:")[0]
|
37 |
myobj = gTTS(text=trimmed_response, lang='en', slow=False)
|
38 |
+
myobj.save(audio_path)
|
39 |
# split audio by / and keep the last element
|
40 |
# audio = audio.split("/")[-1]
|
41 |
# audio = audio + ".wav"
|
42 |
+
history.append(( (audio, ) , (audio_path, )))
|
43 |
print(history)
|
44 |
return history
|
45 |
|
|
|
64 |
bot, chatbot, chatbot
|
65 |
)
|
66 |
|
67 |
+
audio.change(fn=get_output, inputs=[chatbot, audio], outputs=[chatbot]).then(
|
68 |
bot, chatbot, chatbot
|
69 |
)
|
70 |
|