Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -137,10 +137,10 @@ def translate(audio):
|
|
137 |
transcription = whisper_model.transcribe(audio, language="pl")
|
138 |
return transcription["text"]
|
139 |
|
140 |
-
@spaces.GPU
|
141 |
def predict(audio, _chatbot, _task_history):
|
142 |
# Użyj funkcji translate, aby przekształcić audio w tekst
|
143 |
-
_query =
|
144 |
|
145 |
print(f"____User: {_parse_text(_query)}")
|
146 |
_chatbot.append((_parse_text(_query), ""))
|
@@ -162,7 +162,7 @@ def predict(audio, _chatbot, _task_history):
|
|
162 |
return full_response
|
163 |
|
164 |
|
165 |
-
@spaces.GPU
|
166 |
def regenerate(_chatbot, _task_history):
|
167 |
if not _task_history:
|
168 |
yield _chatbot
|
@@ -172,7 +172,7 @@ def regenerate(_chatbot, _task_history):
|
|
172 |
yield from predict(item[0], _chatbot, _task_history)
|
173 |
|
174 |
|
175 |
-
with gr.Blocks() as
|
176 |
gr.Markdown(DESCRIPTION)
|
177 |
chatbot = gr.Chatbot(label='Llama Voice Chatbot', elem_classes="control-height")
|
178 |
query = gr.Textbox(lines=2, label='Input')
|
@@ -186,7 +186,7 @@ with gr.Blocks() as chat_demo:
|
|
186 |
audio_upload = gr.Audio(source="microphone", type="filepath", show_label=False)
|
187 |
submit_audio_btn = gr.Button("🎙️ Send an audio")
|
188 |
|
189 |
-
|
190 |
-
|
191 |
|
192 |
-
|
|
|
137 |
transcription = whisper_model.transcribe(audio, language="pl")
|
138 |
return transcription["text"]
|
139 |
|
140 |
+
@spaces.GPU(enable_queue=True)
|
141 |
def predict(audio, _chatbot, _task_history):
|
142 |
# Użyj funkcji translate, aby przekształcić audio w tekst
|
143 |
+
_query = whisper_model.transcribe(audio)["text"]
|
144 |
|
145 |
print(f"____User: {_parse_text(_query)}")
|
146 |
_chatbot.append((_parse_text(_query), ""))
|
|
|
162 |
return full_response
|
163 |
|
164 |
|
165 |
+
@spaces.GPU(enable_queue=True)
|
166 |
def regenerate(_chatbot, _task_history):
|
167 |
if not _task_history:
|
168 |
yield _chatbot
|
|
|
172 |
yield from predict(item[0], _chatbot, _task_history)
|
173 |
|
174 |
|
175 |
+
with gr.Blocks() as demo:
|
176 |
gr.Markdown(DESCRIPTION)
|
177 |
chatbot = gr.Chatbot(label='Llama Voice Chatbot', elem_classes="control-height")
|
178 |
query = gr.Textbox(lines=2, label='Input')
|
|
|
186 |
audio_upload = gr.Audio(source="microphone", type="filepath", show_label=False)
|
187 |
submit_audio_btn = gr.Button("🎙️ Send an audio")
|
188 |
|
189 |
+
submit_btn.click(predict, [query, chatbot, task_history], [chatbot], show_progress=True)
|
190 |
+
submit_audio_btn.click(predict, [audio_upload, chatbot, task_history], [chatbot], show_progress=True).then(update_audio, chatbot, audio_output)
|
191 |
|
192 |
+
demo.queue().launch()
|