From 018539d41baca8cfd902ae2814cd5fcdb7910a99 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Sat, 28 Feb 2026 19:40:23 -0500 Subject: [PATCH] feat: parameterize min silence duration and increase default to 1000ms --- README.md | 1 + transcribe.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aa9a0cf..40360b7 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Run the script using `python3 transcribe.py` with optional flags. - `-s`, `--stream`: Enable real-time streaming transcription/draft mode (Strategy 1). - `-c`, `--context`: Enable prompt caching/rolling context to help the model maintain sentence continuity across chunks. - `--lang [CODE]`: Hardcode the source language (e.g., `en`, `es`) to bypass automatic language detection for faster processing. +- `--silence [MS]`: Set the minimum silence duration in milliseconds to end a chunk. Defaults to 1000ms. Increase to force longer sentences before translation. --- diff --git a/transcribe.py b/transcribe.py index ceb89ca..5d685e0 100644 --- a/transcribe.py +++ b/transcribe.py @@ -46,7 +46,6 @@ SAMPLERATE = 16000 BLOCK_SIZE = 512 VAD_THRESHOLD = 0.5 BUFFER_LIMIT = SAMPLERATE * 30 -MIN_SILENCE_DURATION_MS = 500 audio_queue = queue.Queue() ingest_queue = queue.Queue() @@ -96,6 +95,7 @@ def main(): parser.add_argument("-s", "--stream", action="store_true", help="Enable real-time streaming transcription (Draft mode)") parser.add_argument("-c", "--context", action="store_true", help="Enable prompt caching/rolling context for better continuity") parser.add_argument("--lang", type=str, help="Hardcode source language (e.g. 'en', 'es') to bypass detection") + parser.add_argument("--silence", type=int, default=1000, help="Minimum silence duration in ms to end a chunk (default: 1000)") args = parser.parse_args() @@ -167,7 +167,7 @@ def main(): vad_model, sampling_rate=SAMPLERATE, threshold=VAD_THRESHOLD, - min_silence_duration_ms=MIN_SILENCE_DURATION_MS + min_silence_duration_ms=args.silence ) if len(speech_timestamps) > 0: @@ -175,7 +175,7 @@ def main(): last_end = speech_timestamps[-1]['end'] buffer_len_samples = len(current_audio) - if (buffer_len_samples - last_end) > (SAMPLERATE * MIN_SILENCE_DURATION_MS / 1000) or buffer_len_samples > BUFFER_LIMIT: + if (buffer_len_samples - last_end) > (SAMPLERATE * args.silence / 1000) or buffer_len_samples > BUFFER_LIMIT: # Clear draft line if it was used if args.stream: