gitre / test_srt.py
kjbytes's picture
feat: add SRT subtitle generation and improve security
cfff3e1
Raw
History Blame Contribute Delete
532 Bytes
"""Runnable check for SRT cue timing: python test_srt.py"""
import os
os.environ.setdefault("API_KEY", "test")
os.environ.setdefault("OUT_DIR", "/tmp/audio-test")
from app import srt
out = srt("Hi there. How are you?", 10.0)
assert out.startswith("1\n00:00:00,000 --> "), out
assert "--> 00:00:10,000" in out, out # last cue ends at the audio duration
assert out.count("-->") == 2, out
assert "Hi there." in out and "How are you?" in out
assert srt("", 5.0) == ""
assert srt("one sentence", 3.0).count("-->") == 1
print("ok")