r/termux•
Brahmadeo

Kokoros (Kokoro-Rust) in Termux/PRoot

User content

I got Kokoro TTS working on my Android phone using Termux + PRoot Ubuntu. Sharing the setup in case anyone else wants to try.

Note: I'm using the Rust version (https://github.com/lucasjinreal/Kokoros), not the original Python one. It's faster and has a decent CLI.

##Prerequisites

  • Termux installed
  • PRoot distro (I used Ubuntu)

##The Build Process Getting this to compile was annoying. Here's what broke and how I fixed it:

###Issue 1: OpenSSL Missing

# Error: couldn't find OpenSSL
# Fix:
apt install libssl-dev pkg-config

###Issue 2: ONNX Runtime Download Failed The build tries to download ONNX Runtime automatically but it failed in PRoot (network issues).

Fix: I manually downloaded it in native Termux (which has network), then moved it:

# In Termux (not PRoot):
curl -L -o onnxruntime.tgz https://cdn.pyke.io/0/pyke:ort-rs/ms@1.22.0/aarch64-unknown-linux-gnu.tgz
tar -xzf onnxruntime.tgz

# Then in PRoot:
export ORT_LIB_LOCATION=/path/to/extracted/onnxruntime
export ORT_SKIP_DOWNLOAD=1

###Issue 3: espeak-ng Bindings

# Error: libclang not found
# Fix:
apt install clang libclang-dev espeak-ng libespeak-ng-dev

##Full Setup ###1. System packages:

apt update && apt upgrade -y
apt install git build-essential cmake \
    libssl-dev pkg-config \
    clang libclang-dev \
    espeak-ng libespeak-ng-dev \
    mpv \
    python3 python3-pip

###2. Install Rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

###3. Build Kokoros:

cd Kokoros

# If manual ONNX download was needed, set these first:
# export ORT_LIB_LOCATION=/path/to/onnxruntime
# export ORT_SKIP_DOWNLOAD=1

cargo build --release

The binary ends up at target/release/koko.

###4. Python dependencies: pip install soundfile numpy ebooklib beautifulsoup4

##Usage Basic test:

./target/release/koko --style af_heart t "Hello world" -o test.wav
mpv test.wav

I wrote a Python wrapper script that handles clipboard input and EPUB chapter conversion. It's in the original artifact if anyone wants it. ##Performance On my phone (Snapdragon), RTF is around 1.0-1.2, which means a 5-minute audio clip takes about 6 minutes to generate. Good enough for audiobook conversion. On my laptop with NVIDIA GPU, I built with --features cuda and RTF dropped to like 0.2-0.3. Way faster. ##Issues I Hit PRoot doesn't have network by default, so auto-downloads fail You need the exact ONNX Runtime version (1.22.0 for my Kokoros build) Without libclang-dev, the espeak bindings won't compile Temp files can eat up storage if generation fails mid-way That's about it.

Posted Dec 9, 2025, 9:57 AM UTC

81
Loading comments…