Skip to content

Latest commit

 

History

History
175 lines (132 loc) · 4.67 KB

File metadata and controls

175 lines (132 loc) · 4.67 KB

Getting Started with SRT Translator

What This Tool Does

This Python script translates SRT subtitle files using the free Pollinations AI API. It:

  • ✅ Preserves all timing information exactly as it is
  • ✅ Only sends the subtitle text for translation
  • ✅ Works without an API key (completely free!)
  • ✅ Supports batch processing for efficiency

Your SRT File

You have: One.Battle.After.Another.2025.1080p.AMZN.WEB-DL.DDP5.1.H.264-KyoGo.srt

  • Contains: 2,245 subtitle entries
  • Status: ✅ Successfully parsed and ready for translation

Installation (One Time)

# Install the required Python package
pip install requests
# or use the requirements file:
pip install -r requirements.txt

That's it! No API key setup needed.

Usage Examples

1. Basic Translation (English to Spanish)

python translate_srt.py "One.Battle.After.Another.2025.1080p.AMZN.WEB-DL.DDP5.1.H.264-KyoGo.srt" -t es

Output: One.Battle.After.Another.2025.1080p.AMZN.WEB-DL.DDP5.1.H.264-KyoGo_translated.srt

2. Specify Output Filename

python translate_srt.py "One.Battle.After.Another.2025.1080p.AMZN.WEB-DL.DDP5.1.H.264-KyoGo.srt" \
  -t es \
  -o "One.Battle.Spanish.srt"

3. Translate to French

python translate_srt.py "One.Battle.After.Another.2025.1080p.AMZN.WEB-DL.DDP5.1.H.264-KyoGo.srt" -t fr

4. Adjust Batch Size (if you hit rate limits)

python translate_srt.py "One.Battle.After.Another.2025.1080p.AMZN.WEB-DL.DDP5.1.H.264-KyoGo.srt" \
  -t es \
  --batch-size 10

Language Codes

Code Language Code Language
en English ja Japanese
es Spanish ko Korean
fr French zh Chinese
de German pt Portuguese
it Italian auto Auto-detect

What Happens During Translation

  1. Parsing - The script reads your SRT file and extracts:

    1
    00:01:33,135 --> 00:01:34,303
    Welcome.
    
    • Index: 1
    • Timestamp: 00:01:33,135 --> 00:01:34,303 (kept as-is)
    • Text: "Welcome." (sent for translation)
  2. Translation - The text is sent to Pollinations AI:

    • Processed in batches (default: 50 subtitles at a time)
    • Shows progress: "Translated 50/2245 subtitles..."
  3. Reconstruction - Creates new SRT file:

    1
    00:01:33,135 --> 00:01:34,303
    Bienvenido.
    
    • Same index
    • Same timestamp (unchanged!)
    • Translated text

Testing

We've included a test script to verify everything works:

python test_parser.py

This tests the SRT parser without making any API calls.

Files in This Project

  • translate_srt.py - Main translation script
  • requirements.txt - Python dependencies
  • test_parser.py - Test script to verify SRT parsing
  • example_usage.sh - Interactive example script
  • README.md - Full documentation
  • GETTING_STARTED.md - This file!

Troubleshooting

"ModuleNotFoundError: No module named 'requests'"

pip install requests

Translation is slow

  • This is normal! Translating 2,245 subtitles takes time
  • Default batch size is 50 (processes 50 at a time)
  • You can increase it: --batch-size 100 (faster but might hit rate limits)

Rate limiting errors

  • Decrease batch size: --batch-size 10
  • The free tier has a concurrency limit of 1
  • Consider getting an API key for higher limits (still free for higher tiers)

Wrong translation

  • Specify source language explicitly: -s en -t es
  • Try a different model: --model openai

API Tier Information

Pollinations AI offers free tiers:

Tier Key Required? Concurrency Access
Anonymous (🌱) No 1 Basic models
Seed (🌱) Yes 3 Standard models
Flower (🌸) Yes 7 Advanced models
Nectar (🍯) Yes 50 All models + priority

To get an API key (optional, for faster processing):

  1. Visit https://pollinations.ai/
  2. Sign up for a free tier
  3. Use it: --api-key YOUR_KEY

Next Steps

  1. Install dependencies:

    pip install -r requirements.txt
  2. Try a translation:

    python translate_srt.py "One.Battle.After.Another.2025.1080p.AMZN.WEB-DL.DDP5.1.H.264-KyoGo.srt" -t es
  3. Check the output:

    • Look for the _translated.srt file
    • Open it in a text editor or subtitle software
    • Verify timing is preserved
  4. Use with your videos!

Support

For more details, see:


Happy Translating! 🎬🌍