feat: parameterize min silence duration and increase default to 1000ms
This commit is contained in:
@@ -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).
|
- `-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.
|
- `-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.
|
- `--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.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -46,7 +46,6 @@ SAMPLERATE = 16000
|
|||||||
BLOCK_SIZE = 512
|
BLOCK_SIZE = 512
|
||||||
VAD_THRESHOLD = 0.5
|
VAD_THRESHOLD = 0.5
|
||||||
BUFFER_LIMIT = SAMPLERATE * 30
|
BUFFER_LIMIT = SAMPLERATE * 30
|
||||||
MIN_SILENCE_DURATION_MS = 500
|
|
||||||
|
|
||||||
audio_queue = queue.Queue()
|
audio_queue = queue.Queue()
|
||||||
ingest_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("-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("-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("--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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ def main():
|
|||||||
vad_model,
|
vad_model,
|
||||||
sampling_rate=SAMPLERATE,
|
sampling_rate=SAMPLERATE,
|
||||||
threshold=VAD_THRESHOLD,
|
threshold=VAD_THRESHOLD,
|
||||||
min_silence_duration_ms=MIN_SILENCE_DURATION_MS
|
min_silence_duration_ms=args.silence
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(speech_timestamps) > 0:
|
if len(speech_timestamps) > 0:
|
||||||
@@ -175,7 +175,7 @@ def main():
|
|||||||
last_end = speech_timestamps[-1]['end']
|
last_end = speech_timestamps[-1]['end']
|
||||||
buffer_len_samples = len(current_audio)
|
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
|
# Clear draft line if it was used
|
||||||
if args.stream:
|
if args.stream:
|
||||||
|
|||||||
Reference in New Issue
Block a user