Views
No views yet
myshell-ai/MeloTTS-English converted to RKNN so the decoder runs on the
RK3588 NPU. Verified on a Radxa ROCK 5B+ serving live Home Assistant voice and a
web chat UI.decoder.rknn | 82 MB — runs on the NPU (fp16) |
encoder.onnx | 31 MB — runs on CPU (onnxruntime) |
decoder.onnx | 140 MB — CPU fallback / reference, optional |
g.bin, g0..g4.bin | 256-dim speaker embeddings, 1 KB each |
lexicon.txt, config.json | English frontend (219-symbol table) |
| sample rate | 44100 Hz |
| verified | rknn-toolkit2 2.3.0 → librknnrt 2.3.0, rknpu driver 0.9.8 |
g0..g4.bin are the five English speakers from the checkpoint: EN-US, EN-BR,
EN-India, EN-AU, EN-Default (g.bin is whichever you've selected). Extracted from
emb_g.weight — a 256 × 256 table, one row per speaker.tokens.txt. The EN checkpoint has extra punctuation at indices 1–6, so AA is
index 7, not 1 — reusing the ZH table shifts every phoneme ID and you get
gibberish. Build it from the shipped config.json:
symbol_to_id = {s: i for i, s in enumerate(config["symbols"])}3 from the Chinese runner is wrong.)bert-base-uncased over the normalised text and feed the
768-dim output into the ja_bert slot; leave the 1024-dim bert slot zeros.
Without BERT you get buzzing, and the upstream reference has BERT commented out —
which is why its own English sample buzzes too.noise_scale = 0.667 (with noise_scale_w = 0.8, sdp_ratio = 0.2).
noise_scale = 0 buzzes on voiced/stressed vowels. Missing BERT and zero noise
are two independent causes of buzz — fix both.re.split(r'(?<=[.!?;:])\s+', text)) and synthesize each
separately, concatenating with ~0.05 s of silence. Whole-utterance synthesis drifts:
it speeds up and gets louder toward the end.dec_len = 128 slices at word boundaries with overlap-trim and merge.melo_en.py here is a working implementation of all seven.1pip install rknn-toolkit-lite2 onnxruntime transformers soundfile numpy \
2 g2p_en inflect unidecode nltk
3python -c "import nltk; nltk.download('averaged_perceptron_tagger_eng'); nltk.download('cmudict')"
4
5python melo_en.py "Welcome home. Today the weather is sunny and warm." out.wavbert-base-uncased (~440 MB). For an offline deployment, pre-seed
the HF cache and set HF_HOME, HF_HUB_OFFLINE=1, TRANSFORMERS_OFFLINE=1, NLTK_DATA.import the RKNN runtime before transformers, note that
from rknnlite.api import RKNNLite corrupts Python's logging._nameToLevel, which
then makes transformers/torch fail with ValueError: Unknown level: 'WARNING'.
Restore it immediately after the import:1from rknnlite.api import RKNNLite
2import logging
3logging._nameToLevel.update({'CRITICAL':50,'ERROR':40,'WARN':30,'WARNING':30,
4 'INFO':20,'DEBUG':10,'NOTSET':0})1# 1. export ONNX from the English checkpoint (auto-downloads MeloTTS-English)
2git clone https://github.com/ml-inory/melotts.axera
3python melotts.axera/model_convert/convert.py -l EN # -> encoder-en.onnx, decoder-en.onnx
4
5# 2. decoder -> RKNN (fp16, no quantization)
6python convert_rknn.py # -> decoder.rknn
7
8# 3. speaker embedding: emb_g.weight[speaker_id] -> float32, reshape(1,256,1) -> g.bin
9python extract_g.pypython3 -m venv --without-pip then bootstrap pip if ensurepip is broken;
drop the bare MeCab==0.996.5 pin from requirements.txt (keep mecab_python3); install
setuptools<81 for librosa.bert and ja_bert inputs. Some RKNN runners drop them
— if you use such a runner you must feed zeros for both, which costs prosody. Feeding
real BERT into ja_bert (item 3 above) is what makes it sound right.| files | origin | licence |
|---|---|---|
melotts/, text/, english_utils/, utils.py | MeloTTS frontend, as packaged by ml-inory/melotts.axera | BSD-3-Clause (frontend derived from myshell-ai MeloTTS, MIT) |
melotts_rknn.py, convert_rknn.py | happyme531/MeloTTS-RKNN2 | AGPL-3.0 |
melo_en.py, extract_g.py, this README | ours | AGPL-3.0 (see below) |
text/cleaner.py and text/__init__.py were reduced to import just the English module.
Upstream imports every language at module load, which pulls in multilingual BERT
checkpoints — that breaks an offline deployment and wastes memory when you only need
English.convert_rknn.py, which
this build uses directly. This repo is AGPL-3.0 because of that, not by preference.model_convert/convert.py ONNX export that made the English path possible, and
the correct frontend/pipeline reference.happyme531/MeloTTS-RKNN2) is AGPL-3.0, so the distributed whole is AGPL-3.0. The
underlying MeloTTS model and weights are MIT (myshell-ai); the AGPL obligation comes
from the RKNN conversion/runtime code, not from the model. Full source of everything
required to rebuild is included here.