Skip to content

Commit 5dfbdf7

Browse files
extrangeMahmoudAshraf97
extrange
authored andcommitted
change language_detection_threshold type to float
Cannot be an optional parameter
1 parent 9e657b4 commit 5dfbdf7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

faster_whisper/transcribe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ def transcribe(
744744
clip_timestamps: Union[str, List[float]] = "0",
745745
hallucination_silence_threshold: Optional[float] = None,
746746
hotwords: Optional[str] = None,
747-
language_detection_threshold: Optional[float] = 0.5,
747+
language_detection_threshold: float = 0.5,
748748
language_detection_segments: int = 1,
749749
) -> Tuple[Iterable[Segment], TranscriptionInfo]:
750750
"""Transcribes an input file.

tests/test_transcribe.py

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33

44
import numpy as np
5+
import pytest
56

67
from faster_whisper import BatchedInferencePipeline, WhisperModel, decode_audio
78

@@ -269,3 +270,9 @@ def test_monotonic_timestamps(physcisworks_path):
269270
assert word.start <= word.end
270271
assert word.end <= segments[i].end
271272
assert segments[-1].end <= info.duration
273+
274+
275+
def test_language_detection_threshold_none_raises_error(jfk_path):
276+
model = WhisperModel("tiny")
277+
with pytest.raises(TypeError):
278+
model.transcribe(jfk_path, language_detection_threshold=None) # type: ignore

0 commit comments

Comments
 (0)