Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -458,37 +458,37 @@ pipe_asr = pipeline("automatic-speech-recognition", model=model, tokenizer=proce
|
|
458 |
|
459 |
base_audio_drive = "/data/audio"
|
460 |
|
461 |
-
# def transcribe_function(stream, new_chunk):
|
462 |
-
# try:
|
463 |
-
# sr, y = new_chunk[0], new_chunk[1]
|
464 |
-
# except TypeError:
|
465 |
-
# print(f"Error chunk structure: {type(new_chunk)}, content: {new_chunk}")
|
466 |
-
# return stream, "", None
|
467 |
-
|
468 |
-
# y = y.astype(np.float32) / np.max(np.abs(y))
|
469 |
-
|
470 |
-
# if stream is not None:
|
471 |
-
# stream = np.concatenate([stream, y])
|
472 |
-
# else:
|
473 |
-
# stream = y
|
474 |
-
|
475 |
-
# result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
476 |
-
|
477 |
-
# full_text = result.get("text","")
|
478 |
-
|
479 |
-
# return stream, full_text, result
|
480 |
-
|
481 |
-
|
482 |
def transcribe_function(stream, new_chunk):
|
483 |
-
|
|
|
|
|
|
|
|
|
|
|
484 |
y = y.astype(np.float32) / np.max(np.abs(y))
|
|
|
485 |
if stream is not None:
|
486 |
stream = np.concatenate([stream, y])
|
487 |
else:
|
488 |
stream = y
|
|
|
489 |
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
490 |
-
|
491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
|
493 |
|
494 |
|
|
|
458 |
|
459 |
base_audio_drive = "/data/audio"
|
460 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
def transcribe_function(stream, new_chunk):
|
462 |
+
try:
|
463 |
+
sr, y = new_chunk[0], new_chunk[1]
|
464 |
+
except TypeError:
|
465 |
+
print(f"Error chunk structure: {type(new_chunk)}, content: {new_chunk}")
|
466 |
+
return stream, "", None
|
467 |
+
|
468 |
y = y.astype(np.float32) / np.max(np.abs(y))
|
469 |
+
|
470 |
if stream is not None:
|
471 |
stream = np.concatenate([stream, y])
|
472 |
else:
|
473 |
stream = y
|
474 |
+
|
475 |
result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
476 |
+
|
477 |
+
full_text = result.get("text","")
|
478 |
+
|
479 |
+
return stream, full_text, result
|
480 |
+
|
481 |
+
|
482 |
+
# def transcribe_function(stream, new_chunk):
|
483 |
+
# sr, y = new_chunk[0], new_chunk[1]
|
484 |
+
# y = y.astype(np.float32) / np.max(np.abs(y))
|
485 |
+
# if stream is not None:
|
486 |
+
# stream = np.concatenate([stream, y])
|
487 |
+
# else:
|
488 |
+
# stream = y
|
489 |
+
# result = pipe_asr({"array": stream, "sampling_rate": sr}, return_timestamps=False)
|
490 |
+
# full_text = result.get("text", "")
|
491 |
+
# return stream, full_text # Return the transcribed text
|
492 |
|
493 |
|
494 |
|