Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change language_detection_threshold type to float #1188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion faster_whisper/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions tests/test_transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os

import numpy as np
import pytest

from faster_whisper import BatchedInferencePipeline, WhisperModel, decode_audio

Expand Down Expand Up @@ -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
Loading