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.
  • 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.1

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.1
File Size Uploaded Provenance Actions
hatsuon-0.1.1.tar.gz 70.8 kB With provenance Details for hatsuon-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 110.6 kB

Release files / hatsuon-0.1.1.tar.gz

Download URL hatsuon-0.1.1.tar.gz
Size 70.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c40a83cbca7575a17c4d192ed5635703c2c2e1a13916d42ca215c1ce13533259
BLAKE2b-256 checksum
How to use checksums
c128d7e26ebddd7e8ad144c80b29c99730e89fec597a02bbad4a1d8379799043
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.1-py3-none-any.whl

Download URL hatsuon-0.1.1-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2b42d494ec5408760f7338ec12d661510813ddc269ad5aa107a042fdbb2dc9b
BLAKE2b-256 checksum
How to use checksums
d32de4717307db35647c9d3f04a9a2b41a7d1014401784a77bf97cf838af306e
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.1

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.1.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