Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -110,24 +110,10 @@ def transcribe_function(stream, new_chunk):
|
|
110 |
else:
|
111 |
stream = y
|
112 |
|
113 |
-
# Only process if there is significant audio input
|
114 |
-
if len(stream) > sr * 0.5: # Process if there is at least 0.5 seconds of audio
|
115 |
-
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
116 |
-
full_text = result.get("text", "")
|
117 |
-
if full_text.strip():
|
118 |
-
print(f"Transcription: {full_text}")
|
119 |
-
threading.Thread(target=auto_reset_state).start()
|
120 |
-
return stream, full_text, full_text
|
121 |
-
|
122 |
-
return stream, "", None
|
123 |
-
|
124 |
-
# Process the audio data for transcription
|
125 |
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
126 |
full_text = result.get("text", "")
|
127 |
|
128 |
-
# Start a thread to reset the state after 10 seconds
|
129 |
threading.Thread(target=auto_reset_state).start()
|
130 |
-
|
131 |
return stream, full_text, full_text
|
132 |
|
133 |
|
|
|
110 |
else:
|
111 |
stream = y
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
114 |
full_text = result.get("text", "")
|
115 |
|
|
|
116 |
threading.Thread(target=auto_reset_state).start()
|
|
|
117 |
return stream, full_text, full_text
|
118 |
|
119 |
|