Testing

Testing keeps Python and TypeScript behavior aligned and catches asset regressions before release.

Runtime suites

cd hama/python
uv sync --extra test
uv run pytest
uv run pytest tests/test_asr.py -q
uv run pytest tests/test_split_assets.py -q

The Python suite covers tokenizer invariants, split-asset loading, ASR behavior (including per-phoneme time spans), and P2G golden parity. The TypeScript suite checks Node + browser bindings, CTC decoding, split-model loading, WAV inference, P2G decoding, and browser-specific validators for G2P and ASR. Some Bun versions may panic after printing successful test output; read the test results first, then treat the panic as a separate runtime issue.

Cross-runtime parity

Before releasing, compare representative G2P, ASR, and P2G outputs across Python and TypeScript using the same assets. Treat mismatches in IPA strings, alignment indices, decoded ASR tokens, phoneme time spans, or P2G text/alignments as release blockers.

Smoke tests

  • Execute uv run python -c “from hama import G2PModel; print(G2PModel().predict(‘안녕하세요’).ipa)” and uv run python python/example.py.
  • Run uv run python ../examples/python_asr.py; omit —wav for the synthetic smoke input.
  • Run node ts/example.js after building ts/.
  • Run bun run validate:model:split, bun run validate:asr, bun run validate:browser, and bun run validate:browser:asr before publishing.
  • Open the Astro site locally and check both the browser G2P demo and /research/ums for browser regressions.

CI recommendations

  • Run tests for both runtimes on every PR.
  • Gate releases on split-model, ASR, and browser validator success.
  • Publish preview packages for QA when .hama weight packages or vocabularies change.