|
@@ -37,6 +37,7 @@ class Transcriber:
|
|
|
language: str | None,
|
|
language: str | None,
|
|
|
beam_size: int = 1,
|
|
beam_size: int = 1,
|
|
|
vad_filter: bool = False,
|
|
vad_filter: bool = False,
|
|
|
|
|
+ cpu_threads: int = 0,
|
|
|
no_speech_prob_max: float = 0.6,
|
|
no_speech_prob_max: float = 0.6,
|
|
|
avg_logprob_min: float = -1.0,
|
|
avg_logprob_min: float = -1.0,
|
|
|
):
|
|
):
|
|
@@ -49,6 +50,9 @@ class Transcriber:
|
|
|
language: Language code (e.g., "en", "es") or None for auto-detect.
|
|
language: Language code (e.g., "en", "es") or None for auto-detect.
|
|
|
beam_size: Beam search width (1 = greedy, fastest).
|
|
beam_size: Beam search width (1 = greedy, fastest).
|
|
|
vad_filter: Enable Whisper's built-in VAD (we already run webrtcvad).
|
|
vad_filter: Enable Whisper's built-in VAD (we already run webrtcvad).
|
|
|
|
|
+ cpu_threads: CPU threads for inference (0 = CTranslate2's automatic
|
|
|
|
|
+ choice). Setting this to the physical core count is typically
|
|
|
|
|
+ faster than the automatic choice on many-core CPUs.
|
|
|
no_speech_prob_max: Drop segments Whisper scores as non-speech above this.
|
|
no_speech_prob_max: Drop segments Whisper scores as non-speech above this.
|
|
|
avg_logprob_min: Drop segments with average log-probability below this.
|
|
avg_logprob_min: Drop segments with average log-probability below this.
|
|
|
"""
|
|
"""
|
|
@@ -57,6 +61,7 @@ class Transcriber:
|
|
|
self.compute_type = compute_type
|
|
self.compute_type = compute_type
|
|
|
self.beam_size = beam_size
|
|
self.beam_size = beam_size
|
|
|
self.vad_filter = vad_filter
|
|
self.vad_filter = vad_filter
|
|
|
|
|
+ self.cpu_threads = cpu_threads
|
|
|
self.no_speech_prob_max = no_speech_prob_max
|
|
self.no_speech_prob_max = no_speech_prob_max
|
|
|
self.avg_logprob_min = avg_logprob_min
|
|
self.avg_logprob_min = avg_logprob_min
|
|
|
|
|
|
|
@@ -76,7 +81,12 @@ class Transcriber:
|
|
|
self.device = "cpu"
|
|
self.device = "cpu"
|
|
|
self.compute_type = "int8"
|
|
self.compute_type = "int8"
|
|
|
|
|
|
|
|
- self.model = WhisperModel(model, device=self.device, compute_type=self.compute_type)
|
|
|
|
|
|
|
+ self.model = WhisperModel(
|
|
|
|
|
+ model,
|
|
|
|
|
+ device=self.device,
|
|
|
|
|
+ compute_type=self.compute_type,
|
|
|
|
|
+ cpu_threads=self.cpu_threads,
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
def transcribe(self, audio: np.ndarray) -> TranscriptResult:
|
|
def transcribe(self, audio: np.ndarray) -> TranscriptResult:
|
|
|
"""Transcribe audio to text.
|
|
"""Transcribe audio to text.
|
|
@@ -93,6 +103,7 @@ class Transcriber:
|
|
|
beam_size=self.beam_size,
|
|
beam_size=self.beam_size,
|
|
|
vad_filter=self.vad_filter,
|
|
vad_filter=self.vad_filter,
|
|
|
condition_on_previous_text=False,
|
|
condition_on_previous_text=False,
|
|
|
|
|
+ without_timestamps=True,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
# Join the segments Whisper is confident about
|
|
# Join the segments Whisper is confident about
|