Upload folder using huggingface_hub
Browse files
chat.py
CHANGED
@@ -62,9 +62,7 @@ def transcribe(file):
|
|
62 |
def speak(history):
|
63 |
text = history[-1][1]
|
64 |
speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
|
65 |
-
data, sr = sf.read(BytesIO(speech.read()))
|
66 |
-
#data= np.stack((data, data), axis=1)
|
67 |
-
print(sr, data.shape, data.dtype)
|
68 |
return sr, data
|
69 |
|
70 |
def vote(data: gr.LikeData):
|
@@ -97,7 +95,7 @@ def main():
|
|
97 |
mic = gr.Microphone(type="filepath", format="mp3", editable=False, waveform_options={"show_controls": False}, visible=False)
|
98 |
thread = gr.State(start_thread)
|
99 |
audio_html = gr.HTML(visible=False)
|
100 |
-
player = gr.Audio(autoplay=True, editable=False, waveform_options={"show_controls": False})
|
101 |
|
102 |
msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
|
103 |
bot, [chatbot, thread], chatbot).then(
|
|
|
62 |
def speak(history):
|
63 |
text = history[-1][1]
|
64 |
speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
|
65 |
+
data, sr = sf.read(BytesIO(speech.read()), dtype='int16')
|
|
|
|
|
66 |
return sr, data
|
67 |
|
68 |
def vote(data: gr.LikeData):
|
|
|
95 |
mic = gr.Microphone(type="filepath", format="mp3", editable=False, waveform_options={"show_controls": False}, visible=False)
|
96 |
thread = gr.State(start_thread)
|
97 |
audio_html = gr.HTML(visible=False)
|
98 |
+
player = gr.Audio(autoplay=True, editable=False, waveform_options={"show_controls": False}, visible=False)
|
99 |
|
100 |
msg.submit(user, [msg, mic, chatbot, thread], [msg, chatbot]).then(
|
101 |
bot, [chatbot, thread], chatbot).then(
|