Kokoro-82M v1.1-zh for RK3588: Mandarin and English speech synthesis

Compiled models (.rnpu) for the Rockchip RK3588 / RK3588S NPU, ready to load: no PyTorch, no ONNX export, no compiler run on your side. Five fp16 graphs for the own NPU stack of RCDL, a C++17 / Python library for vision and speech on these boards. RCDL's compiler built them from ONNX, and its runtime runs them by driving the board's rknpu kernel driver directly, so librknnrt and rknn-toolkit2 are not needed (how the stack works). They need RCDL 0.3.1 or newer.

Mandarin or English text goes in and 24 kHz speech comes out, all on the board, in one pass per sentence: no sampling loop, no separate vocoder, no espeak-ng. Upstream: Kokoro-82M v1.1-zh by hexgrad, with three of its voices.

Redistributable, including commercially. Kokoro-82M v1.1-zh is Apache-2.0 on the code and the weights. The lexicons are built from MIT, Apache-2.0 and BSD-2-Clause sources and public-domain books; their notices are in THIRD_PARTY_NOTICES.md. See Licence.

Files

file what it is size
kokoro_text_l128_fp16.rnpu text side: up to 128 symbols → each token's duration and the encodings 67.7 MB
kokoro_f0n_t256_fp16.rnpu, kokoro_f0n_t512_fp16.rnpu pitch and energy for up to 256 / 512 frames of 25 ms (6.4 s / 12.8 s) 19.9 MB each
kokoro_dec_t256_fp16.rnpu, kokoro_dec_t512_fp16.rnpu decoder and generator, 256 / 512 frames → magnitudes and phases for the inverse STFT 106.5 / 106.7 MB
kokoro_source.npy weights of the harmonic source, which the CPU makes from the pitch < 0.1 MB
kokoro_tokens.json the model's symbol table < 0.1 MB
kokoro_lexicon_zh.txt Mandarin lexicon: jieba's words with their pinyin 11.1 MB
kokoro_lexicon_en.txt English lexicon (optional): misaki's US dictionaries, CMUdict for the names they lack, readings by context 12.4 MB
kokoro_voice_zf_001.npy, kokoro_voice_zm_010.npy Mandarin voices: each a [510, 256] table, one row per phoneme count 0.5 MB each
kokoro_voice_af_maple.npy English voice af_maple 0.5 MB
THIRD_PARTY_NOTICES.md where each file comes from, and the licences

A sentence runs on the shorter pitch / decoder pair that holds it. Between the graphs the CPU rounds the durations to frames, makes the harmonic source and runs the inverse STFT. The front end (KokoroFrontend) rebuilds misaki's Mandarin G2P, version 1.1, which Kokoro was trained on: the text is cut into words over jieba's dictionary, then misaki's tone sandhi and erhua apply. With the English lexicon it reads English as misaki's English G2P does, without its spaCy tagger.

Measured on RK3588S and RK3588

RK3588S RK3588
an English sentence → 5.6 s of speech (voice af_maple) 2.50 s (real-time factor 0.44) 2.48 s
that speech, transcribed on the board by Moonshine 0 of 12 words wrong the same
a Mandarin sentence (voice zf_001), transcribed by SenseVoice 0 of 14 characters wrong the same

RCDL 0.3.0 conda packages, RCDL's own NPU runtime, one NPU core, NPU driver 0.9.8; BSP kernel 6.1.118 on the RK3588S, 6.1.141 on the RK3588. The CPU governor was performance, with the process pinned to the four A76 cores. Under the boards' default schedutil, tasks that alternate NPU and CPU work measured up to about four times slower, with the same results. On an RK3588, a 4.3 s sentence takes 1.3 s on one NPU core and 0.94 s on all three.

Against the PyTorch model on the same phonemes, 99.1% of the tokens get the same number of frames (none is more than one off), and the log-mel spectra are 0.23 apart after alignment. Speech recognition hears the two alike: 0.93% of characters wrong in either (SenseVoice), 1.04% of words (Moonshine).

