Spaces:
Runtime error
Runtime error
Commit
·
ff0411d
1
Parent(s):
7b401d5
playsound func
Browse files
app.py
CHANGED
@@ -117,6 +117,8 @@ chunk_overlap = 300
|
|
117 |
global Audio_output
|
118 |
Audio_output = []
|
119 |
|
|
|
|
|
120 |
|
121 |
def load_single_document(file_path: str) -> List[Document]:
|
122 |
ext = "." + file_path.rsplit(".", 1)[-1]
|
@@ -695,6 +697,7 @@ def LinkElement(chatbot_history):
|
|
695 |
|
696 |
def chathmi3(message, history2):
|
697 |
global last_request
|
|
|
698 |
print("Input Message:", message)
|
699 |
last_request = message
|
700 |
history2 = history2 + [(message, None)]
|
@@ -712,6 +715,7 @@ def chathmi3(message, history2):
|
|
712 |
file_name = temp.split(")")[0]
|
713 |
print("file_name:", file_name)
|
714 |
history2 = history2 + [(None, (file_name,))]
|
|
|
715 |
yield ["", history2]
|
716 |
except:
|
717 |
print("No need to add file in chatbot")
|
@@ -786,6 +790,12 @@ def Inference_Agent(history_inf):
|
|
786 |
def ClearText():
|
787 |
return ""
|
788 |
|
|
|
|
|
|
|
|
|
|
|
|
|
789 |
with gr.Blocks() as demo:
|
790 |
# gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
|
791 |
# main = gr.ChatInterface(
|
@@ -846,7 +856,8 @@ with gr.Blocks() as demo:
|
|
846 |
# upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
|
847 |
clear_button.click(clearall, None, chatbot)
|
848 |
retry_button.click(retry, chatbot, chatbot)
|
849 |
-
inf1 = inputtext.submit(chathmi3, [inputtext, chatbot], [inputtext, chatbot])
|
|
|
850 |
# inf2 = inputtext.submit(display_input, [inputtext, chatbot], chatbot).\
|
851 |
# then(Inference_Agent, chatbot, [inputtext, chatbot])
|
852 |
stop_button.click(read_logs, None, logs, cancels=[inf1])
|
|
|
117 |
global Audio_output
|
118 |
Audio_output = []
|
119 |
|
120 |
+
global Filename_Chatbot
|
121 |
+
Filename_Chatbot = ""
|
122 |
|
123 |
def load_single_document(file_path: str) -> List[Document]:
|
124 |
ext = "." + file_path.rsplit(".", 1)[-1]
|
|
|
697 |
|
698 |
def chathmi3(message, history2):
|
699 |
global last_request
|
700 |
+
global Filename_Chatbot
|
701 |
print("Input Message:", message)
|
702 |
last_request = message
|
703 |
history2 = history2 + [(message, None)]
|
|
|
715 |
file_name = temp.split(")")[0]
|
716 |
print("file_name:", file_name)
|
717 |
history2 = history2 + [(None, (file_name,))]
|
718 |
+
Filename_Chatbot = file_name
|
719 |
yield ["", history2]
|
720 |
except:
|
721 |
print("No need to add file in chatbot")
|
|
|
790 |
def ClearText():
|
791 |
return ""
|
792 |
|
793 |
+
def playsound():
|
794 |
+
global Filename_Chatbot
|
795 |
+
if Filename_Chatbot.split(".")[1] == 'wav':
|
796 |
+
soundfilename = Filename_Chatbot
|
797 |
+
return soundfilename
|
798 |
+
|
799 |
with gr.Blocks() as demo:
|
800 |
# gr.Markdown("Start typing below and then click **SUBMIT** to see the output.")
|
801 |
# main = gr.ChatInterface(
|
|
|
856 |
# upload_button.upload(func_upload_file, [upload_button, main.chatbot], main.chatbot)
|
857 |
clear_button.click(clearall, None, chatbot)
|
858 |
retry_button.click(retry, chatbot, chatbot)
|
859 |
+
inf1 = inputtext.submit(chathmi3, [inputtext, chatbot], [inputtext, chatbot]).\
|
860 |
+
then(playsound, None, voice_output)
|
861 |
# inf2 = inputtext.submit(display_input, [inputtext, chatbot], chatbot).\
|
862 |
# then(Inference_Agent, chatbot, [inputtext, chatbot])
|
863 |
stop_button.click(read_logs, None, logs, cancels=[inf1])
|