|
|
@@ -9,6 +9,7 @@ stays lazy inside the constructor.
|
|
|
|
|
|
import logging
|
|
|
import math
|
|
|
+import re
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
@@ -131,11 +132,16 @@ class PyWhisperCppTranscriber:
|
|
|
no_speech_thold=self.no_speech_prob_max,
|
|
|
)
|
|
|
|
|
|
- # Collect accepted segments and track their confidence
|
|
|
+ # Collect accepted segments and track their confidence. Segments are
|
|
|
+ # joined with a space and whitespace is collapsed: whisper.cpp often
|
|
|
+ # omits the leading spaces faster-whisper carries, and bare
|
|
|
+ # concatenation glues words together ("mostmatter").
|
|
|
accepted_segments = [
|
|
|
seg for seg in segments if accept_segment(seg, self.avg_logprob_min)
|
|
|
]
|
|
|
- text = "".join(seg.text for seg in accepted_segments).strip()
|
|
|
+ text = re.sub(
|
|
|
+ r"\s+", " ", " ".join(seg.text for seg in accepted_segments)
|
|
|
+ ).strip()
|
|
|
|
|
|
# Sticky pinning logic (only when auto-detecting with sticky strategy)
|
|
|
# pywhispercpp returns numpy scalars; coerce so no np.float32 leaks into
|