Project

supertitle

0.0
No commit activity in last 3 years
No release in over 3 years
Methods for converting between subtitles/captions/transcripts formats
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 5.0
>= 0
~> 10.0
 Project Readme

Supertitle

A little gem to help deal with converting between to & from various subtitle and transcript formats. Right now it only handles conversion of SRT files to a text transcript that's more appropriate for being read by humans.

CLI

The CLI takes four arguments:

Usage: supertitle input_file input_format output_file output_format

Example:
  $ supertitle scna.srt srt scna-script.txt transcript

This will read the SRT input file and write a human-readable transcript to scna-script.txt.

API

Reading

First, parse some content into "supertitles", the arbitrary object model of this gem:

srt = File.read("test/fixtures/scna.srt")
supertitles = Supertitle.parse(srt, :srt)

Supported input formats:

Object model

The Supertitle.read method will return an array of Supertitle::Line objects, each providing start, stop, and text attributes. start and stop are millisecond offsets, relative to the start of the subtitles or transcript. text will strip and join any multi-line subtitles into a single line, separated by a single space.

Writing

To write out those supertitles into a supported string format:

transcript = Supertitle.write(supertitles, :transcript) #=> a multi-line string

Supported output formats:

  • :transcript - a human-readable custom transcript format ([mm:ss] text…)