Translation and subtitle services for 3speak.tv, powered by LibreTranslate and a custom subtitle API.
Two Docker services:
- LibreTranslate (port 5000) — self-hosted translation for comment sections across the 3speak.tv frontend. Supports 34 languages with automatic source language detection.
- Subtitle API (port 3300) — lightweight Node.js service that queries MongoDB for available video subtitles by author/permlink.
- Docker & Docker Compose
- ~5 GB RAM (for language models)
- ~3 GB disk (models are downloaded on first start and persisted in a Docker volume)
- MongoDB connection (for subtitle API)
cp .env.example .env
# Edit .env with your MongoDB connection string
docker compose up -dFirst startup takes a few minutes while language models download. Subsequent starts are instant.
# Translation
curl -X POST http://localhost:5000/translate \
-H 'Content-Type: application/json' \
-d '{"q":"Hello world","source":"en","target":"de","format":"text"}'
# Subtitles
curl http://localhost:3300/subtitles/cryptomorfosis/f353d7b5English, Chinese, Hindi, Spanish, French, Arabic, Bengali, Portuguese, Russian, Japanese, German, Korean, Italian, Dutch, Polish, Turkish, Vietnamese, Thai, Indonesian, Ukrainian, Swedish, Czech, Greek, Hungarian, Finnish, Danish, Romanian, Hebrew, Persian, Tagalog, Malay, Bulgarian, Norwegian, Urdu
POST /translate- Translate textGET /languages- List available languagesPOST /detect- Detect language of text
See LibreTranslate API docs for full reference.
GET /subtitles/:author/:permlink- Get available subtitles for a videoGET /health- Health check
Example:
curl http://localhost:3300/subtitles/cryptomorfosis/f353d7b5Response:
[
{ "lang": "en", "cid": "QmZw3G6RKvRu2PiKBHErXHmhYiWCYoySBNXFeUojxvzUNh" },
{ "lang": "es", "cid": "Qma4MA9AUDrPsykwGfukWzzohq5pfkagNkFUdbNG8xqz3n" }
]Returns 404 if no subtitles exist for the given author/permlink.
| Variable | Default | Description |
|---|---|---|
LT_LOAD_ONLY |
34 languages | Comma-separated language codes to load |
LT_API_KEYS |
false |
Require API keys (disabled for local use) |
MONGODB_URI |
— | MongoDB connection string (required for subtitle API) |
DATABASE_NAME |
threespeak |
MongoDB database name |
COLLECTION_NAME |
subtitles |
MongoDB collection name |
API_PORT |
3300 |
Port for the subtitle API |
An example nginx config is provided in nginx/translator.conf.example.
To set it up on your server:
# Copy and rename with your domain
sudo cp nginx/translator.conf.example /etc/nginx/sites-available/translator.yourdomain.com
# Edit the file and replace translator.example.com with your domain
sudo nano /etc/nginx/sites-available/translator.yourdomain.com
# Enable the site
sudo ln -s /etc/nginx/sites-available/translator.yourdomain.com /etc/nginx/sites-enabled/
# Test and reload nginx
sudo nginx -t && sudo systemctl reload nginx
# Obtain SSL certificate
sudo certbot --nginx -d translator.yourdomain.comThe 3speak.tv frontend connects via the VITE_TRANSLATE_API_URL environment variable.
docker compose ps
docker logs -f 3speak-translate
docker logs -f 3speak-subtitle-api