File size: 507 Bytes
84fb685
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os, sys

# HF Spaces pass the port via PORT
PORT = os.environ.get("PORT", "7860")

# Limit models for faster boot + smaller disk use (tweak as you like)
os.environ.setdefault(
    "LT_LOAD_ONLY",
    "en,es,fr,de,pt,ru,ar,hi,ja,ko,zh"
)

# Start LibreTranslate and download/update models on first boot
args = [
    "libretranslate",
    "--host", "0.0.0.0",
    "--port", str(PORT),
    "--update-models"
]

# Replace this Python process with the LT server (cleaner signals)
os.execvp(args[0], args)