Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .devops/cpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# audio.cpp — CPU Dockerfile
#
# Usage:
# docker build -f .devops/cpu.Dockerfile -t local/audiocpp:full-cpu .

# ============================================================
# [BUILD] Compile all release binaries
# ============================================================
ARG UBUNTU_VERSION=24.04
ARG BUILD_DATE=N/A
ARG APP_VERSION=N/A
ARG APP_REVISION=N/A
ARG GCC_VERSION=14

FROM docker.io/ubuntu:$UBUNTU_VERSION AS build

ARG GCC_VERSION=14

# Install build toolchain
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc-${GCC_VERSION} g++-${GCC_VERSION} make cmake libgomp1 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV CC=gcc-${GCC_VERSION} CXX=g++-${GCC_VERSION}

WORKDIR /app
COPY . .

# Configure
RUN cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DENGINE_ENABLE_CUDA=OFF \
-DENGINE_ENABLE_VULKAN=OFF \
-DENGINE_ENABLE_OPENMP=ON \
-DENGINE_BUILD_EXAMPLES=OFF \
-DENGINE_BUILD_TESTS=OFF \
-DENGINE_BUILD_WARMBENCH=OFF && \
cmake --build build --parallel $(nproc) \
--target audiocpp_cli \
--target audiocpp_server \
--target model_perf \
--target miocodec_wavlm_parity

# Collect all binaries + multiplexer into /app/full
RUN mkdir -p /app/full && \
cp build/bin/audiocpp_cli build/bin/audiocpp_server \
build/bin/model_perf build/bin/miocodec_wavlm_parity /app/full/ && \
cp .devops/entrypoint.sh /app/full/entrypoint.sh && \
chmod +x /app/full/entrypoint.sh

# ============================================================
# [BASE] Shared runtime (OS + common libs)
# ============================================================
FROM docker.io/ubuntu:$UBUNTU_VERSION AS base

ARG BUILD_DATE=N/A
ARG APP_VERSION=N/A
ARG APP_REVISION=N/A
ARG IMAGE_URL=https://github.com/0xShug0/audio.cpp
ARG IMAGE_SOURCE=https://github.com/0xShug0/audio.cpp

LABEL org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.version=$APP_VERSION \
org.opencontainers.image.revision=$APP_REVISION \
org.opencontainers.image.title="audio.cpp" \
org.opencontainers.image.description="An all-in-one, pure C++ inference engine for audio models, powered by ggml" \
org.opencontainers.image.url=$IMAGE_URL \
org.opencontainers.image.source=$IMAGE_SOURCE

