Spaces:
Running
Running
Download test/services/test_caption_timecodes.py from kodnuke/youtube-bot: direct link, hf CLI and curl.
- Browser
- Download file 842 Bytes
-
https://huggingface.co/spaces/kodnuke/youtube-bot/resolve/main/test/services/test_caption_timecodes.py
- Command line
-
hf download hf://spaces/kodnuke/youtube-bot/test/services/test_caption_timecodes.py
-
curl -L -o test_caption_timecodes.py https://huggingface.co/spaces/kodnuke/youtube-bot/resolve/main/test/services/test_caption_timecodes.py
842 Bytes
| """Native caption publication and final rendering must retain spoken timecodes.""" | |
| import pytest | |
| from edge_tts import SubMaker | |
| from app.services import subtitle, voice | |
| CAPTIONS = [ | |
| "Jump to the recording.", | |
| "Jump to 00:01:23,456 in the recording.", | |
| "Show 00:01:23,456 --> 00:01:25,456 in the log.", | |
| ] | |
| def test_speech_caption_publication_preserves_timecodes(tmp_path, text): | |
| maker = SubMaker() | |
| maker.feed({ | |
| "type": "SentenceBoundary", "offset": 0, | |
| "duration": 8000000, "text": text, | |
| }) | |
| destination = tmp_path / "speech.srt" | |
| voice.create_subtitle(maker, text, str(destination), word_level=True) | |
| assert destination.is_file() | |
| assert subtitle.file_to_subtitles(str(destination)) == [ | |
| (1, "00:00:00,000 --> 00:00:00,800", text) | |
| ] | |