|
@@ -1,6 +1,7 @@
|
|
|
"""Transcription using Faster-Whisper."""
|
|
"""Transcription using Faster-Whisper."""
|
|
|
|
|
|
|
|
import logging
|
|
import logging
|
|
|
|
|
+import re
|
|
|
from dataclasses import dataclass
|
|
from dataclasses import dataclass
|
|
|
from typing import Protocol
|
|
from typing import Protocol
|
|
|
|
|
|
|
@@ -130,13 +131,18 @@ class Transcriber:
|
|
|
without_timestamps=True,
|
|
without_timestamps=True,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- # Collect accepted segments and track their confidence
|
|
|
|
|
|
|
+ # Collect accepted segments and track their confidence. Segments are
|
|
|
|
|
+ # joined with a space and whitespace is collapsed: faster-whisper
|
|
|
|
|
+ # usually carries leading spaces but whisper.cpp often does not, and
|
|
|
|
|
+ # bare concatenation glues words together ("mostmatter").
|
|
|
accepted_segments = [
|
|
accepted_segments = [
|
|
|
seg
|
|
seg
|
|
|
for seg in segments
|
|
for seg in segments
|
|
|
if accept_segment(seg, self.no_speech_prob_max, self.avg_logprob_min)
|
|
if accept_segment(seg, self.no_speech_prob_max, 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)
|
|
# Sticky pinning logic (only when auto-detecting with sticky strategy)
|
|
|
language_probability_to_report = info.language_probability
|
|
language_probability_to_report = info.language_probability
|