ZONOS3-Mini for LiteRT

This repository contains Zyphra/ZONOS3-Mini-hf, Zyphra's text-to-speech model, as three float32 LiteRT .tflite graphs for the CPU, with a prebuilt Android runner and a desktop Python script. On a Pixel 11 Pro's CPU, one prepared sentence of about 4 s took about 37 s from start to WAV, loading the graphs included. Speed still being tuned (updates follow).

On a Mac's CPU, the graphs gave the same audio codes as the publisher's PyTorch model in 60 of 60 test runs. On a Pixel 11 Pro and a Galaxy S26 (Snapdragon, SM8850), six prepared sentences gave the same codes as on the Mac in every frame.

On an Android phone, one command of the runner android/zonos_host speaks one of the six prepared sentences in kit/ to a WAV file (Use it). The runner takes no text, only these prepared inputs. An English sentence of your own goes through desktop/speak.py, which needs the publisher's files and which we ran on a Mac. On a GPU, the output was not shown to match: run the graphs on the CPU (Notes).

Use it

1. Download

pip install -U huggingface_hub
hf download litert-community/ZONOS3-Mini --local-dir ZONOS3-Mini
cd ZONOS3-Mini

The download is about 4.7 GB.

2. Speak a prepared sentence on an Android phone

You need an arm64 Android phone with USB debugging on, adb, and about 4.8 GB free on the phone, and the runner's peak memory on both phones was 3.54 GB.

adb shell mkdir -p /data/local/tmp/zonos3
adb push android graphs kit /data/local/tmp/zonos3/
adb shell "cd /data/local/tmp/zonos3 && chmod 755 android/zonos_host && LD_LIBRARY_PATH=android android/zonos_host kit s00 graphs/lm_step_p768.tflite graphs/codec_dec_f150.tflite out/s00"
adb pull /data/local/tmp/zonos3/out/s00/waveform.wav s00.wav

The runner speaks s00, the first prepared sentence. It writes three files into out/s00, which must not exist yet: waveform.wav (mono, 16-bit, 44.1 kHz), waveform.f32 (the same audio in float32) and codes.i32 (ten codes per frame). On standard error it prints TAKE s00 frames=62 samples=182280 wall_s=โ€ฆ, where wall_s is the time from its start to the written WAV. Replace s00 with s01 to s05 for the other sentences.

Every input the runner reads is prepared. kit/takes/s00/prompt.f32 contains the sentence and the voice Savannah as rows of 1,024 numbers, made in Python on a Mac, and draws.f32 contains the random draws for sampling. This release has no text front end for Android, so the runner speaks only these six sentences:

sentence text
s00 The quick brown fox jumps over the lazy dog near the riverbank.
s01 Please remember to bring an umbrella, because it might rain this afternoon.
s02 She opened the window and listened to the birds singing in the garden.
s03 The train leaves at 7:45 and arrives in Boston about 3 hours later.
s04 Thank you for calling. Your order has been shipped and will arrive soon.
s05 a Japanese sentence, written in kit/takes/s05/request.json

3. Speak your own English sentence on a Mac

This needs Python 3.12 and the publisher's files at commit e39d30df (2.39 GB: code, tokenizer, voices and weights).

hf download Zyphra/ZONOS3-Mini-hf --revision e39d30df560125d9c434acd5cb0e83e4c2d64e0d --local-dir ZONOS3-Mini-hf
python3.12 -m venv .venv
source .venv/bin/activate
pip install -r desktop/requirements.txt
MODEL=ZONOS3-Mini-hf
python -I -B desktop/speak.py "Please remember to bring an umbrella." --model "$MODEL" --graphs graphs --out umbrella

The script loads the publisher's model and code from $MODEL (with trust_remote_code) and runs the graphs with ai-edge-litert 2.3.0 on 4 CPU threads. It writes umbrella/speech.wav (mono, 16-bit, 44.1 kHz), umbrella/codes.npy, umbrella/waveform.npy and umbrella/run.json, and umbrella must not exist yet. It speaks English in the voice Savannah and samples with PyTorch's generator from --seed (1000 by default). With --speaker-wav <file.wav>, it takes the voice of a recording instead: the speaker graph reads only the first 10 s, where the publisher's model reads up to 60 s.

Files

file bytes what
graphs/lm_step_p768.tflite 3,342,543,296 the language model
graphs/codec_dec_f150.tflite 572,522,276 the decoder: audio codes in, spectral rows out
graphs/spk_enc_t998.tflite 45,122,316 the speaker encoder: a voice embedding from a recording, used by the desktop script only
android/zonos_host 7,139,128 the Android runner, built for arm64-v8a and Android API level 28; its C++ source is in host/ and include/
android/libLiteRt.so 5,629,696 LiteRT 2.3.0, the runtime library the runner loads (com.google.ai.edge.litert:litert:2.3.0 on Google Maven)
desktop/speak.py speaks an English sentence to a WAV file with Python; host.py, requirements.txt and README.md sit beside it
kit/ 768,008,027 in 59 files the prepared inputs: six sentences in kit/takes/, the tables they share in kit/shared/, and reference outputs
HOST.md how to rebuild the runner (Android NDK 29.0.13113456) and call it, and the files of kit/
NOTICE, licenses/ the publisher's notice and license texts, LiteRT's license and notices, and the Android NDK toolchain notice (License)

Notes

  • GPU. On a Mac's GPU, the language-model graph did not match the publisher's model in 910 of 910 steps, and the phones' GPUs were not tried.
  • Length. One call of the decoder graph speaks at most 150 frames (10 s, the three silence frames that open the speech included). Longer speech stops with BucketExceeded: split longer text and speak each part.
  • Positions. The prompt and the generated speech share 768 positions of the language-model graph. When they are used up, generation stops with CapacityReached.
  • Random draws. The prepared inputs carry their random draws, which is why both phones gave the same codes as the reference in kit/takes/<sentence>/reference/. For each of the six sentences, the WAV from both phones still differs from the reference WAV in 140 to 236 of its 16-bit samples (193 of 182,280 for s00), each by 1, because the phones' float32 audio differs from the reference by at most 3.44e-6 before rounding. An app supplies its own draws, and its codes then differ from the reference.
  • How the files were made. The three graphs were exported in float32 with litert-torch 0.10.0 from the publisher's weights at commit e39d30df.

License

The graphs and the tables in kit/ are derived from the publisher's weights, which the publisher releases under the Apache License 2.0 (NOTICE). The publisher's repository has no LICENSE file. Our own files in this repository are released under the Apache License 2.0, like the weights: the runner's source in host/, HOST.md and the scripts in desktop/.

NOTICE and the four texts in licenses/ that it names come unchanged from that repository at commit e39d30df: the MIT license of the original ZONOS3-Mini code and the licenses of the AntSpeaker, Hugging Face Transformers and torchaudio code that the publisher's model code adapts. android/libLiteRt.so is LiteRT 2.3.0 from Google Maven, with its license and third-party notices in licenses/LiteRT-LICENSE.txt and licenses/LiteRT-THIRD_PARTY_NOTICE.txt. The runner links the Android NDK's C++ runtime statically (notice: licenses/NDK-NOTICE.toolchain), and include/pocketfft.h carries its own BSD license.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for litert-community/ZONOS3-Mini

Quantized
(1)
this model