From 13c78c882f3bab6120cadfec1768e04ca00831dc Mon Sep 17 00:00:00 2001 From: Christian Rute Date: Thu, 16 Jan 2025 18:27:51 +0100 Subject: [PATCH] workin < 60s --- app.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index dafbff5..419b1bc 100644 --- a/app.py +++ b/app.py @@ -54,7 +54,6 @@ def stop_recording(): global is_recording, recorded_audio, start_time if not is_recording: return "Not recording!" - sd.stop() is_recording = False elapsed_time = time.time() - start_time # Calculate elapsed time print(f"Recording stopped. Duration: {elapsed_time:.2f} seconds.") @@ -99,19 +98,25 @@ def transcribe_audio(): chunk_filename = f"chunk_{i}.wav" chunk.export(chunk_filename, format="wav") print(f"Transcribing chunk {i + 1}/{len(chunks)}...") + + # Transcribe the chunk result = pipe(chunk_filename) transcription.append(result["text"]) # Clean up temporary chunk file os.remove(chunk_filename) + # Stream intermediate transcription + yield f"{' '.join(transcription)}" + print("Transcription complete.") - return " ".join(transcription) + yield f"{' '.join(transcription)}" else: print(f"Audio is short enough ({duration:.2f} seconds). Transcribing directly...") result = pipe(FILENAME) print("Transcription complete.") - return result["text"] + yield f"{result['text']}" + # Gradio Interface