29 lines
582 B
Python
29 lines
582 B
Python
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
|
|
from backend.local_whisper import build_vtt_from_segments
|
|
|
|
|
|
def test_build_vtt_from_whisper_segments():
|
|
segments = [
|
|
{"start": 0.0, "end": 2.5, "text": "Hello world."},
|
|
{"start": 2.5, "end": 5.0, "text": "This is a test."},
|
|
]
|
|
|
|
assert build_vtt_from_segments(segments) == """WEBVTT
|
|
|
|
1
|
|
00:00:00.000 --> 00:00:02.500
|
|
Hello world.
|
|
|
|
2
|
|
00:00:02.500 --> 00:00:05.000
|
|
This is a test.
|
|
"""
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_build_vtt_from_whisper_segments()
|