Upload folder using huggingface_hub
Browse files
chat.py
CHANGED
|
@@ -36,7 +36,7 @@ def user(text, audio, history, thread):
|
|
| 36 |
text = transcribe(audio)
|
| 37 |
print(f"Message: {text}")
|
| 38 |
message = client.beta.threads.messages.create(thread_id=thread.id, role="user", content=text)
|
| 39 |
-
return history + [[text, None]]
|
| 40 |
|
| 41 |
def bot(history, thread):
|
| 42 |
stream = client.beta.threads.runs.create(thread_id=thread.id, assistant_id=assistant.id, stream=True)
|
|
@@ -95,11 +95,11 @@ def main():
|
|
| 95 |
msg = gr.Textbox(label="Say something.", elem_id="textbox")
|
| 96 |
mic = gr.Microphone(type="filepath", format="mp3", editable=False, waveform_options={"show_controls": False}, visible=False)
|
| 97 |
player = gr.Audio(autoplay=True, editable=False, waveform_options={"show_controls": False}, visible=False)
|
| 98 |
-
msg.submit(user, [msg, mic, chatbot, thread], chatbot).then(
|
| 99 |
bot, [chatbot, thread], chatbot).then(
|
| 100 |
speak, chatbot, player
|
| 101 |
)
|
| 102 |
-
mic.stop_recording(user, [msg, mic, chatbot, thread], chatbot).then(
|
| 103 |
lambda:None, None, mic).then(
|
| 104 |
bot, [chatbot, thread], chatbot).then(
|
| 105 |
speak, chatbot, player
|
|
|
|
| 36 |
text = transcribe(audio)
|
| 37 |
print(f"Message: {text}")
|
| 38 |
message = client.beta.threads.messages.create(thread_id=thread.id, role="user", content=text)
|
| 39 |
+
return "", history + [[text, None]]
|
| 40 |
|
| 41 |
def bot(history, thread):
|
| 42 |
stream = client.beta.threads.runs.create(thread_id=thread.id, assistant_id=assistant.id, stream=True)
|
|
|
|
| 95 |
msg = gr.Textbox(label="Say something.", elem_id="textbox")
|
| 96 |
mic = gr.Microphone(type="filepath", format="mp3", editable=False, waveform_options={"show_controls": False}, visible=False)
|
| 97 |
player = gr.Audio(autoplay=True, editable=False, waveform_options={"show_controls": False}, visible=False)
|
| 98 |
+
msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
|
| 99 |
bot, [chatbot, thread], chatbot).then(
|
| 100 |
speak, chatbot, player
|
| 101 |
)
|
| 102 |
+
mic.stop_recording(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
|
| 103 |
lambda:None, None, mic).then(
|
| 104 |
bot, [chatbot, thread], chatbot).then(
|
| 105 |
speak, chatbot, player
|