feat: align subtitles from first 10 seconds audio
This commit is contained in:
1 parent
93e06ca40a
commit
5228765473
11 files changed
+248
-22
No files matched your search
@@ -3,7 +3,7 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from backend.subtitle_tools import build_vtt, clean_english_subtitle
|
||||
from backend.subtitle_tools import build_vtt, clean_english_subtitle, shift_cues
|
||||
|
||||
|
||||
def test_clean_english_subtitle_removes_empty_and_duplicate_cues():
|
||||
@@ -43,6 +43,21 @@ def test_build_vtt_outputs_numbered_blocks():
|
||||
assert result == "WEBVTT\n\n1\n00:00:00.872 --> 00:00:04.959\nMy first job as an investor\n"
|
||||
|
||||
|
||||
def test_shift_cues_moves_time_without_touching_text():
|
||||
shifted = shift_cues([
|
||||
{
|
||||
"start": "00:00:00.200",
|
||||
"end": "00:00:01.200",
|
||||
"text": "First line",
|
||||
}
|
||||
], -0.5)
|
||||
|
||||
assert shifted[0].start == "00:00:00.000"
|
||||
assert shifted[0].end == "00:00:00.700"
|
||||
assert shifted[0].text == "First line"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_clean_english_subtitle_removes_empty_and_duplicate_cues()
|
||||
test_build_vtt_outputs_numbered_blocks()
|
||||
test_shift_cues_moves_time_without_touching_text()
|
||||
Reference in new issue
Block a user