Skip to main content

A tool for generating subtitles using Google Gemini models.

Project description

Subtitle tool

codecov

This utility uses Google Gemini to generate subtitles to audio and video files.

Dependencies

ffmpeg needs to be installed for audio extraction.

Process

  1. Extract the audio from the video
  2. Send the audio to Gemini for transcription
  3. Backup the existing subtitle
  4. Save the new subtitle

Dependencies

  • Export the API key for Gemini to the environment variable GEMINI_API_KEY or specify it in the command line with the flag --api-key.

  • ffmpeg needs to be installed (brew install ffmpeg, apt-get install ffmpeg or dnf install ffmpeg)

  • Ensure uv installs its dev dependencies with uv sync --extra dev.

Installation

pip install subtitle-tool

Developing

For local development it is useful to install the binary from the development location into the user's PATH. For this, run the following commands:

uv tool install -e .
uv tool update-shell

Usage

  • Subtitle files with the defaults:
subtitle-tool video.avi
subtitle-tool audio.mp3
  • Usage options:
Usage: subtitle-tool [OPTIONS] MEDIAFILE

  Generate subtitles for a media file

Options:
  --api-key TEXT                  Google Gemini API key
  -m, --ai-model TEXT             Gemini model to use  [default:
                                  gemini-2.5-flash]
  -s, --subtitle-path TEXT        Subtitle file name [default: MEDIAFILE.srt]
  -v, --verbose                   Enable debug logging for subtitle_tool
                                  modules
  -d, --debug                     Enable debug logging for all modules
  -k, --keep-temp-files           Do not erase temporary files
  -l, --audio-segment-length INTEGER
                                  Length of audio segments to be subtitled in
                                  seconds  [default: 30]
  -p, --parallel-segments INTEGER
                                  Number of segments subtitled in parallel
                                  [default: 5]
  --help                          Show this message and exit.

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

subtitle_tool-0.1.56.tar.gz (50.9 kB view details)

Uploaded Source

Built Distribution

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

subtitle_tool-0.1.56-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file subtitle_tool-0.1.56.tar.gz.

File metadata

  • Download URL: subtitle_tool-0.1.56.tar.gz
  • Upload date:
  • Size: 50.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for subtitle_tool-0.1.56.tar.gz
Algorithm Hash digest
SHA256 0e76e6f5d74d85f53587a7ad65fe5c2fb926688eb480bcad7e5c84c609bfa8f4
MD5 a7ba13817f5c7ff34917f2c366d0fea6
BLAKE2b-256 9298e5f535ed000c03444216033150f8fd713b8445aeb2d9707d47f4beeb1fb4

See more details on using hashes here.

File details

Details for the file subtitle_tool-0.1.56-py3-none-any.whl.

File metadata

File hashes

Hashes for subtitle_tool-0.1.56-py3-none-any.whl
Algorithm Hash digest
SHA256 673b9a45a97262a0e19a95f2bc00a18d7b4cf24f9574b7e399c1e5d2eed68a0b
MD5 85dd13124b8ba7116d2b5809820309a5
BLAKE2b-256 497614bc3aff6d0fb0fcb8f5347ccb15b85b880da24f06ca05a51fa193e7570a

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