Skip to content

Commit ea6e850

Browse files
authored
feat: Add Kokoros backend (#9212)
Signed-off-by: Richard Palethorpe <io@richiejp.com>
1 parent b7247fc commit ea6e850

19 files changed

Lines changed: 4180 additions & 2 deletions

File tree

.github/workflows/test-extra.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
llama-cpp-quantization: ${{ steps.detect.outputs.llama-cpp-quantization }}
3232
acestep-cpp: ${{ steps.detect.outputs.acestep-cpp }}
3333
voxtral: ${{ steps.detect.outputs.voxtral }}
34+
kokoros: ${{ steps.detect.outputs.kokoros }}
3435
steps:
3536
- name: Checkout repository
3637
uses: actions/checkout@v6
@@ -528,3 +529,25 @@ jobs:
528529
- name: Test voxtral
529530
run: |
530531
make --jobs=5 --output-sync=target -C backend/go/voxtral test
532+
tests-kokoros:
533+
needs: detect-changes
534+
if: needs.detect-changes.outputs.kokoros == 'true' || needs.detect-changes.outputs.run-all == 'true'
535+
runs-on: ubuntu-latest
536+
steps:
537+
- name: Clone
538+
uses: actions/checkout@v6
539+
with:
540+
submodules: true
541+
- name: Dependencies
542+
run: |
543+
sudo apt-get update
544+
sudo apt-get install -y build-essential cmake pkg-config protobuf-compiler clang libclang-dev
545+
sudo apt-get install -y espeak-ng libespeak-ng-dev libsonic-dev libpcaudio-dev libopus-dev libssl-dev
546+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
547+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
548+
- name: Build kokoros
549+
run: |
550+
make -C backend/rust/kokoros kokoros-grpc
551+
- name: Test kokoros
552+
run: |
553+
make -C backend/rust/kokoros test

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "docs/themes/hugo-theme-relearn"]
22
path = docs/themes/hugo-theme-relearn
33
url = https://github.com/McShelby/hugo-theme-relearn.git
4+
[submodule "backend/rust/kokoros/sources/Kokoros"]
5+
path = backend/rust/kokoros/sources/Kokoros
6+
url = https://github.com/lucasjinreal/Kokoros

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Disable parallel execution for backend builds
2-
.NOTPARALLEL: backends/diffusers backends/llama-cpp backends/outetts backends/piper backends/stablediffusion-ggml backends/whisper backends/faster-whisper backends/silero-vad backends/local-store backends/huggingface backends/rfdetr backends/kitten-tts backends/kokoro backends/chatterbox backends/llama-cpp-darwin backends/neutts build-darwin-python-backend build-darwin-go-backend backends/mlx backends/diffuser-darwin backends/mlx-vlm backends/mlx-audio backends/mlx-distributed backends/stablediffusion-ggml-darwin backends/vllm backends/vllm-omni backends/moonshine backends/pocket-tts backends/qwen-tts backends/faster-qwen3-tts backends/qwen-asr backends/nemo backends/voxcpm backends/whisperx backends/ace-step backends/acestep-cpp backends/fish-speech backends/voxtral backends/opus backends/trl backends/llama-cpp-quantization
2+
.NOTPARALLEL: backends/diffusers backends/llama-cpp backends/outetts backends/piper backends/stablediffusion-ggml backends/whisper backends/faster-whisper backends/silero-vad backends/local-store backends/huggingface backends/rfdetr backends/kitten-tts backends/kokoro backends/chatterbox backends/llama-cpp-darwin backends/neutts build-darwin-python-backend build-darwin-go-backend backends/mlx backends/diffuser-darwin backends/mlx-vlm backends/mlx-audio backends/mlx-distributed backends/stablediffusion-ggml-darwin backends/vllm backends/vllm-omni backends/moonshine backends/pocket-tts backends/qwen-tts backends/faster-qwen3-tts backends/qwen-asr backends/nemo backends/voxcpm backends/whisperx backends/ace-step backends/acestep-cpp backends/fish-speech backends/voxtral backends/opus backends/trl backends/llama-cpp-quantization backends/kokoros
33

