Generate SRT files with Google Cloud Services

tl;dr: I need to generate my own SRT files for my videos because Facebook Creator Studio makes me angry.

Long: Backstory

Requirements

  • python
  • ffmpeg
  • Google Cloud API Key with the Speech to Text product enabled. (instructions)

More details for installation and usage in the script below.

Notes

Default GCS only works for videos no longer than 60 seconds, and the script will only send the first 60 seconds of video to accommodate this. Modifications are required to use GCS for longer videos.1

I find the video transcription model more accurate than the default, but video is a premium model if that matters to you. I still need to make corrections, but far fewer than Facebook's auto-captioning feature.

For bin length, I've set it to a default of 3 seconds with a line break of 37 characters.2

Loading...
1 00:00:05,100 --> 00:00:07,500 Big Bang Theory thank you. So especially in that

Footnotes

  1. See https://towardsdatascience.com/how-to-use-google-speech-to-text-api-to-transcribe-long-audio-files-1c886f4eb3e9

  2. 3 seconds seems to come up a bit, and the first subtitle style-guide I found is from the BBC and I saw 37 characters on there because of teletext. For online it's based on percentage of screen-width and at that point I realised close enough is good enough. Got better numbers? Let me know.

Published December 4, 2020