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.
- 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.
To install Gemini SRT Translator, use pip:
pip install gemini-srt-translator
To use Gemini SRT Translator, you need to generate a free API key from Google AI Studio. Follow these steps:
- Go to Google AI Studio API Key.
- Sign in with your Google account.
- Click on "Generate API Key".
- 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.
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.
You can further customize the translation settings by providing optional parameters:
gemini_api_key2
: Second Gemini API key for additional quota.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.gemini_api_key2 = "your_gemini_api_key2_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()
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.
This project is licensed under the MIT License. See the LICENSE file for details.