Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -73,28 +73,20 @@ def transcribe_function(stream, new_chunk):
|
|
73 |
if max_abs_y > 0:
|
74 |
y = y / max_abs_y
|
75 |
|
76 |
-
#
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
if duration >= 7:
|
82 |
-
# Process the audio data for transcription
|
83 |
-
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
84 |
-
full_text = result.get("text", "")
|
85 |
-
print(f"Transcription: {full_text}")
|
86 |
-
|
87 |
-
# Retrieve hybrid response using Neo4j and other methods
|
88 |
-
response_text = retriever(full_text)
|
89 |
-
print(f"Response: {response_text}")
|
90 |
|
91 |
-
|
92 |
-
|
|
|
93 |
|
94 |
-
|
95 |
-
|
96 |
|
97 |
-
return stream,
|
98 |
|
99 |
|
100 |
|
@@ -226,9 +218,9 @@ def process_audio_query(audio_input):
|
|
226 |
interface = gr.Interface(
|
227 |
fn=process_audio_query,
|
228 |
inputs=gr.Audio(sources="microphone", type="numpy",streaming=True),
|
229 |
-
outputs=gr.Audio(type="filepath", autoplay=True),
|
230 |
description="Ask questions via audio and receive audio responses.",
|
231 |
-
allow_flagging="never" # Disables the Clear button
|
232 |
)
|
233 |
|
234 |
# Launch the Gradio app
|
|
|
73 |
if max_abs_y > 0:
|
74 |
y = y / max_abs_y
|
75 |
|
76 |
+
# Ensure stream is also at least 1-dimensional before concatenation
|
77 |
+
if stream is not None and len(stream) > 0:
|
78 |
+
stream = np.concatenate([stream, y])
|
79 |
+
else:
|
80 |
+
stream = y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
# Process the audio data for transcription
|
83 |
+
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
84 |
+
full_text = result.get("text", "")
|
85 |
|
86 |
+
# Start a thread to reset the state after 10 seconds
|
87 |
+
threading.Thread(target=auto_reset_state).start()
|
88 |
|
89 |
+
return stream, full_text, full_text
|
90 |
|
91 |
|
92 |
|
|
|
218 |
interface = gr.Interface(
|
219 |
fn=process_audio_query,
|
220 |
inputs=gr.Audio(sources="microphone", type="numpy",streaming=True),
|
221 |
+
outputs=gr.Audio(type="filepath", autoplay=True,interactive=False),
|
222 |
description="Ask questions via audio and receive audio responses.",
|
223 |
+
#allow_flagging="never" # Disables the Clear button
|
224 |
)
|
225 |
|
226 |
# Launch the Gradio app
|