Bez popisu

Fangjun Kuang be3a66d713 fix building on macOS (#36) před 2 roky
.github 491c7b99b4 Support building for android (#35) před 2 roky
cmake 491c7b99b4 Support building for android (#35) před 2 roky
scripts 78ce6f6233 Add CI test and refactor the code a bit. (#4) před 2 roky
sherpa-ncnn 491c7b99b4 Support building for android (#35) před 2 roky
toolchains 767e37f6cf Support building for aarch64 (#7) před 2 roky
.clang-format 78ce6f6233 Add CI test and refactor the code a bit. (#4) před 2 roky
.gitignore 0e5a58da20 add arm build support (#3) před 2 roky
CMakeLists.txt 491c7b99b4 Support building for android (#35) před 2 roky
CPPLINT.cfg 78ce6f6233 Add CI test and refactor the code a bit. (#4) před 2 roky
LICENSE 3185205428 First commit před 2 roky
README.md 8238256b34 update README.md to include more models (#32) před 2 roky
build-aarch64-linux-gnu.sh 491c7b99b4 Support building for android (#35) před 2 roky
build-android-arm64-v8a.sh be3a66d713 fix building on macOS (#36) před 2 roky
build-android-armv7-eabi.sh be3a66d713 fix building on macOS (#36) před 2 roky
build-android-x86-64.sh be3a66d713 fix building on macOS (#36) před 2 roky
build-arm-linux-gnueabihf.sh 491c7b99b4 Support building for android (#35) před 2 roky

README.md

Introduction

Documentation: https://k2-fsa.github.io/sherpa/ncnn/index.html

Try it in colab: Open In Colab

We provide two YouTube videos for demonstration about real-time speech recognition with sherpa-ncnn from a microphone:

Note: If you don't have access to YouTube, we provide the links in bilibili below:

See https://github.com/k2-fsa/sherpa

This repo uses ncnn for running the neural network model and does not depend on libtorch.

Please read https://k2-fsa.github.io/icefall/recipes/librispeech/lstm_pruned_stateless_transducer.html if you are interested in how the model is trained.

We provide exported models in ncnn format and they can be downloaded using the following links:

LSTM transducer

ConvEmformer transducer

Build for Linux/macOS

git clone https://github.com/k2-fsa/sherpa-ncnn
cd sherpa-ncnn
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j6
cd ..

Download the pretrained model (Chinese)

Caution: You have to run git lfs install. Otherwise, you will be SAD later.

git lfs install
git clone https://huggingface.co/csukuangfj/sherpa-ncnn-2022-09-30

./build/bin/sherpa-ncnn \
  ./sherpa-ncnn-2022-09-30/tokens.txt \
  ./sherpa-ncnn-2022-09-30/encoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/encoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-30/decoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/decoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-30/joiner_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/joiner_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-30/test_wavs/0.wav

# You will find executables in ./bin/

Build for Windows

git clone https://github.com/k2-fsa/sherpa-ncnn
cd sherpa-ncnn
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release
cd ..

# You will find executables in ./bin/Release

Download the pretrained model (Chinese)

Caution: You have to run git lfs install. Otherwise, you will be SAD later.

git lfs install
git clone https://huggingface.co/csukuangfj/sherpa-ncnn-2022-09-30

./build/bin/sherpa-ncnn \
  ./sherpa-ncnn-2022-09-30/tokens.txt \
  ./sherpa-ncnn-2022-09-30/encoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/encoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-30/decoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/decoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-30/joiner_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/joiner_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-30/test_wavs/0.wav

# If you are using Windows, please use ./build/bin/Release/sherpa-ncnn

# If you get encoding issues on Windows, please run
#  CHCP 65001
# in you commandline window.

To do speech recognition in real-time with a microphone, run:

./build/bin/sherpa-ncnn-microphone \
  ./sherpa-ncnn-2022-09-30/tokens.txt \
  ./sherpa-ncnn-2022-09-30/encoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/encoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-30/decoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/decoder_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-30/joiner_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-30/joiner_jit_trace-v2-epoch-11-avg-2-pnnx.ncnn.bin

# If you are using Windows, please use ./build/bin/Release/sherpa-ncnn-microphone.exe

Download the pretrained model (English)

git lfs install
git clone https://huggingface.co/csukuangfj/sherpa-ncnn-2022-09-05

./build/bin/sherpa-ncnn \
  ./sherpa-ncnn-2022-09-05/tokens.txt \
  ./sherpa-ncnn-2022-09-05/bar/encoder_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-05/bar/encoder_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-05/bar/decoder_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-05/bar/decoder_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-05/bar/joiner_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-05/bar/joiner_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-05/test_wavs/1089-134686-0001.wav

# If you are using Windows, please use ./build/bin/Release/sherpa-ncnn.exe

To do speech recognition in real-time with a microphone, run:

./build/bin/sherpa-ncnn-microphone \
  ./sherpa-ncnn-2022-09-05/tokens.txt \
  ./sherpa-ncnn-2022-09-05/bar/encoder_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-05/bar/encoder_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-05/bar/decoder_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-05/bar/decoder_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.bin \
  ./sherpa-ncnn-2022-09-05/bar/joiner_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.param \
  ./sherpa-ncnn-2022-09-05/bar/joiner_jit_trace-v2-iter-468000-avg-16-pnnx.ncnn.bin

# If you are using Windows, please use ./build/bin/Release/sherpa-ncnn-microphone.exe

# If you get encoding issues on Windows, please run
#  CHCP 65001
# in you commandline window.