hama on-device NLP

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, and ASR behavior. The TypeScript suite checks Node + browser bindings, CTC decoding, split-model loading, WAV inference, and browser-specific validators for both 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 and ASR outputs across Python and TypeScript using the same assets. Treat mismatches in IPA strings, alignment indices, or decoded ASR tokens 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 ONNX assets or vocabularies change.