Skip to content

Instantly share code, notes, and snippets.

@huozhong-in
huozhong-in / srt_to_txt.py
Created January 9, 2022 02:29 — forked from ndunn219/srt_to_txt.py
Simple Python Script for Extracting Text from an SRT File
"""
Creates readable text file from SRT file.
"""
import re, sys
def is_time_stamp(l):
if l[:2].isnumeric() and l[2] == ':':
return True
return False
@huozhong-in
huozhong-in / vtt2text.py
Created January 8, 2022 15:58 — forked from glasslion/vtt2text.py
This script convert youtube subtitle file(vtt) to plain text.
"""
Convert YouTube subtitles(vtt) to human readable text.
Download only subtitles from YouTube with youtube-dl:
youtube-dl --skip-download --convert-subs vtt <video_url>
Note that default subtitle format provided by YouTube is ass, which is hard
to process with simple regex. Luckily youtube-dl can convert ass to vtt, which
is easier to process.
@huozhong-in
huozhong-in / reverse.py
Created September 21, 2018 08:20
reverse a string
' '.join(map(lambda x: x[::-1], 'I have a dream'.split(' ')))