Skip to content

Add homonphone replacer example for Python API. #2161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025

Conversation

csukuangfj
Copy link
Collaborator

To run the example for the following hotwords

国安|雏鹰|飞龙|雄鹰|祥鹏

do the following.

  1. Use
    https://colab.research.google.com/drive/1-Djy8uYqlM4Z6zBaQkzcJO9JkfUAZGkV?usp=sharing
    to get replacer2.fst.
    We have attached it below
    replace2.fst.zip

  2. Download lexicon.txt and dict.tar.bz2 from
    https://github.com/k2-fsa/sherpa-onnx/releases/tag/hr-files

wget https://github.com/k2-fsa/sherpa-onnx/releases/download/hr-files/lexicon.txt
wget https://github.com/k2-fsa/sherpa-onnx/releases/download/hr-files/dict.tar.bz2
tar xvf dict.tar.bz2
rm dict.tar.bz2
  1. 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

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

@csukuangfj csukuangfj merged commit 51f8824 into k2-fsa:master Apr 29, 2025
30 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant