Skip to content

Commit 11fd8ab

Browse files
authored
Fix neg_threshold (#1191)
1 parent 9516429 commit 11fd8ab

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

faster_whisper/vad.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class VadOptions:
3535
"""
3636

3737
threshold: float = 0.5
38-
neg_threshold: float = threshold - 0.15
38+
neg_threshold: float = None
3939
min_speech_duration_ms: int = 0
4040
max_speech_duration_s: float = float("inf")
4141
min_silence_duration_ms: int = 2000
@@ -63,6 +63,7 @@ def get_speech_timestamps(
6363
vad_options = VadOptions(**kwargs)
6464

6565
threshold = vad_options.threshold
66+
neg_threshold = vad_options.neg_threshold
6667
min_speech_duration_ms = vad_options.min_speech_duration_ms
6768
max_speech_duration_s = vad_options.max_speech_duration_s
6869
min_silence_duration_ms = vad_options.min_silence_duration_ms
@@ -90,7 +91,8 @@ def get_speech_timestamps(
9091
triggered = False
9192
speeches = []
9293
current_speech = {}
93-
neg_threshold = vad_options.neg_threshold
94+
if neg_threshold is None:
95+
neg_threshold = max(threshold - 0.15, 0.01)
9496

9597
# to save potential segment end (and tolerate some silence)
9698
temp_end = 0

0 commit comments

Comments
 (0)