SUBT-AI-TLES
A simple wrapper around your LLM for movie subtitles translation that makes
What does it do?
- Parses the .srt
- Requests individual lines to be translated by the LLM
- Puts it all back together, making sure the sentences match the srt structure/timings
- Caches results - which makes rerunning failed runs a possibility
Provided adapters
So far OpenAI API is the only supported/pre-implemented 'backend'
Setup required environment variables and then simply import and invoke the function.
import asyncio
from subtaitles import translate_srt_file, Engine, Lang
# use predefined translators from the Engine enum
asyncio.run(
translate_srt_file(
path="/tmp/subtitles.en.srt",
new_path="/tmp/subtitles.de.srt",
translator=Engine.OPEN_AI,
target=Lang.DE,
)
)
# behavior and configuration is controlled via environment variables
# all the used variables are defined int the environment module
from subtaitles import env
Directory mode
A directory mode is included as well that tries to translate ALL the .srt files it can find in the supplied directory
path. Locale extension are used to avoid re-running the translation over and over, e.g.:
If
sub-1.de.srtalready exists in the directory and translation fromen -> deis to be performed on it, the filesub-1.srtwill be skipped altogether.
import asyncio
from subtaitles import Lang, Engine
from subtaitles.filesystem import translate_directory
asyncio.run(
translate_directory(
path="/tmp/data/shows/foo/season-01",
translator=Engine.OPEN_AI,
target=Lang.DE,
)
)
Custom implementations
An arbitrary class that implements the TranslateProtocol can be passed to both
the translate_srt_file() and translate_srt()
import asyncio
from subtaitles import Lang, translate_srt_file
class MyCustomTranslator:
async def translate(
self,
text: list[str],
language_from: Lang,
language_to: Lang,
) -> list[str]:
# <implement whatever floats your boat>
...
asyncio.run(
translate_srt_file(
path="/tmp/subtitles.en.srt",
new_path="/tmp/subtitles.de.srt",
translator=MyCustomTranslator(),
target=Lang.DE,
)
)
CLI
translate_srt_file is exposed as a utility command for command line usage:
translate_subtitles --help
translate_subtitles --engine openai /tmp/subtitles.en.srt /tmp/subtitles.de.srt en de
Metadata
Release files for subt-ai-tles 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| subt_ai_tles-0.2.3.tar.gz | 14.7 kB | Without provenance | Details for subt_ai_tles-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| subt_ai_tles-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for subt_ai_tles-0.2.3-py3-none-any.whl |
Total release size: 35.4 kB
Release files / subt_ai_tles-0.2.3.tar.gz
| Download URL | subt_ai_tles-0.2.3.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3172730d13b56dcdd94737d2381ef685c3e863b60c2dbe75ce518af1534de937
|
|
BLAKE2b-256 checksum How to use checksums |
05f730d200e641f3a49fb7e82fe8ab347b743c0ecb4ecb8550de62e8b09ff030
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / subt_ai_tles-0.2.3-py3-none-any.whl
| Download URL | subt_ai_tles-0.2.3-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28cabb0710015739f1d125a9ae2332e51a0adb769d80e695dafe4e536c3fc56a
|
|
BLAKE2b-256 checksum How to use checksums |
522a511f24cfe92045ca67662de998571c6add5fa9f8ef452dc7e987927016f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for subt-ai-tles 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.