Skip to main content

hatsuon

Japanese pronunciation scoring for read-aloud speech, on the CPU. It scores accuracy per mora, the special morae (っ, ん, long vowels) and Tokyo pitch accent.

Status: alpha (0.1). Thresholds were tuned on native speech only (JSUT/JVS), and no L2 learner data has been used yet. Treat the scores as feedback, not as a grade. Design and tuning records: docs/SPEC.md and calibration/default.json.

Install

pip install "hatsuon[all]"

The acoustic model is not shipped in the package. Convert it once on your machine. This step needs PyTorch and transformers only for the conversion itself:

pip install "hatsuon[export]"
hatsuon-export            # writes ~/.cache/hatsuon/models/... (ONNX, int8)

hatsuon-export --out DIR writes the model elsewhere; set HATSUON_MODEL_DIR=DIR to use it. --no-quantize keeps FP32 weights.

Use

import hatsuon

r = hatsuon.score("learner.wav", "東京に行きます。")
print(r.overall, r.accuracy, r.completeness, r.pitch, r.timing, r.confidence)
for w in r.words:
    print(w.surface, w.reading, w.score, w.accent.value)
    for m in w.morae:
        print("  ", m.kana, m.status.value, round(m.score), m.duration, m.pitch_status)
print([x.value for x in r.warnings])
  • audio can be a path, encoded bytes, or a (samples, sample_rate) tuple.
  • Ambiguous readings: reading="きょう" (whole text) or reading={"今日": "きょう"}.
  • Accent overrides: accent={"箸": 1} (0 = heiban, n = fall after mora n).
  • pitch=False or timing=False skips those stages.
  • debug=True attaches F0, the free decode and per-phone GOP to r.debug.
  • Soft problems such as no_speech, content_mismatch or pitch_unreliable come back in r.warnings and lower r.confidence.
  • Hard errors raise hatsuon.AudioError or hatsuon.TextError.

Known limitations (0.1)

  • Native-only calibration. We have not yet measured mispronunciation recall on learners. On 20 held-out JVS speakers, 0.6% of correct native morae fall below the mispronounced threshold. Synthetic one-mora substitutions (the text is changed, the audio is not) are caught 94% of the time: 98% for consonants and 91% for vowels. Real learner errors are subtler than these. On about 10k utterances of non-native read speech (unlabelled), 4.5% of morae are flagged mispronounced; how many of those flags are right is still unmeasured.
  • Pitch accent:
    • Native speakers often place the F0 peak one mora late, so a fall up to one mora after the nucleus is accepted. As a result, a learner who puts the nucleus one mora too late is not caught.
    • About 9% of native heiban phrases are flagged with a false fall.
  • Readings come from OpenJTalk. When it misreads a word (proper nouns, 命 → イノチ when the speaker says めい), a correct reading shows up as deleted morae. Pass reading={"命": "めい"} in those cases.
  • Read speech only. Not for spontaneous speech or singing.

Development

pip install -e ".[all,dev]"
pytest && ruff check .
bash tools/fetch_data.sh                  # JSUT, JVS, jsut-label into data/ (see DATA_SOURCES.md)
python tools/eval_accent.py --n 300       # pitch-accent accuracy on JSUT
python tools/calibrate.py collect && python tools/calibrate.py fit --write

License

MIT. Corpora and the acoustic model have their own licences and are never redistributed. See DATA_SOURCES.md.

Metadata

Release files for hatsuon 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hatsuon 0.1.2
File Size Uploaded Provenance Actions
hatsuon-0.1.2.tar.gz 77.0 kB With provenance Details for hatsuon-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hatsuon 0.1.2
File Interpreter ABI Platform Actions
hatsuon-0.1.2-py3-none-any.whl Python 3 none any Details for hatsuon-0.1.2-py3-none-any.whl

Total release size: 117.9 kB

Release files / hatsuon-0.1.2.tar.gz

Download URL hatsuon-0.1.2.tar.gz
Size 77.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c6cdfc5af2d836f7bd2128db01b0f84b4a3463997ff218285f8d09cc8f590ab5
BLAKE2b-256 checksum
How to use checksums
32f740322d9ae44e4b2418cbbdefb9f428cd585c9530966dfee236bc4c6da8ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / hatsuon-0.1.2-py3-none-any.whl

Download URL hatsuon-0.1.2-py3-none-any.whl
Size 40.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26395064137d87b02d8a0e1dc306ce70e6880f888cb4cda106e6c4b7ed0836ba
BLAKE2b-256 checksum
How to use checksums
7a4516ba6e1a6a8f14e0f30529523290e4ebf7f41473609709b18b7f3e828f15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for hatsuon 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hatsuon-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page