gpl-free-multilingual-g2p-onnx
A lightweight, GPL-free phonemizer for TTS
3 min readupdated
This model converts text in English, French, Spanish, and Japanese into IPA phonetic transcription — a required step before speech synthesis (G2P, grapheme-to-phoneme conversion). Created by Northlight as a direct replacement for the standard espeak-ng engine under a permissive Apache-2.0 commercial license, it uses no GPL or CC-BY-SA data. Inside are three compact INT8 ONNX models: a 4-layer Transformer encoder and decoder (d=384, h=6) for word transcription, and a 4-layer distilled ELECTRA-small model to disambiguate English homographs (words like read or lead that are spelled the same but pronounced differently depending on context). The entire bundle weighs 23.79 MiB and is fully compatible with the Kokoro-82M, Piper, and sherpa-onnx 2.0+ vocabularies.
Key features
- Legal compliance: Trained exclusively on dictionaries and corpora with BSD and Apache-2.0 licenses (CMUdict, CMUSphinx LIUM, OpenSLR SLR34, UniDic 2.1.2, WikipediaHomographData), without a single example from
espeak-ngor Wiktionary. - Compact size and speed: The weight of all three INT8 models combined with JSON tables is 24.95 MB. On two CPU threads, G2P takes ~3.6 ms per word, and homograph analysis takes ~1.2 ms per sentence.
- Browser and server execution: The ONNX format allows running the model locally on a CPU via
onnxruntimeor directly on the client side via WebAssembly (onnxruntime-web) without runtime dictionaries. - Precise integration with Kokoro-82M: The built-in
ipa_to_kokoro()mapper delivers 0.000% missed tokens for the 114-tokenhexgrad/Kokoro-82Mvocabulary.
What you can do
- Build a commercial TTS pipeline: Replace the GPL dependency
espeak-ngin combinations with Kokoro-82M, Piper, or sherpa-onnx 2.0+ for closed-source products. - Run speech synthesis in the browser: Embed the phonemizer into a client-side web application based on
kokoro-jsandonnxruntime-webwithout needing a backend for text preparation. - Improve complex English text reading: Fix pronunciation errors in 162 common English homographs (326 meanings) through whole-sentence analysis.
Example
import json, numpy as np, onnxruntime as ort
tok = json.load(open("g2p_tokenizer.json", encoding="utf-8"))
enc = ort.InferenceSession("onnx/g2p_encoder_int8.onnx", providers=["CPUExecutionProvider"])
dec = ort.InferenceSession("onnx/g2p_decoder_int8.onnx", providers=["CPUExecutionProvider"])
# Вход собирается из тега языка (, , , ) и символов/байтов UTF-8,
# после чего декодер авторегрессивно предсказывает токены IPA до EOS_ID.
Read more
DetailsBenchmarks: on English homographs, accuracy (Macro Acc) reaches 96.93% compared to 73.80% for
espeak-ng and 90.51% for misaki; on Japanese kana (strict-OOV), the PER error is 4.02% compared to 19.38% for espeak-ng.Hardware: runs on a regular CPU or in the browser via WebAssembly; GPU and VRAM are not required.
Limitations: only supports
en (US), fr, es (Latin American variant), and ja; German is not included. On unfamiliar Japanese kanji without an external dictionary, the PER is 15.53% (for texts rich in kanji, the authors recommend connecting UniDic / pyopenjtalk).









Comments