Fix main_v2 bridge and pipeline regressions

This commit is contained in:
Adolfo Reyna
2026-03-16 21:15:15 -04:00
parent ffeb996d7e
commit f79c4f7310
7 changed files with 190 additions and 51 deletions
+24 -9
View File
@@ -100,7 +100,7 @@ def run_transcription(out_queue, args):
if status: print(status, file=sys.stderr)
audio_queue.put(indata.copy())
audio_buffer, speech_started, rolling_context = [], False, ""
audio_buffer, speech_started, rolling_context, rolling_context_en = [], False, "", ""
last_stream_time = time.time()
try:
@@ -127,7 +127,7 @@ def run_transcription(out_queue, args):
transcribe_kwargs = {
"path_or_hf_repo": model_name,
"temperature": args.temperature_fallback,
"word_timestamps": True,
"word_timestamps": args.speaker_diarization,
"logprob_threshold": args.logprob_threshold,
"compression_ratio_threshold": args.compression_threshold,
}
@@ -139,13 +139,26 @@ def run_transcription(out_queue, args):
detected_lang = res_asr.get('language', args.lang or 'en')
if text:
if args.filter_lang and args.lang and detected_lang != args.lang:
print(f"[Transcribe] Discarding segment (Detected: {detected_lang}, Expected: {args.lang})")
audio_buffer, speech_started = [], False
continue
english_text = text
if detected_lang != "en" or args.lang == 'en':
if detected_lang != "en":
bridge_kwargs = transcribe_kwargs.copy()
bridge_kwargs["task"] = "translate"
res_bridge = transcribe_with_controls(current_audio, bridge_kwargs)
english_text = res_bridge['text'].strip()
if detected_lang != "en":
bridge_kwargs = {
"path_or_hf_repo": model_name,
"task": "translate",
"temperature": args.temperature_fallback,
"logprob_threshold": args.logprob_threshold,
"compression_ratio_threshold": args.compression_threshold,
}
if args.lang:
bridge_kwargs["language"] = args.lang
if args.context and rolling_context_en:
bridge_kwargs["initial_prompt"] = rolling_context_en
res_bridge = transcribe_with_controls(current_audio, bridge_kwargs)
english_text = res_bridge.get("text", "").strip() or text
speaker_label = None
if diarization_pipeline:
@@ -171,7 +184,9 @@ def run_transcription(out_queue, args):
speaker_tag = f" ({speaker_label})" if speaker_label else ""
print(f"[Transcribe] {detected_lang.upper()}{speaker_tag}: {text}")
if args.context: rolling_context = (rolling_context + " " + text)[-200:].strip()
if args.context:
rolling_context = (rolling_context + " " + text)[-200:].strip()
rolling_context_en = (rolling_context_en + " " + english_text)[-200:].strip()
audio_buffer, speech_started = [], False