pip3 install --verbose subtitlecore
python -m spacy download en_core_web_trf
python -m spacy download es_dep_news_trf
Please refer to api docs.
- 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
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)
git clone https://github.com/qishe-nlp/subtitlecore.git
Install poetry
poetry update
poetry run pytest -rP
which run tests under tests/*
poetry run subtitlecore_content --help
poetry run subtitlecore_parse2sens --help
poetry run subtitlecore_parse2text --help
poetry shell
cd apidocs
sphinx-apidoc -f -o source ../subtitlecore
make html
python -m http.server -d build/html
cp -rf apidocs/build/html/* docs/
- Change
version
inpyproject.toml
andsubtitlecore/__init__.py
- Build python package by
poetry build
- Set pypi test environment variables in poetry, refer to poetry doc
- Publish to pypi test by
poetry publish -r test
- Github action build and publish package to test pypi repo
git tag [x.x.x]
git push origin master
- Manually publish to pypi repo through github action