Skip to content

Commit

Permalink
adds conversion from srt to webvtt
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed May 10, 2023
1 parent ef72812 commit 6984df2
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ keywords = ["template-python-cmd"]
license = { text = "BSD 3-Clause License" }
classifiers = ["Programming Language :: Python :: 3"]
dependencies = [
"download",
"srtranslator",
"gTTS",
"playaudio",
"PyQt6==6.3.1"
"download==0.3.5",
"srtranslator==0.2.6",
"gTTS==2.3.2",
"playaudio==1.0.5",
"PyQt6==6.3.1",
"webvtt-py==0.4.6"
]

dynamic = ["version"]
Expand Down
122 changes: 122 additions & 0 deletions tests/test.srt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
1
00:00:00,000 --> 00:00:07,000
I don't have to remind many Americans that the
Center for Disease Control was the one that said
you should use DDT in your homes.

2
00:00:07,000 --> 00:00:11,000
Used right, it is absolutely harmless to humans
and animals.

3
00:00:11,000 --> 00:00:15,000
Remember the name, DDT.

4
00:00:15,000 --> 00:00:22,000
A scientific panel today reported that pesticides
may indeed represent a grave threat to mankind.

5
00:00:22,000 --> 00:00:26,000
Remember the swine flu scare of 1976?

6
00:00:26,000 --> 00:00:30,000
That was the year the U.S. government told us all
that swine flu could turn out to be a killer,

7
00:00:30,000 --> 00:00:38,000
and Washington decided that every man, woman, and
child in the nation should get a shot to prevent a
nationwide outbreak, a pandemic.

8
00:00:38,000 --> 00:00:41,000
Well, 46 million of us obediently took the shot.

9
00:00:41,000 --> 00:00:49,000
Did anyone ever come to you and say there's the
possibility of neurological damage if you get into
a mass immunization program?

10
00:00:49,000 --> 00:00:50,000
No.

11
00:00:50,000 --> 00:00:51,000
No one ever did?

12
00:00:51,000 --> 00:00:52,000
No.

13
00:00:52,000 --> 00:00:59,000
I can't believe that they would say that they did
not know that there were neurological illnesses
associated with influenza vaccination.

14
00:00:59,000 --> 00:01:02,000
That simply is not true. We did know that.

15
00:01:02,000 --> 00:01:06,000
And he's lying.

16
00:01:06,000 --> 00:01:10,000
I guess you would have to make that assumption.

17
00:01:10,000 --> 00:01:17,000
Then why does this report from your own agency
list neurological complications as a possibility?

18
00:01:17,000 --> 00:01:21,000
You didn't feel it was necessary to tell the
American people that information.

19
00:01:21,000 --> 00:01:26,000
Dr. Sensor's CDC also helped create the
advertising to get the public to take the shot.

20
00:01:26,000 --> 00:01:29,000
The vaccines are safe, so roll up your sleeve.

21
00:01:29,000 --> 00:01:35,000
And now Americans are claiming damages from Uncle
Sam amounting to three and a half billion dollars.

22
00:01:35,000 --> 00:01:41,000
By far the greatest number of the claims,
two-thirds of them, are for neurological damage or
even death.

23
00:01:41,000 --> 00:01:51,000
There are serious concerns tonight about how well
the CDC controls dangerous germs at its own labs
after yet another safety lapse.

24
00:01:51,000 --> 00:01:58,000
For the third time in a month, the CDC
acknowledged deadly pathogens were handled
incorrectly in government labs.

25
00:01:58,000 --> 00:02:17,000
That CDC is the CDC that allegedly is looking out
for your public health.

28 changes: 28 additions & 0 deletions tests/test_srt_to_webvtt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Unit test file.
"""
import os
import tempfile
import unittest

import webvtt

HERE = os.path.dirname(os.path.abspath(__file__))


TEST_SRT = os.path.join(HERE, "test.srt")


class SrtToWebvtt(unittest.TestCase):
"""Main tester class."""

def test_translate(self) -> None:
"""Test command line interface (CLI)."""
# translator = DeeplTranslator() # free version
with tempfile.TemporaryDirectory() as tmpdirname:
out_file = os.path.join(tmpdirname, "out.vtt")
webvtt.from_srt(TEST_SRT).save(out_file)


if __name__ == "__main__":
unittest.main()

0 comments on commit 6984df2

Please sign in to comment.