From 00048efad2f80091dc7ef2f340b3ed73141ed892 Mon Sep 17 00:00:00 2001 From: Florian Quirin Date: Thu, 19 Jan 2023 20:41:46 +0100 Subject: [PATCH] added sherpa-ncnn --- sherpa-ncnn/README.md | 11 +++++++++++ sherpa-ncnn/install.sh | 21 +++++++++++++++++++++ sherpa-ncnn/run-test.sh | 35 +++++++++++++++++++++++++++++++++++ whisper-cpp/run-test.sh | 4 +++- 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 sherpa-ncnn/README.md create mode 100644 sherpa-ncnn/install.sh create mode 100644 sherpa-ncnn/run-test.sh diff --git a/sherpa-ncnn/README.md b/sherpa-ncnn/README.md new file mode 100644 index 0000000..137fbb7 --- /dev/null +++ b/sherpa-ncnn/README.md @@ -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 diff --git a/sherpa-ncnn/install.sh b/sherpa-ncnn/install.sh new file mode 100644 index 0000000..688e5c9 --- /dev/null +++ b/sherpa-ncnn/install.sh @@ -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" diff --git a/sherpa-ncnn/run-test.sh b/sherpa-ncnn/run-test.sh new file mode 100644 index 0000000..fe70bd0 --- /dev/null +++ b/sherpa-ncnn/run-test.sh @@ -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" diff --git a/whisper-cpp/run-test.sh b/whisper-cpp/run-test.sh index 0f40644..aa656e2 100644 --- a/whisper-cpp/run-test.sh +++ b/whisper-cpp/run-test.sh @@ -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"