Against misaki itself, the front end differs in 1.6% of the symbols on 230 Mandarin sentences. On 120 English ones it differs from misaki with espeak-ng in 4.6%: none in the 20 everyday sentences, the rest in the 100 from Wikipedia. Read back by Moonshine, 8.0% of those words come out wrong against 6.9% from misaki's symbols, the difference being names.

Use it

On the board (linux-aarch64):

conda create -n rcdl -c https://mirrors.ruis.ai/conda -c conda-forge rcdl
conda activate rcdl
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_text_l128_fp16.rnpu
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_f0n_t256_fp16.rnpu
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_f0n_t512_fp16.rnpu
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_dec_t256_fp16.rnpu
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_dec_t512_fp16.rnpu
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_source.npy
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_tokens.json
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_lexicon_zh.txt
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_lexicon_en.txt
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_voice_zf_001.npy
curl -LO https://huggingface.co/ruisv/rcdl-kokoro/resolve/main/kokoro_voice_af_maple.npy
import wave, numpy as np, rcdl

tts = rcdl.KokoroTts.from_files(
    "kokoro_text_l128_fp16.rnpu",
    ["kokoro_f0n_t256_fp16.rnpu", "kokoro_f0n_t512_fp16.rnpu"],
    ["kokoro_dec_t256_fp16.rnpu", "kokoro_dec_t512_fp16.rnpu"],
    "kokoro_source.npy", "kokoro_tokens.json",
    "kokoro_lexicon_zh.txt", "kokoro_voice_zf_001.npy",
    lexicon_en="kokoro_lexicon_en.txt")              # optional: English
zh = tts.synthesize("今天天气很好,我们去公园散步吧。")
tts.set_voice("kokoro_voice_af_maple.npy")
en = tts.synthesize("The weather is lovely today. Let's meet by the library this afternoon.")

