Add homonphone replacer example for Python API. #2161
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To run the example for the following hotwords
do the following.
Use
https://colab.research.google.com/drive/1-Djy8uYqlM4Z6zBaQkzcJO9JkfUAZGkV?usp=sharing
to get
replacer2.fst
.We have attached it below
replace2.fst.zip
Download
lexicon.txt
anddict.tar.bz2
fromhttps://github.com/k2-fsa/sherpa-onnx/releases/tag/hr-files
Download an ASR model from
https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#csukuangfj-sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20-bilingual-chinese-english
Run it
# 国安|雏鹰|飞龙|雄鹰|祥鹏 python3 ./python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py \ --tokens ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt \ --encoder ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.onnx \ --decoder ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx \ --joiner ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.onnx \ --hr-dict-dir ./dict \ --hr-lexicon ./lexicon.txt \ --hr-rule-fsts ./replace2.fst