Add examples for Visual C++ MFC (#208)

This commit is contained in:
Fangjun Kuang
2023-07-12 13:37:28 +08:00
committed by GitHub
parent 5cd72ba3aa
commit c818b82e13
18 changed files with 1487 additions and 0 deletions

53
mfc-examples/README.md Normal file
View File

@@ -0,0 +1,53 @@
# Speech recognition with Visual C++ MFC
This directory contains examples showing how to use Next-gen Kaldi in MFC
for speech recognition.
Caution: You need to use Windows and install Visual Studio in order to run it.
We use bash script below to demonstrate how to use it. Please change
the commands accordingly for Windows.
## Streaming speech recognition
```bash
mkdir -p $HOME/open-source
cd $HOME/open-source
git clone https://github.com/k2-fsa/sherpa-onnx
cd sherpa-onnx
mkdir build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install ..
cmake --build . --config Release --target install
cd ../mfc-examples
msbuild ./mfc-examples.sln /property:Configuration=Release /property:Platform=x64
cp ../build/install/lib/*.dll ./x64/Release/
# now run the program
./x64/Release/StreamingSpeechRecognition.exe
```
Note that we also need to download pre-trained models. Please
refer to https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/index.html
for a list of streaming models.
We use the following model for demonstration.
```bash
cd $HOME/open-source/sherpa-onnx/mfc-examples/x64/Release
wget https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615/resolve/main/exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx
wget https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615/resolve/main/exp/decoder-epoch-12-avg-4-chunk-16-left-128.onnx
wget https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615/resolve/main/exp/joiner-epoch-12-avg-4-chunk-16-left-128.onnx
wget https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615/resolve/main/data/lang_char/tokens.txt
# now rename
mv encoder-epoch-12-avg-4-chunk-16-left-128.onnx encoder.onnx
mv decoder-epoch-12-avg-4-chunk-16-left-128.onnx decoder.onnx
mv joiner-epoch-12-avg-4-chunk-16-left-128.onnx joiner.onnx
# Now run it!
./StreamingSpeechRecognition.exe
```