# nanori-eval: judge and scoring pipeline for Nanori **Nanori** (名乗り, "how a name is announced") is a benchmark for one question: does a text-to-speech (TTS) system read Japanese proper nouns the way they are officially read? Each item is one natural Japanese sentence with one target name. This package is the `eval/` folder of the dataset repository [`fishaudio/nanori`](https://huggingface.co/datasets/fishaudio/nanori), next to the item tables and `known_wrong/`, the published results (`results/`) and the calibration reports (`calibration/`). | subset (config) | items | strata | headline | |---|---:|---|---| | Nanori-Places (`places`, `JA-PLACE`) | 400 | P-H hard (150), P-R regular (60), P-U hard, second sample from another pool (150), ADDR addresses (40) | P-H + P-R, weighted by population / station ridership (Kish n_eff 95.4) | | Nanori-Drugs (`drugs`, `JA-DRUG`) | 227 | D-E listed before 2026 (120), D-N newly listed in 2026 (107) | D-E and D-N separately, never pooled | | Nanori-Companies (`companies`, `JA-COMPANY`) | 150 | hard (100), regular (50), by script (kanji / kana / Latin) | all 150, with hard 100 beside it | This package scores a TTS system on Nanori exactly the way the published leaderboard was scored: 1. **synthesize** each sentence once (adapters for Fish Audio, ElevenLabs and Cartesia, or bring a folder of WAVs); 2. **judge** each clip with the frozen **Gemini two-step judge** (G), the **kana-whisper span judge** (KW) and the **kana CTC forced-choice judge** (CTC); 3. **combine** them with the official rule **R2**; 4. **score**: pass rates per subset and stratum, the weighted Places headline, unscored rates and paired bootstrap confidence intervals (CI) between systems, as JSON and a markdown leaderboard. No human listens at any step. Abbreviations: TTS = text-to-speech; G = Gemini two-step judge; KW = kana-whisper span judge; CTC = connectionist temporal classification (a frame-level speech recognizer, used here as a forced choice between readings); R2 = the official combined rule; FP / FF = false pass / false fail; CP = Clopper-Pearson (exact binomial) bound; CI = confidence interval; pt = percentage points; n_eff = Kish effective sample size; ZDR = zero data retention; HF = Hugging Face. ## Install ```bash git clone https://huggingface.co/datasets/fishaudio/nanori # items + results + this package (Parquet files via git-lfs) # or: hf download fishaudio/nanori --repo-type dataset --local-dir nanori cd nanori/eval pip install -e . # core: synthesis adapters, Gemini judge, combine, score (numpy only) pip install -e '.[hf]' # load the dataset from the Hugging Face Hub (datasets, pyarrow) pip install -e '.[kw]' # kana-whisper judge: torch, transformers, diff-match-patch, regex, editdistance pip install -e '.[ctc]' # kana CTC judge: torch, transformers, huggingface_hub, librosa, soundfile, pyopenjtalk 0.4.1 git clone https://github.com/sbintuitions/Joyo-Kanji-Yomi-Benchmark joyo && git -C joyo checkout 6a79976c nanori-eval fetch-models # downloads the CTC model by id + revision and checks its sha256 (about 1.3 GB) ``` The CTC model, `vumichien/wav2vec2-large-xlsr-japanese-hiragana`, is a public model by Chien Vu (Apache-2.0 per its model card). nanori-eval downloads it from the Hugging Face Hub at revision `017225bb` and checks the sha256 of each of the four files it loads (`constants.CTC_MODEL`); it never re-hosts the weights. The model was fine-tuned on Common Voice Japanese and on JSUT, whose audio terms allow only non-commercial research and personal use. Read the JSUT terms before you use the judge commercially. `--ctc-dir DIR` uses a directory you downloaded yourself (the same checks apply). If `editdistance` does not build on your Python, the package substitutes a pure-Python Levenshtein distance with the same result. ## Data `--data` takes the dataset id `fishaudio/nanori`, the dataset directory, or `.jsonl` / `.parquet` files. The known-wrong readings are a separate config (`known_wrong`); the judges need them (Gemini step 2 and the CTC forced choice), so the loader joins them to the items by `id`. The dataset id and the dataset directory include them; when you pass single files, pass `known_wrong/*.parquet` as well. `nanori-eval items --data fishaudio/nanori` checks a dataset. In a local copy of the repository, the dataset directory is the folder that holds `eval/` (`..` from inside it). | column | meaning | |---|---| | `id`, `subset` (`JA-PLACE` / `JA-DRUG` / `JA-COMPANY`), `stratum` | item id, subset, stratum (e.g. `P-H/F2`, `D-E/kampo`, `hard:kanji`) | | `text` | the sentence, sent to the TTS system byte for byte | | `span_start`, `span_end`, `surface` | the target name in `text` | | `key_kana`, `accepted` | the key reading and every accepted reading (katakana) | | `known_wrong` (config `known_wrong`) | the listed wrong readings | | `headline_weight` | Places P-H / P-R only: population or ridership weight for the headline | | `kw_ref` | the frozen kana-whisper reference (built with pyopenjtalk 0.4.1) | ## Usage ```bash D=fishaudio/nanori # 1. synthesize (keys from FISH_API_KEY / ELEVENLABS_API_KEY / CARTESIA_API_KEY; never logged) nanori-eval synth --data $D --adapter cartesia --system mysys --out audio/mysys # or use your own WAVs laid out as //.wav (16-bit PCM, any rate, mono or stereo): nanori-eval manifest --data $D --audio-dir my_wavs --system mysys --out audio/mysys/manifest.jsonl # 2a. Gemini two-step judge, K = 3 (OPENROUTER_API_KEY; or --provider google with GEMINI_API_KEY, # or --provider vertex --project P with gcloud credentials / VERTEX_ACCESS_TOKEN) nanori-eval judge-gemini --data $D --manifest audio/mysys/manifest.jsonl --run-dir runs/mysys/gemini --max-usd 45 # 2b. kana-whisper span judge (CPU fp32 = the calibrated configuration) nanori-eval judge-kw --data $D --manifest audio/mysys/manifest.jsonl --run-dir runs/mysys/kw --toolkit joyo # 2c. kana CTC judge (CPU fp32, 8 threads; --shard i --nshards n to split the work) nanori-eval judge-ctc --data $D --manifest audio/mysys/manifest.jsonl --run-dir runs/mysys/ctc # 3. combine with the official rule R2 (G, KW and CTC are kept per row) nanori-eval combine --data $D --manifest audio/mysys/manifest.jsonl --gemini-raw runs/mysys/gemini/raw.jsonl \ --kw runs/mysys/kw/kw.jsonl --ctc runs/mysys/ctc --out runs/mysys/verdicts.jsonl # 4. score one or more systems (pairs default to every pair in --system order) nanori-eval score --data $D --system "mysys:My TTS=runs/mysys/verdicts.jsonl" \ --system "other:Other TTS=runs/other/verdicts.jsonl" --out-dir results ``` `score` writes `leaderboard.json` (every cell, judge, system and pair, 4 decimals), `LEADERBOARD.md` (headline cells) and `RESULTS_FULL.md` (every cell); the markdown values are rounded once (0.1 pt, half up) from the exact pass / scored counts (weighted headline: exact weighted sums) and the unrounded CIs. `--placeholder "key:Column label=text"` adds a column for a system not scored yet. The judge runs resume: rerunning a command skips clips that are already complete. `nanori-eval cost --run-dir runs/mysys/gemini` sums the billed cost of a Gemini run. The ElevenLabs adapter sends `language_code` `ja` by default, as in the leaderboard run (`--language-code ''` sends none). ## Adding a system next to the published ones `scripts/add_system.sh` runs the whole chain for one more system and scores it together with the published per-item verdicts in `../results/per_item/`, so its pairs against the published systems use the same items, judges, rule and bootstrap seeds: ```bash cd nanori/eval # your own clips, laid out as //.wav bash scripts/add_system.sh --key mysys --label "My TTS" --wav-dir my_wavs --toolkit joyo --max-usd 45 # or synthesize with the Fish Audio API (FISH_API_KEY); --voice defaults to the leaderboard voice bash scripts/add_system.sh --key mysys --label "My TTS" --fish-model MODEL_ID --toolkit joyo --max-usd 45 ``` The script writes `runs//verdicts.jsonl` (R2 with G, KW and CTC per row) and `runs//score/` (`leaderboard.json`, `LEADERBOARD.md`, `RESULTS_FULL.md`; pairs: every published pair plus ` - s21pro`), and checks that the published systems' numbers in that output equal `../results/leaderboard.json`. `--gemini-raw`, `--kw` and `--ctc` take judge outputs you already have (for example from another machine); a judge whose outputs are given is not run, so with all three the script makes no API call. Run `bash scripts/add_system.sh --help` for every option. ## Judges ### G: Gemini two-step judge (`nanori-G-e7935b549445`) - **Step 1 (audio, blind).** The clip is converted to mono 16-bit at its native rate, RMS −20 dBFS, peak at most −1 dBFS. It is sent with the sentence in which the target is replaced by ⟦1⟧. Neither the written name nor any reading is shown. The model writes the whole recording in hiragana, then for the hidden part: what it heard, a few morae before and after, and a status (clear / unclear / missing). - **Step 2 (text only).** Heard + written name + accepted readings + known-wrong readings → ACCEPTED / KNOWN_WRONG / NONE. Spelling of the same sound does not matter (hiragana vs katakana, ー vs a vowel kana, おう = おお). Morae, voicing, ん, っ, glides and vowel length do matter. Companies also treat small and large vowel kana in loanwords as the same. - **Verdict per call:** unclear → UNSCORED, missing → FAIL, ACCEPTED → PASS, KNOWN_WRONG or NONE → FAIL. - **Verdict per clip:** K = 3 independent calls with seeds 20261121 + k (step 2: + 100). The majority of the scored calls decides; a tie is FAIL and a clip with no scored call is UNSCORED. - **Frozen parts.** The prompt templates (`nanori_eval/prompts/`, sha256 checked before every run), the JSON schemas, temperature 1.0 and reasoning effort low. - **Calibrated route.** `google/gemini-4-neon` via OpenRouter, provider `google-vertex/global`, ZDR, data_collection deny, no fallbacks. This is the default. - **Other routes.** `--provider google` (AI Studio) and `--provider vertex` call the same model directly but were not calibrated. The run's `meta.json` records the route. Another model id is another judge. - **Rule matcher.** A deterministic matcher with the same comparison rules is logged next to every call. ### KW: kana-whisper span judge - **Transcription.** `sbintuitions/kana-whisper` @88ecb3d7 through the official Joyo-Kanji-Yomi toolkit @6a79976c, unchanged (batch 16, ja, chunk 30 s), on CPU fp32. GPU fp16 was not calibrated. - **Span.** The toolkit's `map_marked_span` maps the transcript onto the reference, in which the target is tagged (`kw_ref`). - **Verdict.** The span is compared with the same matcher as above. ACCEPTED → PASS; KNOWN_WRONG, NONE or an empty span → FAIL. UNSCORED when the transcript is empty, its sentence-level kana character error rate is above 0.5, or the span holds non-kana characters. ### CTC: kana CTC forced-choice judge - **Model.** `vumichien/wav2vec2-large-xlsr-japanese-hiragana` @017225bb, CPU float32, 8 threads. - **Candidates.** For each target, whole-sentence hiragana strings: the reading of the left context + a candidate + the reading of the right context (context readings from pyopenjtalk 0.4.1). "Good" candidates are the key and the other accepted readings; "bad" candidates are the known-wrong readings. A few spelling variants per reading are tried (ー vs a vowel kana, ゔ vs the b-row) and the best one is kept. - **Forced choice.** CTC negative log-likelihood of every candidate; margin = NLL(best bad) − NLL(best good), in nats. PASS needs margin ≥ 4 and a good fit of the key on the target frames; FAIL when a known-wrong reading wins by 4 or more, when the key fits the target frames very badly, or when a near-miss of the key (one mora dropped, voicing flipped, small っ added) beats it clearly. Everything else is UNSCORED. - **UNSCORED also** when the item has no known-wrong reading in kana (no forced choice possible; 211 of 777 items), when the rest of the sentence does not fit the clip (the clip is not the sentence), or when the clip is shorter than 0.1 s. ### R2: the official rule (`nanori-R2-f559f531c66d`) **R2 = the Gemini verdict, unless KW and CTC both give a verdict, agree with each other and disagree with Gemini; then their common verdict. A Gemini UNSCORED stays UNSCORED.** The rule was frozen on 2026-11-21 before any system was scored and is the primary judge on every subset. G, KW and CTC are reported beside it as diagnostics. On the leaderboard runs, the two kana judges overruled Gemini on 4–15 of 777 items per system. ## Calibration Synthetic forced controls, no human ratings: per subset 72 seeded items, one forced-correct clip (the key, written in kana) and one forced-wrong clip (a known-wrong reading), rendered with Fun-CosyVoice3-0.5B-2512 in three open voices. Labels come from how the clips were built, so render errors count against the judge. A judge is accepted on a subset when its false-pass one-sided 95 % CP upper bound is ≤ 10 %. Drug and company controls were re-rendered and re-judged on the v1 sentences (2026-11-23); the Places sentences did not change. Full table: `calibration/CALIBRATION.md`. | subset | rule | false pass | FP upper (one-sided 95 % CP) | false fail | FF upper | |---|---|---:|---:|---:|---:| | Places | **R2** | 1/72 | 6.4 % | 12/72 | 25.6 % | | Places | G alone | 6/72 | 15.8 % | 12/72 | 25.6 % | | Drugs | **R2** | 2/72 | 8.5 % | 15/72 | 30.3 % | | Drugs | G alone | 8/72 | 19.2 % | 15/72 | 30.3 % | | Companies | **R2** | 2/72 | 8.5 % | 12/72 | 25.6 % | | Companies | G alone | 3/72 | 10.4 % | 14/72 | 28.7 % | Read these numbers with care: - **R2 passes the rule on every subset; Gemini alone does not.** Do not quote G-only numbers as validated. - **Absolute pass rates are biased low.** The judges fail 17–21 % of the forced-correct controls, so compare systems through the paired differences. - **The controls are synthetic.** They are CosyVoice3 renders, not human-verified audio. FP and FF are upper bounds on judge error for CosyVoice3 audio; how well they transfer to other TTS systems was not measured. - **The answer keys are registry or rule keys.** No native speaker checked them, and pitch accent is not judged. ## Scoring - **Rates.** Item verdict = PASS / FAIL / UNSCORED. Rate = PASS / scored items. Unscored rate = UNSCORED / items judged. Items without a clip count as not run. - **Quoting rule.** A paired difference is marked *not quoted* if either system has more than 5 % unscored items in that cell. - **CIs.** Wilson 95 % CI for one system. For the weighted Places headline, the rate is Σ w·s / Σ w over P-H + P-R and the Wilson interval uses the Kish n_eff (Σ w)² / Σ w². - **Paired differences A − B.** These use the items scored for both systems: a paired cluster bootstrap with the item as the unit, resampled within strata, B = 10,000, percentile 95 % CI. The output also carries the 98.75 % CI and the one-sided bootstrap p (H0: difference ≤ 0). - **Bootstrap seed.** sha256(`seed:subset:cell:judge:A-B`). The default seed is the pre-registered public drand value `94846c99…58e4c0`, so the same inputs give the same CIs on any machine. The system names and the orientation of a pair (A − B vs B − A) are part of the seed; the leaderboard uses the system keys in `results/leaderboard.json`. - **Cell ids** (`headline_weighted`, `all_400_unweighted`, `D-E`, `all_150`, …) are fixed labels for the same reason. ## Cost per system (all three subsets, 777 clips, one clip per item) | step | volume | measured cost (2026-11-23 runs) | |---|---|---| | TTS input | 27,442 characters | see the dataset card (per system) | | Gemini judge, K = 3 | about 4,660 calls (2,331 audio step-1 calls + step-2 text calls) | 35–39 USD on the OpenRouter → Vertex route (about 0.047 USD per clip) | | kana-whisper judge | 777 clips | about 3 s per clip on 8 CPU threads (about 40 minutes) | | kana CTC judge | 777 clips | 0.4–0.8 s per clip on 8 CPU threads (about 10 minutes), plus a 1.3 GB model download | | combine + score | – | seconds on a laptop | Prices are provider list prices at the time of the runs; a direct Google route bills tokens instead (pass `--price-in` / `--price-out` to get USD estimates; `--max-calls` caps calls on any route). ## Reproducing the published numbers `acceptance/` holds the scripts that check this package against the cached raw judge outputs of the leaderboard runs (the seven systems of the v1.0 freeze of 2026-11-23 in `results/` of the dataset, 777 items each, plus the 432 forced controls; systems added later are scored by the package itself). No judge call is made. Result on 2026-11-23, with the items loaded from the dataset files: - **Combine.** R2 rebuilt from the cached Gemini calls, kana-whisper rows and CTC rows equals the frozen combined verdicts on 5,439 of 5,439 clips. - **Published numbers.** All 16,586 values of the frozen result files that concern these systems match exactly: every cell × judges R2 / G / KW / CTC × systems, rates, Wilson CIs, Kish n_eff, unscored rates, and every paired difference with its bootstrap CI, 98.75 % CI and p. `nanori-eval combine` + `nanori-eval score` give the same leaderboard. - **Gemini inputs.** Masked sentences, step-1 and step-2 prompts are byte-identical to the frozen renderer on 17,613 cached calls. The rule matcher and the per-call verdicts match on every call, and audio prep is byte-identical on 53 sampled clips. - **kana-whisper.** The span verdicts recomputed from the cached transcripts with the official toolkit match on 5,935 of 5,935 rows. The references rebuilt with pyopenjtalk 0.4.1 match on 777 of 777 items. - **kana CTC.** The scoring functions, the thresholds and the text module have the same syntax tree as the frozen scorer (docstrings not compared), and the scorer inputs built from the dataset equal the frozen inputs on 777 of 777 items. A fresh `nanori-eval judge-ctc` run on 84 sampled clips (12 per system) in the calibrated environment (torch 2.10, transformers 5.15.1, CPU fp32, 8 threads) reproduced the frozen CTC rows on 84 of 84 clips, every field equal. `nanori-eval fetch-models` downloaded the model by id + revision and verified all four sha256; with that download and newer libraries (torch 2.15, transformers 5.24) the same clips gave the same verdicts on all 84, with margins within 0.001 nats. - **Calibration.** G, KW, CTC and R2 recomputed on the 432 controls equal the frozen calibration reports on every clip. Run the unit tests with `pytest tests` (set `NANORI_EVAL_JOYO_TOOLKIT=joyo` to include the kana-whisper tests). ## License Code and prompt templates: Apache-2.0 (`LICENSE`, `NOTICE`). The item tables, results and reports in the rest of the repository are CC BY 4.0 (`../LICENSE`, `../NOTICE`). The Joyo toolkit and kana-whisper (MIT, SB Intuitions) and the CTC model (Apache-2.0 per its model card; JSUT training data, see above) are fetched by the user and are not bundled.