Spaces:
Runtime error
Runtime error
Commit
·
6c448c0
1
Parent(s):
b06ae43
update sound
Browse files- app.py +17 -5
- requirements.txt +2 -1
app.py
CHANGED
@@ -59,6 +59,7 @@ from langchain.document_loaders import (
|
|
59 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
60 |
from langchain.docstore.document import Document
|
61 |
import langchain
|
|
|
62 |
|
63 |
langchain.debug = True
|
64 |
global memory2
|
@@ -873,7 +874,7 @@ def Inference_Agent(history_inf):
|
|
873 |
def ClearText():
|
874 |
return ""
|
875 |
|
876 |
-
def
|
877 |
global Filename_Chatbot
|
878 |
try:
|
879 |
if Filename_Chatbot.split(".")[1] == 'wav':
|
@@ -885,6 +886,17 @@ def playsound():
|
|
885 |
print("playsound error:", e)
|
886 |
return None
|
887 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
888 |
|
889 |
def HMI_Runing():
|
890 |
return [gr.update(visible=False), gr.update(visible=True)]
|
@@ -1007,7 +1019,7 @@ with gr.Blocks() as demo:
|
|
1007 |
logs = gr.Textbox(max_lines = 25)
|
1008 |
# upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
|
1009 |
clear_button.click(clearall, None, [chatbot, submit_button, stop_button], voice_output)
|
1010 |
-
retry_button.click(retry, chatbot, chatbot).success(
|
1011 |
success(HMI_Wait, None, [submit_button, stop_button]).\
|
1012 |
success(ClearAudio, None, voice_output)
|
1013 |
# inf1 = inputtext.submit(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
@@ -1018,11 +1030,11 @@ with gr.Blocks() as demo:
|
|
1018 |
# then(HMI_Wait, None, [submit_button, stop_button])
|
1019 |
# inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button])
|
1020 |
inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button]).\
|
1021 |
-
success(
|
1022 |
success(ClearAudio, None, voice_output)
|
1023 |
inf3 = submit_button.click(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
1024 |
success(HMI_Runing, None, [submit_button, stop_button]).\
|
1025 |
-
success(
|
1026 |
success(HMI_Wait, None, [submit_button, stop_button]).\
|
1027 |
success(ClearAudio, None, voice_output)
|
1028 |
# inf2 = inputtext.submit(display_input, [inputtext, chatbot], chatbot).\
|
@@ -1035,7 +1047,7 @@ with gr.Blocks() as demo:
|
|
1035 |
frash_logs.click(read_logs, None, logs)
|
1036 |
voice_input.stop_recording(SingleTalk, [voice_input, chatbot], [voice_input, voice_output, chatbot]).\
|
1037 |
success(Text2Sound_HMI,None,None).\
|
1038 |
-
success(
|
1039 |
success(ClearAudio, None, voice_output)
|
1040 |
# voice_output.end(ClearAudio, None, voice_output)
|
1041 |
# def clear_voice():
|
|
|
59 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
60 |
from langchain.docstore.document import Document
|
61 |
import langchain
|
62 |
+
import playsound
|
63 |
|
64 |
langchain.debug = True
|
65 |
global memory2
|
|
|
874 |
def ClearText():
|
875 |
return ""
|
876 |
|
877 |
+
def playsound1():
|
878 |
global Filename_Chatbot
|
879 |
try:
|
880 |
if Filename_Chatbot.split(".")[1] == 'wav':
|
|
|
886 |
print("playsound error:", e)
|
887 |
return None
|
888 |
|
889 |
+
def playsound2():
|
890 |
+
global Filename_Chatbot
|
891 |
+
try:
|
892 |
+
if Filename_Chatbot.split(".")[1] == 'wav':
|
893 |
+
soundfilename = Filename_Chatbot
|
894 |
+
print("soundfilename:", soundfilename)
|
895 |
+
# return None
|
896 |
+
playsound(soundfilename)
|
897 |
+
except Exception as e:
|
898 |
+
print("playsound error:", e)
|
899 |
+
return None
|
900 |
|
901 |
def HMI_Runing():
|
902 |
return [gr.update(visible=False), gr.update(visible=True)]
|
|
|
1019 |
logs = gr.Textbox(max_lines = 25)
|
1020 |
# upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
|
1021 |
clear_button.click(clearall, None, [chatbot, submit_button, stop_button], voice_output)
|
1022 |
+
retry_button.click(retry, chatbot, chatbot).success(playsound1, None, voice_output).\
|
1023 |
success(HMI_Wait, None, [submit_button, stop_button]).\
|
1024 |
success(ClearAudio, None, voice_output)
|
1025 |
# inf1 = inputtext.submit(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
|
|
1030 |
# then(HMI_Wait, None, [submit_button, stop_button])
|
1031 |
# inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button])
|
1032 |
inf4 = inputtext.submit(chathmi4, [inputtext, chatbot], [inputtext, chatbot, submit_button, stop_button]).\
|
1033 |
+
success(playsound1, None, voice_output).\
|
1034 |
success(ClearAudio, None, voice_output)
|
1035 |
inf3 = submit_button.click(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
1036 |
success(HMI_Runing, None, [submit_button, stop_button]).\
|
1037 |
+
success(playsound1, None, voice_output).\
|
1038 |
success(HMI_Wait, None, [submit_button, stop_button]).\
|
1039 |
success(ClearAudio, None, voice_output)
|
1040 |
# inf2 = inputtext.submit(display_input, [inputtext, chatbot], chatbot).\
|
|
|
1047 |
frash_logs.click(read_logs, None, logs)
|
1048 |
voice_input.stop_recording(SingleTalk, [voice_input, chatbot], [voice_input, voice_output, chatbot]).\
|
1049 |
success(Text2Sound_HMI,None,None).\
|
1050 |
+
success(playsound2, None, voice_output).\
|
1051 |
success(ClearAudio, None, voice_output)
|
1052 |
# voice_output.end(ClearAudio, None, voice_output)
|
1053 |
# def clear_voice():
|
requirements.txt
CHANGED
@@ -8,4 +8,5 @@ duckduckgo-search
|
|
8 |
tiktoken
|
9 |
azure-cognitiveservices-speech
|
10 |
pymupdf
|
11 |
-
ffmpeg
|
|
|
|
8 |
tiktoken
|
9 |
azure-cognitiveservices-speech
|
10 |
pymupdf
|
11 |
+
ffmpeg
|
12 |
+
playsound
|