mcspeak/Dockerfile
Ryan Malloy eaff3e8861 Add project-aware voice identity with round-robin assignment
Each project gets a distinct voice from a curated English pool,
assigned via round-robin with gender/accent interleaving for
maximum perceptual contrast between consecutive projects.

- New voice_identity.py: pool filtering, interleaving, persistence
- Round-robin replaces SHA-256 hashing (no collisions until pool
  exhaustion at 22 voices)
- Assignments persist to /data/voice-assignments.json across restarts
- speak() and generate_audio() accept optional project= parameter
- MCP roots fallback with 2s timeout for future bidirectional clients
- English-only pool (af_/am_/bf_/bm_/ef_/em_ prefixes)
- af_nicole excluded from auto-assign (whispery), still explicit-ok
- Fix voice blacklist to use full identifiers (am_adam, af_jessica)
2026-02-24 11:58:10 -07:00

42 lines
1.3 KiB
Docker

FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
# PipeWire client tools — pw-play connects to the host's PipeWire socket
RUN apt-get update && apt-get install -y --no-install-recommends \
pipewire-bin \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
ENV UV_COMPILE_BYTECODE=1
# Create venv
RUN uv venv
# Install CPU-only torch first (saves ~3GB vs CUDA — SNAC runs on CPU anyway)
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install torch --index-url https://download.pytorch.org/whl/cpu
# Install project dependencies (torch already satisfied, won't redownload)
COPY pyproject.toml ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install --no-deps -r pyproject.toml 2>/dev/null || true
# Copy source and install project
COPY src/ src/
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install .
# Non-root user matching host uid for PipeWire socket access
RUN useradd -u 1000 -m tts \
&& mkdir -p /home/tts/.cache/huggingface /data \
&& chown -R tts:tts /home/tts/.cache /data
USER tts
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8371
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s \
CMD python -c "import socket; s=socket.create_connection(('127.0.0.1',8371),2); s.close()" || exit 1
CMD ["tts-mcp"]