fixed a bug
This commit is contained in:
@@ -5,6 +5,7 @@ from sentence_api.processing import (
|
||||
VideoProcessor,
|
||||
document_from_transcript,
|
||||
find_sentence_gaps,
|
||||
_plan_gap_chunks,
|
||||
split_sentence_text,
|
||||
)
|
||||
from sentence_api.models import SentenceBoundary, SentenceBoundaryDocument
|
||||
@@ -417,6 +418,22 @@ def test_find_sentence_gaps_ignores_short_pauses():
|
||||
assert find_sentence_gaps(document) == []
|
||||
|
||||
|
||||
def test_plan_gap_chunks_splits_long_gap_at_silence():
|
||||
samples = np.concatenate(
|
||||
[_speech(14.0), _silence(0.6), _speech(16.0)]
|
||||
).astype(np.float32)
|
||||
chunks = _plan_gap_chunks(samples, SAMPLE_RATE, int(samples.size / SAMPLE_RATE * 1000))
|
||||
|
||||
assert len(chunks) == 2
|
||||
first_start, first_end = chunks[0]
|
||||
second_start, second_end = chunks[1]
|
||||
assert first_start == 0
|
||||
assert 13_000 <= first_end <= 17_000
|
||||
assert second_start == first_end
|
||||
assert second_end == int(samples.size / SAMPLE_RATE * 1000)
|
||||
assert all(end - start <= 20_000 for start, end in chunks)
|
||||
|
||||
|
||||
def test_repair_gaps_inserts_transcribed_sentences_and_keeps_existing(tmp_path, monkeypatch):
|
||||
from dataclasses import replace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user