Accent Detective scores how much a Mandarin recording sounds like Taiwan Mandarin. It is one network that can be cut at four depths, so the same weights serve anything from a small CPU deployment to the most accurate setting. The text the recording reads is optional: without it the model judges the audio alone, and with it the model also looks at the syllables the text implies. Neither mode needs a forced alignment.
中文說明。 評估一段華語錄音聽起來有多像臺灣華語。這是一個網路,可以在四個深度截斷使用:從資源有限的 CPU 環境,到最準的設定,都用同一組權重。錄音念的文字可以不提供。沒有文字時,只看語音;有文字時,也會參考文字對應的音節。兩種方式都不需要強制對齊。
The model listens to how Mandarin is pronounced: tone contours, neutral tones, initials and finals, and rhythm. It does not look at word choice, and it does not check whether a reading is "correct". During training, a text-only model absorbs whatever the sentence content alone predicts, so the score reflects how the sentence is spoken, not which words it contains.
It was built to evaluate text-to-speech systems: comparing different renditions of the same sentence. It is not meant to classify people.
probability the same as a probability, and index the log-odds on a 0–1 scale (0.5 is undecided, each 0.1 is about 7× the odds).# pip install -r requirements.txt (torch, torchaudio, librosa, soundfile, numpy, pypinyin, jieba, opencc, safetensors)
from huggingface_hub import snapshot_download
import sys
path = snapshot_download("JacobLinCool/accent-detective")
sys.path.insert(0, path)
from detective import load
det = load() # CPU or GPU
det.score("clip.wav") # no text, the largest size: {"logit", "probability", "index", "size", "mode", ...}
det.score("clip.wav", "這麼長的時間", size="tiny") # with the text it reads, size tiny
det.score_sizes("clip.wav") # all four sizes from one pass
det.score_recording("talk.wav") # any length: long audio is cut at pauses into 4–10 s pieces
nano, tiny, mini and small, smallest first. A smaller size is the first part of a larger one, so score_sizes costs one pass of the largest size.Everything is one checkpoint, model.safetensors, of 53.9 M parameters.
| Size | Trunk layers | Parameters, audio only | Parameters, with text |
|---|---|---|---|
| Nano | 3 | 9.5 M | 10.5 M |
| Tiny | 6 | 16.2 M | 17.2 M |
| Mini | 9 | 22.9 M | 23.9 M |
| Small | 18 | 43.0 M | 44.0 M |
Training. All four exits are trained at once:
The readouts are then trained on the frozen trunk. Each uses importance weights for sentence length and text context, plus a product-of-experts bias model that sees only the text, so that the readouts do not learn from content.
All numbers come from scoring the audio end to end with the released checkpoint. Real speech is a sealed set of Common Voice speakers whose labels were never used in training or development, and who were used only for reporting, never to choose a design or a setting. Their recordings were not entirely unheard: the Taiwan clips, and 69 of the Mainland clips, were among the unlabelled audio on which an earlier, smaller student was distilled, and the released trunk starts from that student. No other system in the comparisons heard them.
| Nano | Tiny | Mini | Small | |
|---|---|---|---|---|
| Length-matched AUC, sealed speakers, listener-checked labels (583 Taiwan, 1,451 Mainland clips, 448 speakers) | 0.956 | 0.961 | 0.960 | 0.962 |
| The same, with the text | 0.956 | 0.960 | 0.960 | 0.962 |
| The same, Common Voice labels as published (2,060 clips) | 0.888 | 0.903 | 0.905 | 0.913 |
| Expected calibration error, sealed speakers, listener-checked labels | 0.031 | 0.028 | 0.028 | 0.034 |
| Same text and voice prompt, BreezyVoice ranked above CosyVoice-300M (1,000 pairs) | 79% | 79% | 80% | 80% |
| The same contrast in standard deviations of the score on real speech | 0.38 | 0.36 | 0.37 | 0.37 |
| A comparison of the two synthesisers on 10 random pairs that ranks BreezyVoice first | 99% | 99% | 99% | 99% |
| Score variance explained by the TTS voice (119 texts × 4 voices of one TTS) | 6.8% | 4.8% | 5.5% | 11.9% |
| CPU latency for a 5 s clip, audio only, 4 threads / 1 thread | 29 / 74 ms | 51 / 132 ms | 73 / 192 ms | 133 / 355 ms |
| CPU latency with the text, 4 threads / 1 thread | 35 / 81 ms | 57 / 140 ms | 78 / 200 ms | 139 / 362 ms |
Recording conditions. Change in length-matched AUC on the sealed speakers, audio only, listener-checked labels. MP3, real noise and real rooms were never used in training. Training did use simulated band-limiting and µ-law, which are close to the telephone condition.
| Condition | Nano | Tiny | Mini | Small |
|---|---|---|---|---|
| MP3 at 32 kbit/s | −0.003 | −0.003 | −0.003 | −0.001 |
| Telephone (8 kHz, G.711 µ-law) | −0.029 | −0.030 | −0.031 | −0.019 |
| Real point-source noise at 10 dB SNR (OpenSLR 28) | −0.055 | −0.045 | −0.040 | −0.031 |
| Real room reverberation (OpenSLR 28) | −0.040 | −0.030 | −0.028 | −0.029 |
Research, and evaluating or steering speech synthesis towards Taiwan Mandarin. It scores speech, not people: do not use it to infer anyone's nationality or origin.
LICENSE).lexicon/concised.json.xz: headwords and their pinyin extracted from 教育部《國語辭典簡編本》 (Ministry of Education, Taiwan), CC BY-ND 3.0 TW, converted to JSON.lexicon/cedict.txt.gz: CC-CEDICT (MDBG), CC BY-SA 4.0.@misc{lin2026accentdetective,
title = {Accent Detective: A Compact Judge of Taiwan Mandarin Accent},
author = {Lin, Jhen-Ke},
year = {2026},
howpublished = {\url{https://huggingface.co/JacobLinCool/accent-detective}},
note = {Hugging Face model}
}