Open-source X Spaces transcription.

Star

43 lines · 1.1 KB

python
1from __future__ import annotations
2
3import sys
4from pathlib import Path
5
6sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
7
8from space_tape.render import format_ts, transcript_md
9
10
11def test_format_ts() -> None:
12 assert format_ts(5.004) == "00:00:05"
13 assert format_ts(96) == "00:01:36"
14 assert format_ts(3723) == "01:02:03"
15
16
17def test_transcript_keeps_x_url() -> None:
18 cues = [
19 {
20 "start": 5.004,
21 "end": 7.003,
22 "speaker": "notpierce69",
23 "text": "Hey DJ, I don't think anyone else is gonna show up.",
24 }
25 ]
26 md = transcript_md(
27 cues,
28 source_url="https://x.com/i/spaces/1pKdRDlVbRrJW",
29 posted_url="https://x.com/notpierce69/status/2100117423017906497",
30 title="Explorer Initiation",
31 speakers=["notpierce69", "djay44444"],
32 )
33 assert "https://x.com/i/spaces/1pKdRDlVbRrJW" in md
34 assert "https://x.com/notpierce69/status/2100117423017906497" in md
35 assert "**[00:00:05] @notpierce69**" in md
36 assert "@djay44444" in md
37
38
39if __name__ == "__main__":
40 test_format_ts()
41 test_transcript_keeps_x_url()
42 print("ok")