Spaces:
Runtime error
Runtime error
Commit
·
f65f35d
1
Parent(s):
53aaa23
link agent with simple talk
Browse files
app.py
CHANGED
|
@@ -897,10 +897,45 @@ def ClearAudio():
|
|
| 897 |
|
| 898 |
return None
|
| 899 |
|
|
|
|
|
|
|
|
|
|
| 900 |
def SingleTalk(WavFile, history5):
|
|
|
|
| 901 |
ConvertText = speech_to_text(WavFile)
|
| 902 |
history5 = history5 + [(ConvertText, None)]
|
| 903 |
-
yield [None, history5]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 904 |
|
| 905 |
with gr.Blocks() as demo:
|
| 906 |
# gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
|
|
@@ -987,7 +1022,7 @@ with gr.Blocks() as demo:
|
|
| 987 |
upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
|
| 988 |
agentchoice.change(SetAgent, agentchoice, None)
|
| 989 |
frash_logs.click(read_logs, None, logs)
|
| 990 |
-
voice_input.stop_recording(SingleTalk, [voice_input, chatbot], [voice_output, chatbot])
|
| 991 |
# voice_output.end(ClearAudio, None, voice_output)
|
| 992 |
# def clear_voice():
|
| 993 |
# print("clear audio ...")
|
|
|
|
| 897 |
|
| 898 |
return None
|
| 899 |
|
| 900 |
+
global last_answer
|
| 901 |
+
last_answer = ""
|
| 902 |
+
|
| 903 |
def SingleTalk(WavFile, history5):
|
| 904 |
+
global last_answer
|
| 905 |
ConvertText = speech_to_text(WavFile)
|
| 906 |
history5 = history5 + [(ConvertText, None)]
|
| 907 |
+
yield [None, None, history5]
|
| 908 |
+
message = ConvertText
|
| 909 |
+
try:
|
| 910 |
+
response = agent.run(message)
|
| 911 |
+
time.sleep(0.1)
|
| 912 |
+
last_answer = response
|
| 913 |
+
history2 = history2 + [(None, response)]
|
| 914 |
+
yield [None, None, history2]
|
| 915 |
+
# yield ["", history2, None, None]
|
| 916 |
+
print ("response of chatbot:", response)
|
| 917 |
+
# real_content = response[-1:]
|
| 918 |
+
# print("real_content", real_content)
|
| 919 |
+
try:
|
| 920 |
+
temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
|
| 921 |
+
file_name = temp.split(")")[0]
|
| 922 |
+
print("file_name:", file_name)
|
| 923 |
+
history2 = history2 + [(None, (file_name,))]
|
| 924 |
+
Filename_Chatbot = file_name
|
| 925 |
+
yield [None, None, history2]
|
| 926 |
+
except:
|
| 927 |
+
print("No need to add file in chatbot")
|
| 928 |
+
|
| 929 |
+
except Exception as e:
|
| 930 |
+
print("chathmi3 SingleTalk error:", e)
|
| 931 |
+
|
| 932 |
+
# history = history + [(message, None)]
|
| 933 |
+
print("History2 in Simple Talk: ", history2)
|
| 934 |
+
print("-" * 20)
|
| 935 |
+
print("-" * 20)
|
| 936 |
+
|
| 937 |
+
|
| 938 |
+
|
| 939 |
|
| 940 |
with gr.Blocks() as demo:
|
| 941 |
# gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
|
|
|
|
| 1022 |
upload_button.upload(func_upload_file, [upload_button, chatbot], chatbot)
|
| 1023 |
agentchoice.change(SetAgent, agentchoice, None)
|
| 1024 |
frash_logs.click(read_logs, None, logs)
|
| 1025 |
+
voice_input.stop_recording(SingleTalk, [voice_input, chatbot], [voice_input, voice_output, chatbot])
|
| 1026 |
# voice_output.end(ClearAudio, None, voice_output)
|
| 1027 |
# def clear_voice():
|
| 1028 |
# print("clear audio ...")
|