chibop commited on
Commit
7dbb133
·
verified ·
1 Parent(s): f22c88d

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. chat.py +4 -3
chat.py CHANGED
@@ -59,8 +59,9 @@ def speak(history):
59
  text = history[-1][1]
60
  speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
61
  audio = base64.b64encode(speech.read()).decode("utf-8")
62
- audio_element = f'<audio src="data:audio/mpeg;base64,{audio}" autoplay></audio>'
63
- return audio_element
 
64
 
65
  def vote(data: gr.LikeData):
66
  if data.liked:
@@ -95,7 +96,7 @@ with gr.Blocks(title="Paitient Sim", css=css) as demo:
95
  msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot], queue=False).then(
96
  bot, [chatbot, thread], chatbot
97
  ).then(
98
- speak, chatbot, audio_html
99
  )
100
  mic.stop_recording(user, [msg, mic, chatbot, thread], [msg, chatbot], queue=False).then(
101
  lambda:None, None, mic, queue=False).then(
 
59
  text = history[-1][1]
60
  speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
61
  audio = base64.b64encode(speech.read()).decode("utf-8")
62
+ src = f"data:audio/mpeg;base64,{audio}"
63
+ #audio_element = f'<audio src="{src}" autoplay></audio>'
64
+ return src
65
 
66
  def vote(data: gr.LikeData):
67
  if data.liked:
 
96
  msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot], queue=False).then(
97
  bot, [chatbot, thread], chatbot
98
  ).then(
99
+ speak, chatbot, "audio"
100
  )
101
  mic.stop_recording(user, [msg, mic, chatbot, thread], [msg, chatbot], queue=False).then(
102
  lambda:None, None, mic, queue=False).then(