YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
English ITN grammar for on-device SR
Builds en_itn.fst, an inverse-text-normalization rewrite consumed by
sherpa-onnx's rule_fsts/rule_fars ITN stage. It turns spoken-form numbers in
the recognizer output into written form ("two thousand twenty six" β "2026",
"five dollars" β "$5", "ten percent" β "10%").
This exists because our on-device NeMo/Nemotron model spells numbers out, and neither WeTextProcessing (Chinese-only ITN) nor NVIDIA's NeMo-text-processing FARs are usable here β NeMo's exports are a tagger+verbalizer pair that require Sparrowhawk's two-pass parser, whereas sherpa applies each FST as a single-pass rewrite. So we author our own.
The sherpa-onnx FST contract
sherpa loads the FST and runs compose(input_text, rule) β shortestpath. The
rule FST must therefore be:
standardarc type (StdArc / tropical) β asserted on load, log rejectedvectororconstOpenFST binary- byte alphabet, no symbol table β built with pynini's
bytelib - total over byte input β the grammar is applied as a weighted whole-sentence
tagger (space-delimited tokens, each a number-phrase or passthrough word), so
unmatched spans stay identity; a non-total FST returns
""and wipes the transcript
build_en_itn.py satisfies all four. test_en_itn.py validates by replicating
sherpa's compose+shortestpath, so a green test means it works at runtime.
Build
pynini cannot build natively on macOS arm64, so the build is containerized:
./build.sh
Outputs tools/itn/out/en_itn.fst (and en_itn.far), runs the test suite.
Hosting
Distributed exactly like the punctuation model β a Hugging Face repo under our
org, pulled by the on-device ModelManager via OnDeviceModelSpec::Repo. The
SDK references it through the ItnModel config (OnDeviceAsrConfig::with_itn)
and sets config.rule_fsts in
sdk/multimodal-asr-on-device-client/src/engines/asr.rs.
Upload the built FST to the repo the SDK is wired to (brady-pplx/sherpa-onnx-en-itn):
pip install -U huggingface_hub
huggingface-cli login # needs write access to brady-pplx
huggingface-cli upload brady-pplx/sherpa-onnx-en-itn tools/itn/out/en_itn.fst en_itn.fst
ItnModel.revision resolves as a branch/tag ref (defaults to main), not a raw
commit hash, so to freeze a version create a tag on the repo and set that. The
grammar is authored here from scratch, so the artifact carries no upstream
license obligation.
Coverage / limitations
Covered: cardinals 0β999,999,999, US-dollar amounts, percentages.
Follow-ups: year readings ("twenty twenty six" currently β "20 20 6"), cents ("five dollars fifty"), ordinals, dates, phone numbers.