Skip to content

Commit 5f251c9

Browse files
author
extrange
committed
change language_detection_threshold type to float
Cannot be an optional parameter
1 parent 8327d8c commit 5f251c9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

faster_whisper/transcribe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def transcribe(
731731
clip_timestamps: Union[str, List[float]] = "0",
732732
hallucination_silence_threshold: Optional[float] = None,
733733
hotwords: Optional[str] = None,
734-
language_detection_threshold: Optional[float] = 0.5,
734+
language_detection_threshold: float = 0.5,
735735
language_detection_segments: int = 1,
736736
) -> Tuple[Iterable[Segment], TranscriptionInfo]:
737737
"""Transcribes an input file.

tests/test_transcribe.py

Lines changed: 7 additions & 0 deletions
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)