The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(stt): thread confidence thresholds into faster-whisper's own gate (#74178)
PRATHAMESH75fe6330de035c
diff --git a/tests/tools/test_stt_silence_hallucinations.py b/tests/tools/test_stt_silence_hallucinations.pyindex 661e4ab7972..3268f2ee261 100644--- a/tests/tools/test_stt_silence_hallucinations.py+++ b/tests/tools/test_stt_silence_hallucinations.py@@ -41,6 +41,28 @@ class TestBuildLocalTranscribeKwargs:)+ def test_confidence_thresholds_default_to_faster_whisper_values(self):+ kwargs = build_local_transcribe_kwargs({})+ assert kwargs["no_speech_threshold"] == _NO_SPEECH_PROB_THRESHOLD_DEFAULT+ assert kwargs["log_prob_threshold"] == _LOGPROB_THRESHOLD_DEFAULT++ def test_confidence_thresholds_configurable_reach_model_gate(self):+ # The same stt.local knobs the post-filter reads must also be threaded+ # into faster-whisper's internal gate, or non-English speech is dropped+ # before it ever reaches our segment filter.+ kwargs = build_local_transcribe_kwargs(+ {"local": {"no_speech_prob_threshold": 0.9, "logprob_threshold": -2.0}}+ )+ assert kwargs["no_speech_threshold"] == 0.9+ assert kwargs["log_prob_threshold"] == -2.0++ def test_confidence_thresholds_garbage_falls_back(self):+ kwargs = build_local_transcribe_kwargs(+ {"local": {"no_speech_prob_threshold": "nope", "logprob_threshold": None}}+ )+ assert kwargs["no_speech_threshold"] == _NO_SPEECH_PROB_THRESHOLD_DEFAULT+ assert kwargs["log_prob_threshold"] == _LOGPROB_THRESHOLD_DEFAULT+def test_language_and_prompt_resolved(self, monkeypatch):monkeypatch.delenv("HERMES_LOCAL_STT_LANGUAGE", raising=False)cfg = {"language": "en", "local": {"initial_prompt": "Hermes glossary"}}@@ -99,6 +121,8 @@ class TestTranscribeLocalWiring:assert captured["vad_filter"] is Trueassert captured["vad_parameters"] == {"min_silence_duration_ms": 500}assert captured["condition_on_previous_text"] is False+ assert captured["no_speech_threshold"] == _NO_SPEECH_PROB_THRESHOLD_DEFAULT+ assert captured["log_prob_threshold"] == _LOGPROB_THRESHOLD_DEFAULTdef test_hallucinated_segments_filtered_from_transcript(self, monkeypatch):diff --git a/tools/transcription_tools.py b/tools/transcription_tools.pyindex cb1de1b0d59..4c03fa8235f 100644--- a/tools/transcription_tools.py+++ b/tools/transcription_tools.py@@ -1541,6 +1541,19 @@ def build_local_transcribe_kwargs(stt_config: Optional[Dict[str, Any]] = None) -else:kwargs["vad_filter"] = False+ # Push the confidence gate down into faster-whisper itself. Without this the+ # library's own internal defaults (no_speech_threshold=0.6, log_prob_+ # threshold=-1.0) drop low-confidence segments BEFORE they reach our+ # _is_hallucinated_segment post-filter, so the ``stt.local`` threshold knobs+ # were dead for that first gate. Non-English speech decodes at a lower+ # avg_logprob, so the English-tuned defaults silently discard whole+ # utterances. Mapping the same config values through keeps both gates in+ # sync and makes the knobs actually usable. Defaults are unchanged, so+ # behavior is identical unless a user tunes them.+ no_speech_threshold, log_prob_threshold = _confidence_thresholds(local_cfg)+ kwargs["no_speech_threshold"] = no_speech_threshold+ kwargs["log_prob_threshold"] = log_prob_threshold+forced_lang = _resolve_stt_language("local", stt_config)if forced_lang:kwargs["language"] = forced_lang