--- language: ja license: apache-2.0 pipeline_tag: text-to-speech library_name: eeh base_model: ctrltokyo/eeh-1 tags: - text-to-speech - japanese - rust - webassembly - tiny - looped-transformer - streaming --- # eeh-1-1 **A tiny Japanese voice that fits in a browser tab.** eeh is a Japanese text-to-speech model with two voices and 3.3 million parameters, waveform generator included. It reads kanji, numbers and Tokyo pitch accent, and runs on a CPU or fully inside a browser, with nothing sent anywhere. There is no neural vocoder. A transformer reads OpenJTalk's phonemes with their pitch-accent tones, predicts how long each one lasts, then predicts pitch, loudness and the settings of a small source-filter synthesizer, which makes the waveform from a pulse train and noise. It was trained from scratch on 18.6 hours of speech by [Irodori-TTS v4.1 Small Yomi](https://huggingface.co/takuma104/Irodori-TTS-v4.1-Small-Yomi). **What changed since [eeh-1](https://huggingface.co/ctrltokyo/eeh-1).** eeh-1-1 is eeh-1 with **looped** transformer stacks (shared weights, same depth) and **local attention** on the frame-level stacks, fine-tuned from eeh-1 for 20,000 steps. It has 26% fewer parameters, ships as 4.0 MB of int8 weights, streams audio within a sentence (first sound in about 3 ms on a CPU), and scores the same as or better than eeh-1 on every metric. | | | |---|---| | Parameters | 3,343,824 (eeh-1: 4,534,219) | | Weights | 4.0 MB int8 (`eeh.safetensors`), 13.4 MB float32 (`eeh-f32.safetensors`) | | Voices | F1 (female, late 20s, calm and clear), M1 (male, early 30s, warm), Tokyo Japanese | | Output | 24 kHz mono | | Input | Japanese text (kanji, kana, numbers), read with OpenJTalk | | Speed | 14 s sentence in 35 ms on one CPU thread (400x real time, Apple M4 Max, Accelerate); about 60x in a browser tab | | First sound | 3 ms for a short sentence, 11 ms for a 14 s one (one CPU thread, streamed); 13–50 ms in a browser | | Pretrained weights in the model | None (initialised from eeh-1, itself trained from scratch) | | License | Apache-2.0 | ## Samples | Text | F1 | M1 | |---|---|---| | こんにちは!これは、ノートパソコンでも動く小さな音声合成モデルです。 | | | | 会議は三月十四日の午後三時半に変わったので、あと四十五分ほどあります。 | | | | 本当に、あなたの誕生日を忘れると思ったの? | | | | 彼女は海を見たことがなかった。しばらくの間、何も言わずに波打ち際に立っていた。 | | | | 恐れ入りますが、お名前とご連絡先をこちらにご記入いただけますか。 | | | ## Files | Path | Contents | |---|---| | `eeh.safetensors` | Weights, int8 linear layers with a float32 scale per row (4.0 MB); the default | | `eeh-f32.safetensors` | The same weights in float32 (13.4 MB), e.g. for fine-tuning | | `eeh-dict.bin` | The Japanese dictionary the front end reads (36 MB) | | `python/` | Python wheels for macOS (arm64) and Linux (aarch64, x86_64) | | `bin//eeh` | Command-line program | | `lib//`, `include/eeh.h` | C library and header, for any language with a C FFI | | `demo/` | The browser demo: the whole engine compiled to WebAssembly, the weights and the dictionary | | `samples/` | The audio on this page | | `eval/report.json`, `eval/metrics.jsonl` | Evaluation report (int8 weights) and the fine-tuning log | | `looped.png` | The diagram below | | `LICENSE` | Apache-2.0 | ## Usage eeh runs on its own engine, written in Rust: a Japanese front end that reads text exactly as OpenJTalk does (identical on more than 500,000 test texts) and the model. The same engine is behind the Python package, the command-line program, the C library and the browser demo. Both weight files load the same way; int8 is dequantised at load, so speed is identical. ```bash hf download ctrltokyo/eeh-1-1 --local-dir eeh cd eeh ``` ### Python ```bash pip install python/eeh-0.2.0-py3-none-.whl ``` ```python import eeh, soundfile synth = eeh.Synthesizer("eeh.safetensors", "eeh-dict.bin") audio = synth.speak("こんにちは。今日はいい天気ですね。", voice="F1") # float32 array, 24 kHz soundfile.write("hello.wav", audio, synth.sample_rate) # Streaming within a sentence: chunks arrive as soon as their samples are final. synth.speak_stream("長い文章も、最初の音はすぐに届きます。", lambda text, chunk, index: play(chunk), voice="M1") ``` `speak` takes `voice` (`F1` or `M1`), `speed` (1.0), `pitch_shift` (0; 0.058 is about one semitone), `pitch_range` (1.0) and `seed`. `speak_stream(text, callback)` hands over chunks of audio (`first_frames=12`, then `chunk_frames=48`, 10.7 ms per frame); joined, they equal `speak`'s audio. `speak_each(text, callback)` hands over whole sentences. The package has no dependencies; it returns a NumPy array when NumPy is installed. The synthesizer can be shared between threads. ### Command line ```bash chmod +x bin/macos-arm64/eeh # the Hub does not keep the executable bit bin/macos-arm64/eeh speak --weights eeh.safetensors --dictionary eeh-dict.bin \ --voice M1 --text "こんにちは。今日はいい天気ですね。" --out hello.wav [--stream] ``` ### C and other languages `lib//libeeh_ffi` with `include/eeh.h`: `eeh_synthesizer_new` takes the weights and dictionary as bytes, `eeh_speak` returns the audio, `eeh_speak_each` streams it sentence by sentence and `eeh_speak_stream` chunk by chunk. Errors come back as status codes, never as crashes. Go, Node, Java, Ruby and Swift can call it through their C FFI (all five are tested). Text of any length works. It is split into sentences at 。!? and read one sentence at a time; a quote followed by と or って stays with its sentence, and a sentence too long for one call is cut after 、. A text without a final mark gets 。. The audio never peaks above 0.99. ### In a browser ```bash python -m http.server --directory demo 8000 ``` Then open `http://localhost:8000`. The engine runs in a Web Worker and plays audio chunk by chunk as it is made. The first visit downloads about 13 MB (gzip): 3.7 MB of weights, 9 MB of dictionary and 0.4 MB of program, all kept by the browser afterwards. ## How it works **Front end.** eeh's own Rust front end reads the text the way OpenJTalk does with the NAIST Japanese Dictionary: it splits it into words, picks each kanji's reading, expands numbers, joins words into accent phrases and assigns their accent types. It turns the result into tokens: - one token per phoneme (`k`, `sh`, `a`, `N` for ん, `cl` for っ); a long vowel is two tokens, one per mora; - devoiced vowels (the u of です, the i of した) are their own tokens `A I U E O`; - `` marks a boundary between accent phrases, and punctuation is kept; - each token carries the Tokyo pitch-accent tone of its mora, low or high, computed from the phrase's accent type and the mora's position. The 8,650 training sentences (11.8 hours of speech) are read in 0.29 s on one CPU thread (0.03 ms per sentence, about 150,000x real time), 5.5x faster than pyopenjtalk. The dictionary loads in 3 ms. **Model.** All blocks are pre-norm transformer blocks with 192 channels, 4 heads and rotary position embeddings. Their feed-forward is a depthwise convolution (kernel 7) followed by a GELU MLP (192 → 640 → 192). | Stage | Blocks stored / applied | Attention | Output | |---|---|---|---| | Text encoder | 3 / 4 (looped, 2 core passes) | global | token states | | Duration and pause predictor | conv | – | frames per token | | Frame transformer A | 2 / 2 | local, ±32 frames (±341 ms) | log F0, voicing, energy | | Frame transformer B | 3 / 5 (looped, 3 core passes) | local, ±16 frames (±171 ms) | synthesizer settings per frame | | Source-filter head | – | – | band-limited pulse train at F0 plus noise, each shaped by a per-frame filter (256 samples, 10.7 ms) | | Component | Parameters | eeh-1 | |---|---:|---:| | Embeddings (token, tone, voice) | 13,632 | 13,632 | | Text encoder | 1,192,130 | 1,588,864 | | Duration and pause predictor | 123,906 | 123,906 | | Frame transformer A, pitch/voicing/energy head | 795,971 | 795,971 | | Frame transformer B | 1,192,323 | 1,985,984 | | Source-filter waveform head | 25,862 | 25,862 | | Total | 3,343,824 | 4,534,219 | ## Looped stacks ![Looped stack: the prelude runs once, the core block runs three times with shared weights, the coda runs once](https://huggingface.co/ctrltokyo/eeh-1-1/resolve/main/looped.png) A looped stack stores *prelude → core → coda* and applies the core `L` times with tied weights. Depth (block applications) is unchanged from eeh-1; parameters are not. ``` h0 = prelude(x) h = h0 for k in 1..L: h = (h + e_k + tanh(g_k) · h0) ⊙ mask h = core(h) y = norm(coda(h)) ``` - **`e_k`** (`[L, 192]`): learned pass embedding, so the shared core can tell passes apart (a depth embedding, as in Universal Transformers). - **`tanh(g_k) · h0`**: learned scalar gate re-injecting the prelude output before every pass, which keeps later passes anchored to the input and keeps gradients short. - **Zero init**: `e_k = 0`, `g_k = 0`, so an untrained loop is exactly a repeated block. That makes branching from a non-looped checkpoint stable. - **Cost**: `L·192 + L` extra parameters per stack (386 for the encoder, 579 for B). In the Rust engine the core's packed weights are reused across passes while a tile of frames is in cache. | Stack | eeh-1 | eeh-1-1 | Mapping from eeh-1 | |---|---|---|---| | Text encoder | 4 blocks | prelude + core ×2 + coda | blocks 0, 1, 3 (2 dropped) | | Frame transformer B | 5 blocks | prelude + core ×3 + coda | blocks 0, 2, 4 (1, 3 dropped) | **Local attention and streaming.** Frame transformers A and B attend within a band (`|i − j| ≤ W`), computed as a band in `O(T·W)` time and memory instead of `O(T²)`. The receptive field of transformer B is 5 × (16 + 3) = 95 frames (about 1.0 s) each side, so the engine streams. It computes the encoder, durations and prosody for the whole sentence, then runs transformer B and the source-filter head as a wavefront over frames, emitting a chunk once its samples can no longer change. The first chunk is final after 95 + 12 frames are fed. Nothing is computed twice, and the joined chunks equal one-shot synthesis to within 1e-5. **Ablation.** All variants were branched from eeh-1 and fine-tuned for 20,000 steps under identical settings. Scores are on 300 validation clips and 16 novel sentences. | Variant | Params | Reading error | Accent | UTMOS | UTMOS, novel | |---|---:|---:|---:|---:|---:| | eeh-1 (no fine-tune) | 4.53M | 1.03% | 0.706 | 2.94 | 2.88 | | Pruned to 3.7M (blocks deleted) | 3.74M | 1.09% | 0.704 | 2.91 | 2.91 | | Looped B, global attention | 3.74M | 1.08% | 0.702 | 2.90 | 2.90 | | Looped B, local ±64/±32 | 3.74M | 1.10% | 0.705 | 3.00 | 3.04 | | Looped B, local ±32/±16 | 3.74M | 1.07% | 0.700 | 2.99 | 3.04 | | Looped encoder + B, ±64/±32 | 3.34M | 1.10% | 0.702 | 2.98 | 2.99 | | **Looped encoder + B, ±32/±16 (eeh-1-1)** | **3.34M** | 1.12% | 0.703 | 2.99 | 2.98 | At equal size, looping matches deleting blocks. Local attention adds about 0.09 UTMOS on validation and 0.14 on novel sentences. Looping the encoder removes 0.4M more parameters with no measurable loss. Training for 40,000 steps instead of 20,000 did not help (validation loss flat from step 116,000). **int8 weights.** Each 2-D linear weight (33 matrices, about 90% of the parameters) is quantised symmetrically per output row (`q = round(w / s)`, `s = max|w_row| / 127`) and stored as I8 plus an F32 scale; everything else stays float32. The engine dequantises at load (about 1 ms). Durations match float32 exactly. The mean log-mel difference from float32 is 0.17–0.20, and every evaluation score is within ±0.004 on accent and ±0.03 on UTMOS (see below). ## Training data The speech is synthetic. Two voices were designed once from Japanese descriptions with Irodori-TTS v4.1 Small (`落ち着いた20代後半の女性。明瞭で自然な東京の話し言葉。` and `30代前半の男性。温かく親しみやすい、自然な東京の話し言葉。`), then every sentence was read by [Irodori-TTS v4.1 Small Yomi](https://huggingface.co/takuma104/Irodori-TTS-v4.1-Small-Yomi) (MIT) cloning those two references. No recording of a real speaker is involved. On the 300 test sentences in both voices, the teacher's speech has 1.2% kana reading error, 0.69 pitch-accent agreement and a UTMOS of 3.38. The 8,650 sentences (8,000 train, 350 validation, 300 test, split by sentence) were chosen to cover as many morae and mora pairs as possible; 25% are questions and 10% exclamations. Every clip was screened before training: - **Reading.** [kana-whisper](https://huggingface.co/sbintuitions/kana-whisper) transcribed it to katakana, compared with OpenJTalk's reading; more than 10% kana error was rejected. - **Alignment.** Phoneme durations come from forced alignment with `facebook/wav2vec2-lv-60-espeak-cv-ft`, used only to label the data. Its labels were recalibrated on the teacher's audio, and clips it aligned with low confidence were rejected. - **Speaking rate and length.** | | Clips | Hours | |---|---:|---:| | Generated (sentences x voices) | 17,300 | | | Passed screening | 15,684 | | | Used for training (F1 7,301, M1 6,783) | 14,084 | 18.6 | | Validation / test | 614 / 527 | 1.3 / 1.0 | ## Training | | eeh-1 (from scratch) | eeh-1-1 (fine-tune) | |---|---|---| | Steps | 0 → 104,000 | 104,000 → 124,000 | | Initialisation | random | eeh-1 blocks mapped as above; zero-init loop parameters; fresh optimizer | | Batches | about 9,000 frames (96 s of audio) per step | same | | Losses | Multi-resolution spectral losses; adversarial loss with multi-period and multi-resolution discriminators after step 8,000 | same, adversarial throughout | | Hardware | One NVIDIA GB10 (Lenovo ThinkStation PGX) | One NVIDIA H100 | | Time | 11.5 hours | 46 minutes (7.2 steps/s) | The adversarial step computes the discriminators' gradient at the waveform once instead of twice, and runs their convolutions in bfloat16 with autotuned kernels on batches padded to a few fixed shapes. That is twice as fast, with the same gradients. ## Evaluation Speech from the released weights was scored the same way as the teacher's recordings of the same sentences. kana-whisper transcribes it to katakana (reading error against OpenJTalk's reading), a pitch tracker checks each expected rise and fall of the pitch accent, and UTMOS rates naturalness. The spectral distance is the mean log-mel distance from the teacher's recording after DTW. | Sentences | Clips | Model | Reading error | Pitch-accent agreement | UTMOS | Spectral distance | |---|---:|---|---:|---:|---:|---:| | Test | 300 | eeh-1-1 int8 | **0.82%** | 0.705 | **2.97** | **0.662** | | | | eeh-1-1 float32 | 0.84% | **0.710** | **2.97** | **0.662** | | | | eeh-1 | 0.84% | 0.696 | 2.94 | 0.671 | | | | teacher | 1.23% | 0.692 | 3.38 | | | Validation | 300 | eeh-1-1 int8 | 1.11% | 0.703 | 2.98 | 0.701 | | | | eeh-1-1 float32 | 1.12% | 0.703 | 2.99 | 0.701 | | | | eeh-1 | 1.03% | 0.706 | 2.94 | 0.708 | | | | teacher | 1.70% | 0.677 | 3.34 | | | New sentences, not in the dataset | 16 | eeh-1-1 int8 | 0.0% | 0.702 | 3.01 | | | | | eeh-1 | 0.0% | 0.689 | 2.88 | | eeh-1-1 reads and accents as well as the teacher it learned from. It sounds less natural than the teacher (UTMOS about 0.4 lower), which is the cost of the small synthesizer. Differences from eeh-1 are within noise on reading and accent and slightly favour eeh-1-1 on UTMOS and spectral distance. No formal listening test has been run; informal side-by-side listening found eeh-1, eeh-1-1 and the other variants indistinguishable. **Speed** (Apple M4 Max, one thread, Rust engine): | | eeh-1 | eeh-1-1 | |---|---:|---:| | 14 s sentence, portable build | 195 ms | 99 ms | | 14 s sentence, Accelerate | 55 ms | 35 ms | | First sound, 14 s sentence (Accelerate, streamed) | 55 ms | 11 ms | | First sound, 3 s sentence (Accelerate, streamed) | 7.4 ms | 3.0 ms | | Browser tab (Chromium), real time | about 50x | about 60x | The gain grows with sentence length: attention cost is linear in the band width instead of quadratic. On short sentences throughput is the same as eeh-1, and the gain is in first sound. ## Limitations - Japanese only, two fixed voices, no voice cloning. - Readings come from OpenJTalk's dictionary. Rare kanji readings, names and new words can be read wrong, and the accent of compound phrases is predicted by rules. Whatever OpenJTalk gets wrong, eeh says wrong. - Latin letters are spelled out one by one (`eeh` is read イー・イー・エイチ). - The same text is always read the same way. - Prosody (frame transformer A) is computed for the whole sentence before the first chunk, so first sound grows slowly with sentence length (11 ms for a 14 s sentence on one thread). - The training data is synthetic, so eeh cannot sound more natural than the teacher; the small source-filter synthesizer sounds more buzzy than it. ## License Apache-2.0 for the weights and code. ## Citation ```bibtex @software{nicholson2026eeh, author = {Nicholson, Alexander}, title = {eeh: a 3.3M-parameter two-voice Japanese text-to-speech model}, year = {2026}, url = {https://huggingface.co/ctrltokyo/eeh-1-1} } ``` ## Acknowledgements Inspired by [tiny-voca](https://github.com/n4ze3m/tiny-voca), trained on speech from [Irodori-TTS](https://github.com/Aratako/Irodori-TTS), and reading Japanese with [OpenJTalk](https://open-jtalk.sourceforge.net/).