continue fixing

This commit is contained in:
2026-08-18 21:57:25 +08:00
parent aa8baab7c0
commit 3f86e8f44e
6 changed files with 202 additions and 15 deletions

View File

@@ -9,6 +9,7 @@ from .audio_metrics import (
analyze_samples,
decode_audio_mono,
refine_sentence_end_ms,
refine_sentence_start_ms,
)
from .config import Settings
from .generate_boundaries import ALGORITHM_VERSION, make_entry
@@ -116,7 +117,8 @@ def document_from_transcript(
previous_end = 0
sentence_segments = split_sentences_at_punctuation(transcript.segments)
for index, sentence_segment in enumerate(sentence_segments):
start_ms = max(previous_end, int(round(sentence_segment.start_seconds * 1000)))
raw_start_ms = int(round(sentence_segment.start_seconds * 1000))
start_ms = max(previous_end, raw_start_ms)
raw_end_ms = int(round(sentence_segment.end_seconds * 1000))
end_ms = min(
duration_ms,
@@ -130,6 +132,14 @@ def document_from_transcript(
end_ms = refine_sentence_end_ms(
samples, sample_rate, raw_end_ms=raw_end_ms, padded_end_ms=end_ms
)
refined_start_ms = refine_sentence_start_ms(
samples,
sample_rate,
raw_start_ms=raw_start_ms,
previous_end_ms=previous_end,
)
if previous_end <= refined_start_ms and end_ms - refined_start_ms >= 100:
start_ms = refined_start_ms
if not sentence_segment.text.strip() or end_ms <= start_ms:
continue
start_sample = max(0, int(start_ms / 1000 * sample_rate))