ReplyOnPause and ReplyOnStopWords can be interrupted (#119)

* Add all this code

* add code

* Fix demo

---------

Co-authored-by: Freddy Boulton <freddyboulton@hf-freddy.local>
This commit is contained in:
Freddy Boulton
2025-03-03 21:47:16 -05:00
committed by GitHub
parent 87954a62aa
commit 6ea54777af
13 changed files with 155 additions and 40 deletions

View File

@@ -41,7 +41,7 @@ def response(
response_text = (
groq_client.chat.completions.create(
model="llama-3.1-8b-instant",
max_tokens=512,
max_tokens=200,
messages=messages, # type: ignore
)
.choices[0]
@@ -49,6 +49,7 @@ def response(
)
chatbot.append({"role": "assistant", "content": response_text})
yield AdditionalOutputs(chatbot)
for chunk in tts_client.text_to_speech.convert_as_stream(
text=response_text, # type: ignore
@@ -58,7 +59,6 @@ def response(
):
audio_array = np.frombuffer(chunk, dtype=np.int16).reshape(1, -1)
yield (24000, audio_array)
yield AdditionalOutputs(chatbot)
chatbot = gr.Chatbot(type="messages")