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

Fix neg_threshold #1191

Merged
merged 3 commits into from
Dec 29, 2024
Merged
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
6 changes: 4 additions & 2 deletions faster_whisper/vad.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class VadOptions:
"""

threshold: float = 0.5
neg_threshold: float = threshold - 0.15
neg_threshold: float = None
min_speech_duration_ms: int = 0
max_speech_duration_s: float = float("inf")
min_silence_duration_ms: int = 2000
Expand Down Expand Up @@ -63,6 +63,7 @@ def get_speech_timestamps(
vad_options = VadOptions(**kwargs)

threshold = vad_options.threshold
neg_threshold = vad_options.neg_threshold
min_speech_duration_ms = vad_options.min_speech_duration_ms
max_speech_duration_s = vad_options.max_speech_duration_s
min_silence_duration_ms = vad_options.min_silence_duration_ms
Expand Down Expand Up @@ -90,7 +91,8 @@ def get_speech_timestamps(
triggered = False
speeches = []
current_speech = {}
neg_threshold = vad_options.neg_threshold
if neg_threshold is None:
neg_threshold = max(threshold - 0.15, 0.01)

# to save potential segment end (and tolerate some silence)
temp_end = 0
Expand Down
Loading