SrtToTextgrid
Python script to convert .srt subtitle files to Praat .textgrid files
Install / Use
/learn @rctatman/SrtToTextgridREADME
SrtToTextgrid
Python script to convert .srt subtitle files to Praat .textgrid files. It's general enough that it may work on other types of files like .sub or .sbv, but please be cautious.
This was originally written in Python 2.7.3, but it also works in Python 3.
Example file is a .srt file based on a Youtube transcription of Katie Bell's keynote at a 2015 meeting of the New Zealand Python User Group. Url: https://www.youtube.com/watch?v=dj9RR4BSqvM It's almost an hour, so the audio is really too big to upload.
Usage
Before you run the main SRT-to-TextGrid converter, you may need to clean up the SRT file. Sometimes the SRT may not have dedicated intervals for silences. Praat needs those to be explicit. The example SRT file input-SRT-file.srt has this problem. To create those silent intervals, run the following command:
python3 SilentIntervalSRT.py $input-SRT-file.srt $output-SRT-file.srt
Replace the variables $input-SRT-file.srtand$output-SRT-file.srt` with your files.
You can then run the main script that will convert the SRT into a TextGrid. Try experimenting with either the original SRT or the cleaned up SRT:
python3 SrtToTextgrid.py $output-SRT-file.srt $output-TextGrid-file.TextGrid
python3 SrtToTextgrid.py $input-SRT-file.srt $output-TextGrid-file.TextGrid
Replace the variables $input-SRT-file.srt, $output-SRT-file.srt, and $output-TextGrid-file.TextGrid with your files.
Note: The older version of SrtToTextgrid.py' required no milliseconds in the SRT, like in the SRT file keynote-katie-bell-how-python-works-as-a-teaching-language_en.srt`. But the current version requires milliseconds in the SRT. This can be fixed in the future.
Related Skills
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