44
GOCMD=go
55
GOTEST=$(GOCMD) test
@@ -431,6 +431,7 @@ prepare-test-extra: protogen-python
431431
$(MAKE) -C backend/python/whisperx
432432
$(MAKE) -C backend/python/ace-step
433433
$(MAKE) -C backend/python/trl
434+
$(MAKE) -C backend/rust/kokoros kokoros-grpc
434435

435436
test-extra: prepare-test-extra
436437
$(MAKE) -C backend/python/transformers test
@@ -451,6 +452,7 @@ test-extra: prepare-test-extra
451452
$(MAKE) -C backend/python/whisperx test
452453
$(MAKE) -C backend/python/ace-step test
453454
$(MAKE) -C backend/python/trl test
455+
$(MAKE) -C backend/rust/kokoros test
454456

455457
DOCKER_IMAGE?=local-ai
456458
IMAGE_TYPE?=core
@@ -586,6 +588,9 @@ BACKEND_MLX_DISTRIBUTED = mlx-distributed|python|./|false|true
586588
BACKEND_TRL = trl|python|.|false|true
587589
BACKEND_LLAMA_CPP_QUANTIZATION = llama-cpp-quantization|python|.|false|true
588590

591+
# Rust backends
592+
BACKEND_KOKOROS = kokoros|rust|.|false|true
593+
589594
# Helper function to build docker image for a backend
590595
# Usage: $(call docker-build-backend,BACKEND_NAME,DOCKERFILE_TYPE,BUILD_CONTEXT,PROGRESS_FLAG,NEEDS_BACKEND_ARG)
591596
define docker-build-backend
@@ -644,12 +649,13 @@ $(eval $(call generate-docker-build-target,$(BACKEND_ACESTEP_CPP)))
644649
$(eval $(call generate-docker-build-target,$(BACKEND_MLX_DISTRIBUTED)))
645650
$(eval $(call generate-docker-build-target,$(BACKEND_TRL)))
646651
$(eval $(call generate-docker-build-target,$(BACKEND_LLAMA_CPP_QUANTIZATION)))
652+
$(eval $(call generate-docker-build-target,$(BACKEND_KOKOROS)))
647653

648654
# Pattern rule for docker-save targets
649655
docker-save-%: backend-images
650656
docker save local-ai-backend:$* -o backend-images/$*.tar
651657

652-
docker-build-backends: docker-build-llama-cpp docker-build-rerankers docker-build-vllm docker-build-vllm-omni docker-build-transformers docker-build-outetts docker-build-diffusers docker-build-kokoro docker-build-faster-whisper docker-build-coqui docker-build-chatterbox docker-build-vibevoice docker-build-moonshine docker-build-pocket-tts docker-build-qwen-tts docker-build-fish-speech docker-build-faster-qwen3-tts docker-build-qwen-asr docker-build-nemo docker-build-voxcpm docker-build-whisperx docker-build-ace-step docker-build-acestep-cpp docker-build-voxtral docker-build-mlx-distributed docker-build-trl docker-build-llama-cpp-quantization
658+
docker-build-backends: docker-build-llama-cpp docker-build-rerankers docker-build-vllm docker-build-vllm-omni docker-build-transformers docker-build-outetts docker-build-diffusers docker-build-kokoro docker-build-faster-whisper docker-build-coqui docker-build-chatterbox docker-build-vibevoice docker-build-moonshine docker-build-pocket-tts docker-build-qwen-tts docker-build-fish-speech docker-build-faster-qwen3-tts docker-build-qwen-asr docker-build-nemo docker-build-voxcpm docker-build-whisperx docker-build-ace-step docker-build-acestep-cpp docker-build-voxtral docker-build-mlx-distributed docker-build-trl docker-build-llama-cpp-quantization docker-build-kokoros
653659

