subtitlecore package

Submodules

subtitlecore.constants module

subtitlecore.constants.SPACY_PKG

key is language abbreviation, and value is spacy package name

Type:

dict

subtitlecore.entry module

subtitlecore.sentencizer module

class subtitlecore.sentencizer.Sentencizer(lang)

Bases: object

Sentenize a subtitle line object using spacy nlp

Parameters:

lang (srt) – language of text

mark(line)

Parse text into sentences

Parameters:

line (str) – A piece of text

Returns:

A list of sentences

Return type:

list

subtitlecore.subtitle module

class subtitlecore.subtitle.Subtitle(srtfile, lang='en')

Bases: object

Manipulate subtitle content

Parameters:
  • srtfile (str) – subtitle file name

  • lang (str, optional) – subtitle language. Defaults to en

file

subtitle file full path

Type:

str

fname

subtitle file name

Type:

str

fext

subtitle file extension, e.g, srt, vtt

Type:

str

lang

subtitle language, e.g, en, es

Type:

str

content

subtitle content stored as time-based sentences in a list

Type:

list

plaintext()

Get plain text from substitle, without time stamp involved

Returns:

Plain text of subtitle file without time stamp information

Return type:

str

sentenize()

Sentenize each subtitle line within time stamp

Returns:

A list of dict object, which has keys: start, end, text, identifier, sens

Return type:

list

Module contents

subtitlecore Package

This module demostrates the usage of package subtitlecore.