
What is aisub-translator
aisub-translator is a versatile and powerful Python script developed by tsundereraws for translating subtitles. It supports subtitle formats such as .ass
and .srt
, translating them line-by-line with the help of various AI providers like OpenAI, Claude, OpenRouter, MistralAI, DeepSeek, and Ollama. The script is designed to retain the original formatting and styles present in ASS files by preserving their headers, ensuring that only the dialogue lines are translated. This makes it an ideal tool for content creators, translators, and anyone looking to efficiently translate subtitles while maintaining the original style and formatting.
How to Use aisub-translator
To use aisub-translator, you need to have Python 3.13.1 installed along with several dependencies. These can be installed using the following command:
pip install openai requests langdetect pysubs2 python-dotenv mistralai ollama
Once set up, create a .env
file in your project directory to manage your API keys and model configurations for the various AI providers.
To translate subtitle files, run the script from the command line with specified arguments. For instance:
python aisub-translator.py input1.srt input2.srt --target-language en --ai openai --model gpt-4 --temperature 1.0 --context "Episode about a samurai's journey."
Key Command Line Arguments:
input_files
: One or more subtitle files (.ass
or.srt
) to be processed.--target-language
: The language code for the target translation (e.g.,en
for English).--ai
: Selects the AI provider (options includeopenai
,claude
,deepseek
,openrouter
,mistral
,ollama
).--context
: Provides an episode synopsis for contextual translation.--output-file
: Specifies the path to save the translated subtitle file.
Key Features of aisub-translator
- Multi-AI Support: Choose from a variety of AI providers for translation, including OpenAI and Claude.
- Model Customization: Configure models like GPT-4 or Claude 3 through a
.env
file to suit specific translation needs. - Preservation of ASS Headers: Maintains original styles and formatting in
.ass
files, translating only the dialogue. - Selective Processing: Translates only dialogue lines, skipping empty lines and other non-dialogue content.
- Contextual Translation: Enables the addition of synopses and uses previous dialogues to enhance translation continuity.
- Live Output Updates: Continuously updates the output file as each line is translated, allowing for real-time monitoring.
- Clean Logging: Provides clear console messages free from formatting codes for better readability.
- Easy Configuration: Simplifies API key management and model selection through a
.env
file. - Post-Translation Review: Generates a CSV file for review, detailing line numbers alongside original and translated texts.
- Multiple File Support: Allows batch processing of several subtitle files simultaneously.
By utilizing these features, aisub-translator offers a comprehensive solution for subtitle translation that is both user-friendly and efficient, making it a valuable tool for anyone working with multilingual content.
How to Use
To use the aisub-translator, follow these steps:
- Visit https://github.com/tsundereraws/aisub-translatorhttps://github.com/tsunde...
- Follow the setup instructions to create an account (if required)
- Connect the MCP server to your Claude Desktop application
- Start using aisub-translator capabilities within your Claude conversations
Additional Information
Created
February 23, 2025
Company
Start building your own MCP Server
Interested in creating your own MCP Server? Check out the official documentation and resources.
Learn More