# Runtime deps: OpenMP threading, curl (healthcheck), ffmpeg (audio I/O)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgomp1 curl ffmpeg && \
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /tmp/* /var/tmp/* && \
find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete && \
find /var/cache -type f -delete

WORKDIR /app

# ============================================================
# [FULL] All binaries + entrypoint.sh multiplexer
# ============================================================
FROM base AS full

COPY --from=build /app/full /app

USER ubuntu

HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=15s \
CMD curl -f http://localhost:8080/health || exit 1

ENTRYPOINT ["/app/entrypoint.sh"]
102 changes: 102 additions & 0 deletions .devops/cuda.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# audio.cpp — CUDA Dockerfile
#
# Usage:
# docker build -f .devops/cuda.Dockerfile -t local/audiocpp:full-cuda .

# ============================================================
# [BUILD] Compile all release binaries with CUDA
# ============================================================
ARG UBUNTU_VERSION=24.04
ARG CUDA_VERSION=12.9.0
ARG BUILD_DATE=N/A
ARG APP_VERSION=N/A
ARG APP_REVISION=N/A
ARG GCC_VERSION=14

ARG BASE_CUDA_DEV_CONTAINER=docker.io/nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
ARG BASE_CUDA_RUN_CONTAINER=docker.io/nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}

FROM ${BASE_CUDA_DEV_CONTAINER} AS build

ARG GCC_VERSION=14

# Install build toolchain
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc-${GCC_VERSION} g++-${GCC_VERSION} cmake && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV CC=gcc-${GCC_VERSION} CXX=g++-${GCC_VERSION} CUDAHOSTCXX=g++-${GCC_VERSION}

WORKDIR /app
COPY . .

# Configure
RUN cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DENGINE_ENABLE_CUDA=ON \
-DENGINE_ENABLE_CUDA_GRAPHS=ON \
-DENGINE_ENABLE_VULKAN=OFF \
-DENGINE_ENABLE_OPENMP=ON \
-DENGINE_BUILD_EXAMPLES=OFF \
-DENGINE_BUILD_TESTS=OFF \
-DENGINE_BUILD_WARMBENCH=OFF && \
cmake --build build --parallel $(nproc) \
--target audiocpp_cli \
--target audiocpp_server \
--target model_perf \
--target miocodec_wavlm_parity

# Collect all binaries + multiplexer into /app/full
RUN mkdir -p /app/full && \
cp build/bin/audiocpp_cli build/bin/audiocpp_server \
build/bin/model_perf build/bin/miocodec_wavlm_parity /app/full/ && \
cp .devops/entrypoint.sh /app/full/entrypoint.sh && \
chmod +x /app/full/entrypoint.sh

# ============================================================
# [BASE] Shared runtime (NVIDIA CUDA + common libs)
# ============================================================
FROM ${BASE_CUDA_RUN_CONTAINER} AS base

ARG BUILD_DATE=N/A
ARG APP_VERSION=N/A
ARG APP_REVISION=N/A
ARG IMAGE_URL=https://github.com/0xShug0/audio.cpp
ARG IMAGE_SOURCE=https://github.com/0xShug0/audio.cpp

LABEL org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.version=$APP_VERSION \
org.opencontainers.image.revision=$APP_REVISION \
org.opencontainers.image.title="audio.cpp" \
org.opencontainers.image.description="An all-in-one, pure C++ inference engine for audio models, powered by ggml" \
org.opencontainers.image.url=$IMAGE_URL \
org.opencontainers.image.source=$IMAGE_SOURCE

# Runtime deps: OpenMP threading, curl (healthcheck), ffmpeg (audio I/O)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgomp1 curl ffmpeg && \
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /tmp/* /var/tmp/* && \
find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete && \
find /var/cache -type f -delete

WORKDIR /app

# ============================================================
# [FULL] All binaries + entrypoint.sh multiplexer
# ============================================================
FROM base AS full

COPY --from=build /app/full /app

USER ubuntu

HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=15s \
CMD curl -f http://localhost:8080/health || exit 1

ENTRYPOINT ["/app/entrypoint.sh"]

31 changes: 31 additions & 0 deletions .devops/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# ============================================================
# audio.cpp Docker multiplexer
#
# Dispatches to the correct binary based on the first
# argument. All remaining arguments are forwarded verbatim.
# ============================================================
set -e

arg1="$1"
shift || true

if [[ "$arg1" == "cli" ]]; then
exec ./audiocpp_cli "$@"
elif [[ "$arg1" == "server" ]]; then
exec ./audiocpp_server "$@"
elif [[ "$arg1" == "perf" ]]; then
exec ./model_perf "$@"
elif [[ "$arg1" == "parity" ]]; then
exec ./miocodec_wavlm_parity "$@"
else
echo "Unknown command: $arg1"
echo ""
echo "Available commands:"
echo " cli Run audio tasks (TTS, ASR, VAD, VC, diar, etc.)"
echo " server Run the HTTP server"
echo " perf Run model performance benchmarks"
echo " parity Run Miocodec WavLM parity tests"
exit 1
fi

9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git/
.gitignore
.github/
examples/
scripts/
docs/
tools/
build/
*.md
1 change: 1 addition & 0 deletions examples/docker/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
48 changes: 48 additions & 0 deletions examples/docker/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Docker CLI

Run the audio.cpp CLI tool inside a Docker container for text-to-speech.

## Setup

**1. Download the PocketTTS model**

Get the English model from [kyutai/pocket-tts](https://huggingface.co/kyutai/pocket-tts/) on Hugging Face.
Place the files from `languages/english/` into `../models/pocket-tts/languages/english/`:

The directory should look like:
```
../models/pocket-tts/languages/english/
├── model.safetensors
├── tokenizer.model
└── embeddings/
├── alba.safetensors
└── ...
```

**2. Build the image**

Run from repository root:

CPU:

```bash
docker build -f .devops/cpu.Dockerfile -t local/audiocpp:full-cpu .
```

GPU (CUDA):

```bash
docker build -f .devops/cuda.Dockerfile -t local/audiocpp:full-cuda .
```

## Usage

Run one of:

```bash
./cpu-tts.sh
./cuda-tts.sh
```

Speech is saved to `output/speech.wav`.

22 changes: 22 additions & 0 deletions examples/docker/cli/cpu-tts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e

OUTPUT_DIR="$(cd "$(dirname "$0")" && pwd)/output"
mkdir -p "$OUTPUT_DIR"
MODEL_DIR="$(cd "$(dirname "$0")/../models" && pwd)"

docker run --rm \
--user "$(id -u):$(id -g)" \
-v "$MODEL_DIR:/models:ro" \
-v "$OUTPUT_DIR:/output" \
local/audiocpp:full-cpu \
cli \
--task tts \
--family pocket_tts \
--model /models/pocket-tts \
--backend cpu \
--text "You are successfully running a text-to-speech model using audio.cpp, a pure C++ inference engine for audio models." \
--voice-id alba \
--out /output/speech.wav

echo "Saved to: $OUTPUT_DIR/speech.wav"
24 changes: 24 additions & 0 deletions examples/docker/cli/cuda-tts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e

OUTPUT_DIR="$(cd "$(dirname "$0")" && pwd)/output"
mkdir -p "$OUTPUT_DIR"
MODEL_DIR="$(cd "$(dirname "$0")/../models" && pwd)"

docker run --rm \
--gpus all \
--user "$(id -u):$(id -g)" \
-v "$MODEL_DIR:/models:ro" \
-v "$OUTPUT_DIR:/output" \
local/audiocpp:full-cuda \
cli \
--task tts \
--family pocket_tts \
--model /models/pocket-tts \
--backend cuda \
--device 0 \
--text "You are successfully running a text-to-speech model using audio.cpp, a pure C++ inference engine for audio models." \
--voice-id alba \
--out /output/speech.wav

echo "Saved to: $OUTPUT_DIR/speech.wav"
2 changes: 2 additions & 0 deletions examples/docker/models/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!put_models_here
4 changes: 4 additions & 0 deletions examples/docker/models/put_models_here
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Download PocketTTS model files here:
# models/pocket-tts/languages/english/model.safetensors
# models/pocket-tts/languages/english/tokenizer.model
# models/pocket-tts/languages/english/embeddings/*.safetensors
1 change: 1 addition & 0 deletions examples/docker/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
43 changes: 43 additions & 0 deletions examples/docker/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Docker Compose Server

Run the audio.cpp TTS server (as configured in server.json) in Docker.

## Setup

**1. Download the PocketTTS model**

Get the English model from [kyutai/pocket-tts](https://huggingface.co/kyutai/pocket-tts/) on Hugging Face.
Place the files from `languages/english/` into `../models/pocket-tts/languages/english/`:

The directory should look like:
```
../models/pocket-tts/languages/english/
├── model.safetensors
├── tokenizer.model
└── embeddings/
├── alba.safetensors
└── ...
```

**2. Start the server**

CPU:

```bash
docker compose -f cpu-server.yml up
```

GPU (CUDA):

```bash
docker compose -f cuda-server.yml up
```

## Generate speech

```bash
./tts.sh
```

This sends a request to `http://localhost:8080/v1/audio/speech` and saves the result to `output/speech.wav`.

Loading
Loading