Skip to main content

No project description provided

Project description

SUBT-AI-TLES

A simple wrapper around LLMs that provides language translation interface for subtitles (.srt).

Predefined implementations

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,
        source=Lang.EN,
        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

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(),
        source=Lang.EN,
        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

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

subt_ai_tles-0.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

subt_ai_tles-0.0.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file subt_ai_tles-0.0.1.tar.gz.

File metadata

  • Download URL: subt_ai_tles-0.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for subt_ai_tles-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d49cb676ddf49d2ebd7528d6153acf4532f0a0e7d01536a331e3169ba49c072d
MD5 2f1eaeb4aa8d84bee6c96869fc304bc4
BLAKE2b-256 133cb192ed2573f3874dc88842250279162b864698c5d46300e6d042f7e25601

See more details on using hashes here.

File details

Details for the file subt_ai_tles-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for subt_ai_tles-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84e96acaaf2d930e8c8a6a748d466bb18264e54e15bba0d2c19e2cec8c9bf247
MD5 1eb833f00765a08d405606cfd7a6bfd4
BLAKE2b-256 067ae52b1fdf4d1450fa03e7318af33dd7d9257def2e8abc19991c8ea53c0b09

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