Skip to content

Commit

Permalink
added sherpa-ncnn
Browse files Browse the repository at this point in the history
  • Loading branch information
fquirin committed Jan 19, 2023
1 parent be6c184 commit 00048ef
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
11 changes: 11 additions & 0 deletions sherpa-ncnn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Next-gen Kaldi - Sherpa ncnn

**Sherpa**: Real-time (online/streaming) speech recognition using next-gen Kaldi with ncnn.
**ncnn**: High-performance neural network inference framework optimized for the mobile platform

Repositories:
- K2 Sherpa ncnn: https://github.com/k2-fsa/sherpa-ncnn
- ncnn: https://github.com/tencent/ncnn

Tested with:
- Arm64 - Debian 11
21 changes: 21 additions & 0 deletions sherpa-ncnn/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
echo "Installing Sherpa-ncnn ..."
sudo apt update
sudo apt install -y --no-install-recommends git build-essential
echo "Cloning code ..."
git clone https://github.com/k2-fsa/sherpa-ncnn
echo "Running build process ..."
cd sherpa-ncnn
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j3
cd ..
echo "Downloading models ..."
mkdir -p models
cd models
if [ ! -d "sherpa-ncnn-conv-emformer-transducer-small-2023-01-09/" ]; then
wget https://github.com/fquirin/speech-recognition-experiments/releases/download/v1.0.0/sherpa-ncnn-conv-emformer-transducer-small-2023-01-09.zip
unzip sherpa-ncnn-conv-emformer-transducer-small-2023-01-09.zip -d sherpa-ncnn-conv-emformer-transducer-small-2023-01-09
fi
echo "DONE"
35 changes: 35 additions & 0 deletions sherpa-ncnn/run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e

cd sherpa-ncnn
EXE="./build/bin/sherpa-ncnn"
which $EXE

MODEL="./models/sherpa-ncnn-conv-emformer-transducer-small-2023-01-09"
THREADS=2
echo "Model: $MODEL"
echo "Threads: $THREADS"
echo ""

waves=(
"../../test-files/en_speech_jfk_11s.wav"
"../../test-files/en_sh_lights_70pct_4s.wav"
)

start_t=$(date +"%s.%N")
for wave in ${waves[@]}; do
echo "Transcribing file: $wave"
time $EXE \
$MODEL/tokens.txt \
$MODEL/encoder_jit_trace-pnnx.ncnn.param \
$MODEL/encoder_jit_trace-pnnx.ncnn.bin \
$MODEL/decoder_jit_trace-pnnx.ncnn.param \
$MODEL/decoder_jit_trace-pnnx.ncnn.bin \
$MODEL/joiner_jit_trace-pnnx.ncnn.param \
$MODEL/joiner_jit_trace-pnnx.ncnn.bin \
$wave "$THREADS"
#$wave 4 greedy_search
echo ""
done
finish_t=$(date +"%s.%N")
echo "Total: $(expr $finish_t-$start_t | bc)s"
4 changes: 3 additions & 1 deletion whisper-cpp/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ echo ""

start_t=$(date +"%s.%N")
for wave in ${waves[@]}; do
echo "Transcribing file: $wave"
./main -m "models/ggml-${MODEL}.bin" -f "$wave" -t $THREADS
echo ""
done
finish_t=$(date +"%s.%N")
echo "Took: $(expr $finish_t-$start_t | bc)s"
echo "Total: $(expr $finish_t-$start_t | bc)s"

0 comments on commit 00048ef

Please sign in to comment.