sr = zh.sample_rate                                  # 24000
pcm = np.concatenate([np.asarray(zh.pcm), np.zeros(sr // 2, np.float32), np.asarray(en.pcm)])
with wave.open("out.wav", "wb") as w:
    w.setnchannels(1); w.setsampwidth(2); w.setframerate(sr)
    w.writeframes((np.clip(pcm, -1, 1) * 32767).astype(np.int16).tobytes())
print(f"{len(pcm) / sr:.1f} s of speech at {sr} Hz in {zh.chunks + en.chunks} chunks -> out.wav")

kokoro_voice_zm_010.npy is the second Mandarin voice: download it the same way and switch with tts.set_voice("kokoro_voice_zm_010.npy").

What to know before deploying

English needs the English lexicon (31 MB of memory). Without it, Latin words are left out, as the model's own Mandarin pipeline does; with it, text without Chinese is read as English, and so are Latin words inside Mandarin. A word in no dictionary is read as the words it is made of, else letter by letter: misaki would hand it to espeak-ng (GPL), which RCDL neither ships nor links. A word read by its use (live, read, use, that) takes the reading its neighbours pick; on held-out books, 97.6% of such words read as misaki reads them.

Long text is cut for you. One chunk holds up to 128 tokens, two of them the boundaries, and up to 512 frames (12.8 s). The text is cut at sentences, then at commas, then at words. A chunk that would pass 512 frames is read in two halves, cut at a word. The result's chunks says how many there were.

Voice, speed, cores. scripts/kokoro_export.py --voices writes any other of the model's voices. rcdl.KokoroConfig has speed (above 1 is faster) and seed (0 turns the harmonic source's noise off: deterministic, quieter consonants); pass it as tts.synthesize(text, config). Every build runs on one NPU core by default; rcdl.KokoroAcoustic also takes opened engines, such as rcdl.Engine(path, core=rcdl.NpuCore.ALL) for all three.

Licence

Apache-2.0, on the Kokoro-82M v1.1-zh code and weights, from which the five builds, kokoro_source.npy, kokoro_tokens.json and the voices are made. As the model card says, its Mandarin voices come from a professional dataset its owner granted, and its English voices are synthetic.

The lexicons are RCDL's, written by scripts/kokoro_lexicon.py from jieba's dictionary, pypinyin and pypinyin-dict (MIT), misaki's rules and US dictionaries (Apache-2.0), the CMU Pronouncing Dictionary (BSD-2-Clause) and readings counted from ten public-domain books. Which file draws on which, and the notices, are in THIRD_PARTY_NOTICES.md; keep it with the lexicons when you pass them on.

RCDL itself is Apache-2.0 and is unrelated to these terms. It is a general-purpose runtime that loads any .rnpu or .rknn. The licences above apply to these weights and these files only.

scripts/kokoro_export.py writes the ONNX graphs and the voices, and the compiler flags of each build are beside it in scripts/fetch_models.sh. The input contract of every model is in docs/MODELS.md.

中文说明

这是 Kokoro-82M v1.1-zh 面向瑞芯微 RK3588 / RK3588S NPU 的编译模型(.rnpu), 下载即可加载:不需要 PyTorch,不用导出 ONNX,也不用自己跑编译器。五个 fp16 计算图是为 RCDL 的自研 NPU 栈编译的:RCDL 的编译器从 ONNX 生成它们,RCDL 的运行时直接驱动板子上的 rknpu 内核驱动来执行,不需要 librknnrt,也不需要 rknn-toolkit2(自研栈介绍)。 需要 RCDL 0.3.1 或更新版本。

输入普通话或英文文本,输出 24 kHz 语音,全程在板上完成。每句话只跑一遍,没有采样循环, 也没有单独的声码器。文本前端是 RCDL 自己实现的,不依赖 espeak-ng。上游模型是 hexgrad 的 Kokoro-82M v1.1-zh,这里带了它的三个音色。

可以再分发,包括商用。 Kokoro-82M v1.1-zh 的代码和权重都是 Apache-2.0。发音词典 取材于 MIT、Apache-2.0、BSD-2-Clause 许可的来源和公有领域书籍,相应声明见 THIRD_PARTY_NOTICES.md。

文件

文件 内容 大小
kokoro_text_l128_fp16.rnpu 文本侧:最多 128 个符号 → 每个 token 的时长和编码 67.7 MB
kokoro_f0n_t256_fp16.rnpu / kokoro_f0n_t512_fp16.rnpu 音高与能量,最多 256 / 512 帧(每帧 25 ms,即 6.4 s / 12.8 s) 各 19.9 MB
kokoro_dec_t256_fp16.rnpu / kokoro_dec_t512_fp16.rnpu 解码器与生成器,输出逆 STFT 用的幅度和相位 106.5 / 106.7 MB
kokoro_source.npy 谐波源的权重(CPU 据预测的音高生成谐波源) < 0.1 MB
kokoro_tokens.json 模型的符号表 < 0.1 MB
kokoro_lexicon_zh.txt 普通话词典:jieba 的词及其拼音 11.1 MB
kokoro_lexicon_en.txt 英文词典(可选):misaki 的美式词典、补上其中缺少的名称的 CMUdict、按上下文定读音的表 12.4 MB
kokoro_voice_zf_001.npy、kokoro_voice_zm_010.npy 两个普通话音色,各是 [510, 256] 的表,每种音素数一行 各 0.5 MB
kokoro_voice_af_maple.npy 英文音色 0.5 MB
THIRD_PARTY_NOTICES.md 各文件的来源与许可

一句话在能容纳它的较短那一对(音高 / 解码器)上运行。计算图之间由 CPU 把时长取整成帧数、 生成谐波源、做逆 STFT。前端(KokoroFrontend)重新实现了 Kokoro 训练时所用的 misaki 普通话 G2P(1.1 版):先按 jieba 词典切词,再做 misaki 的变调和儿化;配上英文词典后,按 misaki 英文 G2P 的方式读英文,但不用它的 spaCy 标注器。

实测

  • 一句英文合成 5.6 s 语音(音色 af_maple):RK3588S 上 2.50 s(实时率 0.44),RK3588 上 2.48 s;在板上用 Moonshine 识别回来,12 个词错 0 个。
  • 一句普通话(音色 zf_001)用 SenseVoice 识别回来,14 个字错 0 个。两块板结果相同。
  • 测量条件:RCDL 0.3.0 的 conda 包,自研 NPU 运行时,单个 NPU 核,NPU 驱动 0.9.8; RK3588S 为 BSP 内核 6.1.118,RK3588 为 6.1.141。CPU 调频策略为 performance,进程绑在 四个 A76 核上;在板子默认的 schedutil 下,NPU 与 CPU 交替工作的任务最多会慢到约四倍, 结果不变。在 RK3588 上,一句 4.3 s 的话单核 1.3 s 合成完,三核 0.94 s。
  • 与 PyTorch 模型在相同音素上对比:99.1% 的 token 帧数相同(没有一个相差超过一帧), 对齐后 log-mel 谱相差 0.23;语音识别听两者也一样(SenseVoice 字错误率都是 0.93%, Moonshine 词错误率都是 1.04%)。
  • 前端与 misaki 本身对比:230 句普通话中 1.6% 的符号不同;120 句英文(20 句日常用语, 100 句取自 Wikipedia)中 4.6% 的符号与带 espeak-ng 的 misaki 不同,日常用语完全相同; 用 Moonshine 识别回来,词错误率 8.0%,用 misaki 的符号合成的为 6.9%,差别出在名称上。

用法

用法见上面的代码:两条命令装好 RCDL、下载文件,Python 里先合成一句普通话,再切换到英文音色 合成一句英文,写到 24 kHz 的 out.wav。第二个普通话音色 kokoro_voice_zm_010.npy 照样下载, 用 tts.set_voice(...) 切换。

部署前须知

  • 读英文要有英文词典。 不传 lexicon_en 时,拉丁字母单词会被略去,与模型自带的普通话 流程一样;传了以后,不含汉字的文本按英文读,普通话里夹的英文单词也按英文读。英文词典占用 31 MB 内存。
  • 词典里没有的词,按组成它的词来读,否则逐个字母读。 misaki 把这类词交给 espeak-ng (GPL),RCDL 既不随附也不链接它。live、read、use、that 这类按用法定读音的词,由相邻的词 决定读音,依据是从十本公有领域书籍统计出的表;在未参与建表的书上,97.6% 读得与 misaki 相同。
  • 长文本会自动切分。 一段最多 128 个 token(含首尾两个边界)、512 帧(12.8 s)。先按句子切, 再按逗号,再按词;超过 512 帧的一段从词边界处一分为二。结果里的 chunks 是段数。
  • 音色与语速。 tts.set_voice(path) 切换音色,scripts/kokoro_export.py --voices 可导出模型的 其他音色。rcdl.KokoroConfig 有 speed(大于 1 更快)和 seed;seed = 0 关掉谐波源的噪声, 输出确定,辅音会轻一些。
  • 默认单个 NPU 核。 rcdl.KokoroAcoustic 也接受已打开的 Engine,用 rcdl.Engine(path, core=rcdl.NpuCore.ALL) 可把一个构建分到三个核上。

许可

Kokoro-82M v1.1-zh 的代码和权重为 Apache-2.0,五个构建、kokoro_source.npy、 kokoro_tokens.json 和音色文件都由它生成。按模型卡的说法,普通话音色来自所有者授权的专业 数据集,英文音色是合成的。发音词典是 RCDL 用 scripts/kokoro_lexicon.py 生成的:普通话词典 取材于 jieba 词典、pypinyin 与 pypinyin-dict 的读音(MIT)以及 misaki(PaddleSpeech)的合并、 变调和儿化规则(Apache-2.0);英文词典取材于 misaki 的美式词典(Apache-2.0)、CMU Pronouncing Dictionary(BSD-2-Clause,声明也在文件开头)和从十本公有领域书籍统计出的读音表。 声明全文见 THIRD_PARTY_NOTICES.md,转发词典时请一并带上。

RCDL 本身是 Apache-2.0,与上述条款无关。 它是通用运行时,能加载任何 .rnpu 或 .rknn;上述许可只适用于这些权重和这些文件。

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ruisv/rcdl-kokoro

Finetuned
(3)
this model