refractoring

This commit is contained in:
2025-03-19 13:45:46 +01:00
parent 92169ed4ae
commit 5e5c3e2040
6 changed files with 46 additions and 26 deletions
+23
View File
@@ -0,0 +1,23 @@
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
liblc3-tools \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy project files
COPY . .
# Install Python dependencies
RUN --mount=type=cache,target=/root/.cache pip install --no-cache-dir .
# dependencies for running piper on gpu
RUN --mount=type=cache,target=/root/.cache pip install --no-cache-dir onnxruntime-gpu
# Expose the API port
EXPOSE 7999
# Run the translator server
CMD ["python", "-m", "multilang_translator.translator_server.translator_server"]
+12
View File
@@ -0,0 +1,12 @@
services:
auracast-translator:
build:
context: .
dockerfile: Dockerfile
ports:
- "7999:7999"
environment:
- PYTHONUNBUFFERED=1
restart: unless-stopped
networks:
- translator-network
+8 -3
View File
@@ -4,13 +4,14 @@ requires-python = ">= 3.11"
version = '0.1'
dependencies = [
"auracast @git+https://git@gitea.pstruebi.xyz/auracaster/bumble-auracast",
"requests==2.32.3",
"ollama==0.4.7",
"aioconsole==0.8.1",
"fastapi==0.115.11",
"uvicorn==0.34.0",
"ollama==0.4.7",
"requests==2.32.3",
"aiohttp==3.9.3",
"piper-tts==1.2.0",
"librosa==0.10.1"
]
[project.optional-dependencies]
@@ -18,6 +19,10 @@ test = [
"pytest >= 8.2",
]
[tool.poetry.group.auracast_onboard.dependencies]
auracast = "auracast@git+https://git@gitea.pstruebi.xyz/auracaster/bumble-auracast"
[tool.poetry.group.tts.dependencies]
piper-phonemize = "==1.1.0"
piper-tts = "==1.2.0"
+1 -1
View File
@@ -1,7 +1,7 @@
# Prerequisites
sudo apt install liblc3-tools
use python3.9
use python3.11
pip install piper-tts soundfile librosa pyserial pytest
# Piper update voices
+2 -2
View File
@@ -10,14 +10,14 @@ from auracast import auracast_config
import voice_client
import voice_models
from multilang_translator import translator_config
from multilang_translator.translator_models import translator_models
from multilang_translator.translator import llm_translator
import voice_client.tts_client
import voice_models.request_models
async def announcement_from_german_text(
config: translator_config.TranslatorConfigGroup,
config: translator_models.TranslatorConfigGroup,
text_de
):
base_lang = "deu"
@@ -1,20 +0,0 @@
import os
from pydantic import BaseModel
VENV_DIR = os.path.join(os.path.dirname(__file__), './../../venv')
class TranslatorLangConfig(BaseModel):
translator_llm: str = 'llama3.2:3b-instruct-q4_0' # TODO: this was migrated to translator_models - remove this
llm_client: str = 'ollama'
llm_host_url: str | None = 'http://localhost:11434'
llm_host_token: str | None = None
tts_system: str = 'piper'
tts_model: str ='de_DE-kerstin-low'
class TranslatorConfig(BaseModel):
deu: TranslatorLangConfig = TranslatorLangConfig(tts_model = 'de_DE-thorsten-high')
eng: TranslatorLangConfig = TranslatorLangConfig(tts_model = 'en_GB-alba-medium')
fra: TranslatorLangConfig = TranslatorLangConfig(tts_model = 'fr_FR-siwis-medium')
spa: TranslatorLangConfig = TranslatorLangConfig(tts_model = 'es_ES-sharvard-medium')
ita: TranslatorLangConfig = TranslatorLangConfig(tts_model = 'it_IT-paola-medium')