654660
########################################################
655661
### Mock Backend for E2E Tests

backend/Dockerfile.rust

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ARG BASE_IMAGE=ubuntu:24.04
2+
3+
FROM ${BASE_IMAGE} AS builder
4+
ARG BACKEND=kokoros
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
ARG TARGETARCH
7+
ARG TARGETVARIANT
8+
9+
RUN apt-get update && \
10+
apt-get install -y --no-install-recommends \
11+
build-essential \
12+
git ccache \
13+
ca-certificates \
14+
make cmake wget \
15+
curl unzip \
16+
clang \
17+
pkg-config \
18+
libssl-dev \
19+
espeak-ng libespeak-ng-dev \
20+
libsonic-dev libpcaudio-dev \
21+
libopus-dev \
22+
protobuf-compiler && \
23+
apt-get clean && \
24+
rm -rf /var/lib/apt/lists/*
25+
26+
# Install Rust
27+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
28+
ENV PATH="/root/.cargo/bin:${PATH}"
29+
30+
COPY . /LocalAI
31+
32+
RUN git config --global --add safe.directory /LocalAI
33+
34+
RUN make -C /LocalAI/backend/rust/${BACKEND} build
35+
36+
FROM scratch
37+
ARG BACKEND=kokoros
38+
39+
COPY --from=builder /LocalAI/backend/rust/${BACKEND}/package/. ./

backend/index.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,26 @@
469469
nvidia-cuda-13: "cuda13-kokoro"
470470
nvidia-cuda-12: "cuda12-kokoro"
471471
nvidia-l4t-cuda-12: "nvidia-l4t-arm64-kokoro"
472+
- &kokoros
473+
icon: https://avatars.githubusercontent.com/u/166769057?v=4
474+
description: |
475+
Kokoros is a pure Rust TTS backend using the Kokoro ONNX model (82M parameters).
476+
It provides fast, high-quality text-to-speech with streaming support, built on
477+
ONNX Runtime for efficient CPU inference. Supports English, Japanese, Mandarin
478+
Chinese, and German.
479+
urls:
480+
- https://huggingface.co/hexgrad/Kokoro-82M
481+
- https://github.com/lucasjinreal/Kokoros
482+
tags:
483+
- text-to-speech
484+
- TTS
485+
- Rust
486+
- ONNX
487+
license: apache-2.0
488+
alias: "kokoros"
489+
name: "kokoros"
490+
capabilities:
491+
default: "cpu-kokoros"
472492
- &coqui
473493
urls:
474494
- https://github.com/idiap/coqui-ai-TTS
@@ -2043,6 +2063,21 @@
20432063
uri: "quay.io/go-skynet/local-ai-backends:master-metal-darwin-arm64-kokoro"
20442064
mirrors:
20452065
- localai/localai-backends:master-metal-darwin-arm64-kokoro
2066+
## kokoros (Rust)
2067+
- !!merge <<: *kokoros
2068+
name: "kokoros-development"
2069+
capabilities:
2070+
default: "cpu-kokoros-development"
2071+
- !!merge <<: *kokoros
2072+
name: "cpu-kokoros"
2073+
uri: "quay.io/go-skynet/local-ai-backends:latest-cpu-kokoros"
2074+
mirrors:
2075+
- localai/localai-backends:latest-cpu-kokoros
2076+
- !!merge <<: *kokoros
2077+
name: "cpu-kokoros-development"
2078+
uri: "quay.io/go-skynet/local-ai-backends:master-cpu-kokoros"
2079+
mirrors:
2080+
- localai/localai-backends:master-cpu-kokoros
20462081
## faster-whisper
20472082
- !!merge <<: *faster-whisper
20482083
name: "faster-whisper-development"

backend/rust/kokoros/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target/
2+
/proto/
3+
/package/

0 commit comments

Comments
 (0)