Skip to main content

Parse srt file content into well-formed structures

Project description

Installation from pip3

pip3 install --verbose subtitlecore
python -m spacy download en_core_web_trf
python -m spacy download es_dep_news_trf

Usage

Please refer to api docs.

Excutable usage

  • Get subtitle content
subtitlecore_content --srtfile test.srt --lang en
  • Parse srtfile into sentences with timestamp
subtitlecore_parse2sens --srtfile test.srt --lang en
  • Parse srtfile into plain text
subtitlecore_parse2text --srtfile test.srt --lang en

Package usage

from subtitlecore import Subtitle

def get_subtitle_content(srtfile, lang):
  st = Subtitle(srtfile, lang)
  for line_info in st.content:
    print(line_info)

def parse2sens(srtfile, lang):
  st = Subtitle(srtfile, lang)
  content_sens = st.sentenize()
  for e in content_sens:
    print(e)

def parse2text(srtfile, lang):
  st = Subtitle(srtfile, lang)
  text = st.plaintext()
  print(text)

Development

Clone project

git clone https://github.com/qishe-nlp/subtitlecore.git

Install poetry

Install dependencies

poetry update

Test

poetry run pytest -rP

which run tests under tests/*

Execute

poetry run subtitlecore_content --help
poetry run subtitlecore_parse2sens --help
poetry run subtitlecore_parse2text --help

Create sphinx docs

poetry shell
cd apidocs
sphinx-apidoc -f -o source ../subtitlecore
make html
python -m http.server -d build/html

Host docs on github pages

cp -rf apidocs/build/html/* docs/

Build

  • Change version in pyproject.toml and subtitlecore/__init__.py
  • Build python package by poetry build

Git commit and push

Publish from local dev env

  • Set pypi test environment variables in poetry, refer to poetry doc
  • Publish to pypi test by poetry publish -r test

Publish through CI

git tag [x.x.x]
git push origin master

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subtitlecore-0.1.15.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subtitlecore-0.1.15-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file subtitlecore-0.1.15.tar.gz.

File metadata

  • Download URL: subtitlecore-0.1.15.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.0 Linux/6.5.0-1025-azure

File hashes

Hashes for subtitlecore-0.1.15.tar.gz
Algorithm Hash digest
SHA256 3f465f4d57ccca9477c3a1749ed137c06197850d0ae9e30cb68ee3f3d01f5d37
MD5 ca5c15e55cf0509975608dabcb3cbba4
BLAKE2b-256 e81515236565702c8851c7c8eccc5f91188d0b34c7be372ddeb7e27d2d8480db

See more details on using hashes here.

File details

Details for the file subtitlecore-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: subtitlecore-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.0 Linux/6.5.0-1025-azure

File hashes

Hashes for subtitlecore-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 5b6a6c6e8c42344914c47f579d20f2a5aecb281003178b3993c43f797a86763d
MD5 38bd738ed8c76848706a8d0baeee50b6
BLAKE2b-256 311663c45b8f247681ba78b9376bc89421887e3cb3b5e12e4ab83aac66602c5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page