Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,7 @@ import torch
|
|
25 |
import torchaudio
|
26 |
from transformers import pipeline, AutoModelForSpeechSeq2Seq, AutoProcessor
|
27 |
import numpy as np
|
|
|
28 |
|
29 |
|
30 |
|
@@ -267,6 +268,11 @@ pipe_asr = pipeline(
|
|
267 |
return_timestamps=True
|
268 |
)
|
269 |
|
|
|
|
|
|
|
|
|
|
|
270 |
|
271 |
def transcribe_function(stream, new_chunk):
|
272 |
try:
|
@@ -294,6 +300,9 @@ def transcribe_function(stream, new_chunk):
|
|
294 |
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
295 |
full_text = result.get("text", "")
|
296 |
|
|
|
|
|
|
|
297 |
return stream, full_text, full_text
|
298 |
|
299 |
|
|
|
25 |
import torchaudio
|
26 |
from transformers import pipeline, AutoModelForSpeechSeq2Seq, AutoProcessor
|
27 |
import numpy as np
|
28 |
+
import threading
|
29 |
|
30 |
|
31 |
|
|
|
268 |
return_timestamps=True
|
269 |
)
|
270 |
|
271 |
+
# Define the function to reset the state after 10 seconds
|
272 |
+
def auto_reset_state():
|
273 |
+
time.sleep(10)
|
274 |
+
return None, "" # Reset the state and clear input text
|
275 |
+
|
276 |
|
277 |
def transcribe_function(stream, new_chunk):
|
278 |
try:
|
|
|
300 |
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
301 |
full_text = result.get("text", "")
|
302 |
|
303 |
+
# Start a thread to reset the state after 10 seconds
|
304 |
+
threading.Thread(target=auto_reset_state).start()
|
305 |
+
|
306 |
return stream, full_text, full_text
|
307 |
|
308 |
|