Skip to main content

A tool to translate subtitles using Google Generative AI

Project description

Gemini SRT Translator

PyPI version Python support Downloads

Overview

Gemini SRT Translator is a tool designed to translate subtitle files using Google Generative AI. It leverages the power of the Gemini API to provide accurate and efficient translations for your subtitle files.

Features

  • Translate subtitle files to a specified target language.
  • Customize translation settings such as model name and batch size.
  • List available models from the Gemini API.

Installation

To install Gemini SRT Translator, use pip:

pip install gemini-srt-translator

Setup

Generating Your API Key

To use Gemini SRT Translator, you need to generate a free API key from Google AI Studio. Follow these steps:

  1. Go to Google AI Studio API Key.
  2. Sign in with your Google account.
  3. Click on "Generate API Key".
  4. Copy the generated API key and keep it secure.

You will use this API key for setting up the script before starting the translation process.

Usage

Translate Subtitles

You can translate subtitles using the translate command:

import gemini_srt_translator as gst

gst.gemini_api_key = "your_gemini_api_key_here"
gst.target_language = "French"
gst.input_file = "subtitle.srt"

gst.translate()

This will translate the subtitles in the subtitle.srt file to French.

Configuration

You can further customize the translation settings by providing optional parameters:

  • output_file: Path to save the translated subtitle file.
  • description: Description of the translation job.
  • model_name: Model name to use for translation.
  • batch_size: Batch size for translation.
  • free_quota: Use free quota for translation (default: True).

Example:

import gemini_srt_translator as gst

gst.gemini_api_key = "your_gemini_api_key_here"
gst.target_language = "French"
gst.input_file = "subtitle.srt"
gst.output_file = "subtitle_translated.srt"
gst.description = "Translation of subtitle file"
gst.model_name = "gemini-1.5-flash"
gst.batch_size = 30
gst.free_quota = True

gst.translate()

List Models

You can list the available models using the listmodels command:

import gemini_srt_translator as gst

gst.gemini_api_key = "your_gemini_api_key_here"
gst.listmodels()

This will print a list of available models to the console.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

gemini_srt_translator-1.2.5.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

gemini_srt_translator-1.2.5-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file gemini_srt_translator-1.2.5.tar.gz.

File metadata

  • Download URL: gemini_srt_translator-1.2.5.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for gemini_srt_translator-1.2.5.tar.gz
Algorithm Hash digest
SHA256 34ba77bb355ff22a510c7f47e37865dcb2f389e018cb6ff99fe8cd5a3ef02eff
MD5 01925e183582ec6a2f1433c14ef386c0
BLAKE2b-256 9d192d0c5d08b021261cc4a7dfedbad9714c56841680647283f7e127c414570a

See more details on using hashes here.

File details

Details for the file gemini_srt_translator-1.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for gemini_srt_translator-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 de5a31d478c983d6fa24c5f07cec006866730e8e67be97f1f05b998e022f0734
MD5 6d30baac13d61e153602a3568f311d9e
BLAKE2b-256 61d34f242f2a222fefd47979dcd3e1b62b38a243ae402677b009162752b96c86

See more details on using hashes here.

Supported by

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