Upload folder using huggingface_hub
Browse files
chat.py
CHANGED
@@ -61,7 +61,7 @@ def speak(history):
|
|
61 |
speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
|
62 |
audio = base64.b64encode(speech.read()).decode("utf-8")
|
63 |
src = f"data:audio/mpeg;base64,{audio}"
|
64 |
-
audio_element = f'<audio src="{src}"></audio>'
|
65 |
return audio_element
|
66 |
|
67 |
def vote(data: gr.LikeData):
|
@@ -95,7 +95,7 @@ with gr.Blocks(title="Paitient Sim", css=css) as demo:
|
|
95 |
audio_html = gr.HTML(visible=False, elem_id="player")
|
96 |
msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
|
97 |
bot, [chatbot, thread], chatbot).then(
|
98 |
-
speak, chatbot, audio_html
|
99 |
)
|
100 |
mic.stop_recording(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
|
101 |
lambda:None, None, mic).then(
|
|
|
61 |
speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
|
62 |
audio = base64.b64encode(speech.read()).decode("utf-8")
|
63 |
src = f"data:audio/mpeg;base64,{audio}"
|
64 |
+
audio_element = f'<audio src="{src}" autoplay controls></audio>'
|
65 |
return audio_element
|
66 |
|
67 |
def vote(data: gr.LikeData):
|
|
|
95 |
audio_html = gr.HTML(visible=False, elem_id="player")
|
96 |
msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
|
97 |
bot, [chatbot, thread], chatbot).then(
|
98 |
+
speak, chatbot, audio_html
|
99 |
)
|
100 |
mic.stop_recording(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
|
101 |
lambda:None, None, mic).then(
|