Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

Containerize live translation service and move default port to 8765

a0e2f615b9431
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
index b3839237..1931b574 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsStateBindings.kt
@@ -57,7 +57,7 @@ internal fun observeSettingsPreferenceSnapshot(
subtitleTextColor = 0xFFFFFFFF.toInt(),
subtitleBackgroundColor = 0x80000000.toInt(),
playerLiveTranslationEnabled = false,
- playerLiveTranslationEndpoint = "http://10.0.2.2:8177",
+ playerLiveTranslationEndpoint = "http://10.0.2.2:8765",
wifiMaxVideoHeight = null,
ethernetMaxVideoHeight = null,
playerTimeshiftEnabled = false,
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsUiStateModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsUiStateModel.kt
index 54601c5f..a528fb0b 100644
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsUiStateModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsUiStateModel.kt
@@ -77,7 +77,7 @@ data class SettingsUiState(
val subtitleTextColor: Int = 0xFFFFFFFF.toInt(),
val subtitleBackgroundColor: Int = 0x80000000.toInt(),
val playerLiveTranslationEnabled: Boolean = false,
- val playerLiveTranslationEndpoint: String = "http://10.0.2.2:8177",
+ val playerLiveTranslationEndpoint: String = "http://10.0.2.2:8765",
val wifiMaxVideoHeight: Int? = null,
val ethernetMaxVideoHeight: Int? = null,
val playerTimeshiftEnabled: Boolean = false,
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3cebcc83..b08191f7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -407,7 +407,7 @@
<string name="settings_live_translation_enabled">Enable Live Translation Subtitles</string>
<string name="settings_live_translation_enabled_subtitle">Translate spoken live-channel audio into English subtitles using your local Whisper service.</string>
<string name="settings_live_translation_endpoint">Live Translation Service Endpoint</string>
- <string name="settings_live_translation_endpoint_subtitle">Base URL for the local translation service (emulator default: http://10.0.2.2:8177).</string>
+ <string name="settings_live_translation_endpoint_subtitle">Base URL for the local translation service (emulator default: http://10.0.2.2:8765).</string>
<string name="settings_live_translation_endpoint_empty_error">Live translation endpoint cannot be empty.</string>
<string name="settings_live_timeshift_depth">Local Live Rewind Depth</string>
<string name="settings_live_timeshift_backend">Live Rewind Backend</string>
diff --git a/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt b/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
index 191228c1..6957e0ba 100644
--- a/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
+++ b/data/src/main/java/com/streamvault/data/preferences/PreferencesRepository.kt
@@ -347,7 +347,7 @@ class PreferencesRepository @Inject constructor(
preferences[PreferencesKeys.PLAYER_LIVE_TRANSLATION_ENDPOINT]
?.trim()
?.takeIf { it.isNotBlank() }
- ?: "http://10.0.2.2:8177"
+ ?: "http://10.0.2.2:8765"
}
val playerControlsTimeoutSeconds: Flow<Int> = context.dataStore.data.map { preferences ->
diff --git a/docs/LOCAL_LIVE_TRANSLATION.md b/docs/LOCAL_LIVE_TRANSLATION.md
index 4ef68331..205773e9 100644
--- a/docs/LOCAL_LIVE_TRANSLATION.md
+++ b/docs/LOCAL_LIVE_TRANSLATION.md
@@ -6,7 +6,7 @@ This feature adds optional live translation subtitles for `LIVE` playback in the
- Supported for `LIVE` playback from `Xtream` and `M3U` providers.
- The player sends session metadata and tapped decoded PCM audio to a local translation service.
-- The service is expected to run on the same Mac as the Android emulator (`http://10.0.2.2:8177` default).
+- The service is expected to run on the same Mac as the Android emulator (`http://10.0.2.2:8765` default).
- Source language is expected to be auto-detected by the service.
- Returned text is rendered as a single caption line, one phrase at a time
(replaced in place), and cleared after a short idle/linger period.
@@ -78,6 +78,24 @@ This yields English output subtitles from multilingual speech inputs.
## Quick local startup (ready-to-run)
+### Docker (recommended)
+
+The service ships with a `Dockerfile` and `docker-compose.yml`
+(`tools/live-translation-service/`). The container restarts automatically if the
+process crashes or after a reboot (`restart: unless-stopped`), caches the model in a
+named volume, and is capped at 6 GB memory (large-v3 int8 peaks at ~3-4 GB — make
+sure Docker Desktop's VM has at least 8 GB allocated):
+
+```bash
+cd tools/live-translation-service
+docker compose up -d
+```
+
+Note: Docker on macOS has no GPU access, so the container always uses the
+faster-whisper CPU backend. For the MLX (Metal GPU) backend, run natively as below.
+
+### Native (venv)
+
Start the included local service with model `large-v3`:
```bash
@@ -86,7 +104,7 @@ WHISPER_MODEL=large-v3 \
tools/live-translation-service/.venv/bin/uvicorn service:app \
--app-dir tools/live-translation-service \
--host 0.0.0.0 \
- --port 8177
+ --port 8765
```
### Compute resources (Apple Silicon)
@@ -135,7 +153,7 @@ WHISPER_TRANSLATION_MODE=llm \
LLM_BASE_URL=http://localhost:1234/v1 \
LLM_MODEL=qwen3.6-35b-a3b \
tools/live-translation-service/.venv/bin/uvicorn service:app \
- --app-dir tools/live-translation-service --host 0.0.0.0 --port 8177
+ --app-dir tools/live-translation-service --host 0.0.0.0 --port 8765
```
LLM env vars: `LLM_BASE_URL`, `LLM_API_KEY` (default `lm-studio`), `LLM_MODEL`,
@@ -157,4 +175,4 @@ Equivalent docker/env setups are fine as long as your API accepts the same PCM u
- Android emulator cannot reach host `localhost` directly for host-machine services.
- Use `10.0.2.2` for services running on your Mac.
-- Default expected endpoint in app preferences: `http://10.0.2.2:8177`.
+- Default expected endpoint in app preferences: `http://10.0.2.2:8765`.
diff --git a/tools/live-translation-service/.dockerignore b/tools/live-translation-service/.dockerignore
new file mode 100644
index 00000000..6cb62407
--- /dev/null
+++ b/tools/live-translation-service/.dockerignore
@@ -0,0 +1,7 @@
+.venv/
+.hf-cache/
+__pycache__/
+.claude/
+.gitignore
+Dockerfile
+docker-compose.yml
diff --git a/tools/live-translation-service/Dockerfile b/tools/live-translation-service/Dockerfile
new file mode 100644
index 00000000..d89a4e84
--- /dev/null
+++ b/tools/live-translation-service/Dockerfile
@@ -0,0 +1,21 @@
+FROM python:3.12-slim
+
+# CTranslate2 (faster-whisper) needs OpenMP at runtime.
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends libgomp1 \
+ && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /app
+
+COPY requirements.txt .
+RUN pip install --no-cache-dir -r requirements.txt
+
+COPY service.py .
+
+# Model downloads land here; docker-compose mounts a volume at this path so the
+# ~3 GB large-v3 download survives container rebuilds.
+ENV HF_HOME=/data/hf-cache
+
+EXPOSE 8765
+
+CMD ["uvicorn", "service:app", "--host", "0.0.0.0", "--port", "8765"]
diff --git a/tools/live-translation-service/docker-compose.yml b/tools/live-translation-service/docker-compose.yml
new file mode 100644
index 00000000..503247b7
--- /dev/null
+++ b/tools/live-translation-service/docker-compose.yml
@@ -0,0 +1,34 @@
+services:
+ live-translation:
+ build: .
+ image: live-translation-service
+ container_name: live-translation
+ restart: unless-stopped
+ ports:
+ - "8765:8765"
+ environment:
+ WHISPER_MODEL: large-v3
+ WHISPER_BACKEND: faster-whisper
+ WHISPER_COMPUTE_TYPE: int8
+ # WHISPER_TRANSLATION_MODE: llm
+ # LLM mode reaches LM Studio / Ollama running on the Mac host:
+ LLM_BASE_URL: http://host.docker.internal:1234/v1
+ extra_hosts:
+ - "host.docker.internal:host-gateway"
+ volumes:
+ # Keeps the ~3 GB large-v3 download across rebuilds/restarts.
+ - hf-cache:/data/hf-cache
+ # large-v3 int8 on CPU peaks around 3-4 GB; 6 GB leaves room for spikes
+ # while staying inside the 8 GB Docker Desktop VM.
+ mem_limit: 6g
+ memswap_limit: 6g
+ healthcheck:
+ test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8765/health', timeout=5)"]
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ # First start downloads the model and warms it; don't flag unhealthy early.
+ start_period: 10m
+
+volumes:
+ hf-cache: