From 5dfbdf7c97822fafa379e274fcf90a39c9fbb6e6 Mon Sep 17 00:00:00 2001 From: extrange Date: Wed, 4 Dec 2024 09:13:53 +0000 Subject: [PATCH] change language_detection_threshold type to float Cannot be an optional parameter --- faster_whisper/transcribe.py | 2 +- tests/test_transcribe.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/faster_whisper/transcribe.py b/faster_whisper/transcribe.py index d270bdf4..636c6fe2 100644 --- a/faster_whisper/transcribe.py +++ b/faster_whisper/transcribe.py @@ -744,7 +744,7 @@ def transcribe( clip_timestamps: Union[str, List[float]] = "0", hallucination_silence_threshold: Optional[float] = None, hotwords: Optional[str] = None, - language_detection_threshold: Optional[float] = 0.5, + language_detection_threshold: float = 0.5, language_detection_segments: int = 1, ) -> Tuple[Iterable[Segment], TranscriptionInfo]: """Transcribes an input file. diff --git a/tests/test_transcribe.py b/tests/test_transcribe.py index 6b76fe9c..d36d85f3 100644 --- a/tests/test_transcribe.py +++ b/tests/test_transcribe.py @@ -2,6 +2,7 @@ import os import numpy as np +import pytest from faster_whisper import BatchedInferencePipeline, WhisperModel, decode_audio @@ -269,3 +270,9 @@ def test_monotonic_timestamps(physcisworks_path): assert word.start <= word.end assert word.end <= segments[i].end assert segments[-1].end <= info.duration + + +def test_language_detection_threshold_none_raises_error(jfk_path): + model = WhisperModel("tiny") + with pytest.raises(TypeError): + model.transcribe(jfk_path, language_detection_threshold=None) # type: ignore