Add C++ API for streaming ASR. (#1455)
It is a wrapper around the C API.
This commit is contained in:
21
.github/scripts/test-cxx-api.sh
vendored
Executable file
21
.github/scripts/test-cxx-api.sh
vendored
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
log() {
|
||||||
|
# This function is from espnet
|
||||||
|
local fname=${BASH_SOURCE[1]##*/}
|
||||||
|
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "CXX_STREAMING_ZIPFORMER_EXE is $CXX_STREAMING_ZIPFORMER_EXE"
|
||||||
|
echo "PATH: $PATH"
|
||||||
|
|
||||||
|
log "------------------------------------------------------------"
|
||||||
|
log "Test streaming zipformer CXX API"
|
||||||
|
log "------------------------------------------------------------"
|
||||||
|
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
$CXX_STREAMING_ZIPFORMER_EXE
|
||||||
|
rm -rf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20
|
||||||
@@ -193,7 +193,7 @@ jobs:
|
|||||||
|
|
||||||
rm -rf huggingface
|
rm -rf huggingface
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
||||||
|
|
||||||
cd huggingface
|
cd huggingface
|
||||||
mkdir -p aarch64
|
mkdir -p aarch64
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ jobs:
|
|||||||
|
|
||||||
rm -rf huggingface
|
rm -rf huggingface
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
||||||
|
|
||||||
cd huggingface
|
cd huggingface
|
||||||
mkdir -p aarch64
|
mkdir -p aarch64
|
||||||
|
|||||||
2
.github/workflows/android.yaml
vendored
2
.github/workflows/android.yaml
vendored
@@ -121,7 +121,7 @@ jobs:
|
|||||||
|
|
||||||
rm -rf huggingface
|
rm -rf huggingface
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
||||||
|
|
||||||
cd huggingface
|
cd huggingface
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/apk-asr-2pass.yaml
vendored
2
.github/workflows/apk-asr-2pass.yaml
vendored
@@ -163,7 +163,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/apk-asr.yaml
vendored
2
.github/workflows/apk-asr.yaml
vendored
@@ -163,7 +163,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/apk-audio-tagging.yaml
vendored
2
.github/workflows/apk-audio-tagging.yaml
vendored
@@ -160,7 +160,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/apk-kws.yaml
vendored
2
.github/workflows/apk-kws.yaml
vendored
@@ -160,7 +160,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/apk-tts-engine.yaml
vendored
2
.github/workflows/apk-tts-engine.yaml
vendored
@@ -164,7 +164,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/apk-tts.yaml
vendored
2
.github/workflows/apk-tts.yaml
vendored
@@ -164,7 +164,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/apk-vad-asr.yaml
vendored
2
.github/workflows/apk-vad-asr.yaml
vendored
@@ -163,7 +163,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/apk-vad.yaml
vendored
2
.github/workflows/apk-vad.yaml
vendored
@@ -160,7 +160,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/arm-linux-gnueabihf.yaml
vendored
2
.github/workflows/arm-linux-gnueabihf.yaml
vendored
@@ -205,7 +205,7 @@ jobs:
|
|||||||
git config --global user.name "Fangjun Kuang"
|
git config --global user.name "Fangjun Kuang"
|
||||||
|
|
||||||
rm -rf huggingface
|
rm -rf huggingface
|
||||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
||||||
|
|
||||||
cd huggingface
|
cd huggingface
|
||||||
mkdir -p arm32
|
mkdir -p arm32
|
||||||
|
|||||||
2
.github/workflows/build-wheels-aarch64.yaml
vendored
2
.github/workflows/build-wheels-aarch64.yaml
vendored
@@ -99,7 +99,7 @@ jobs:
|
|||||||
|
|
||||||
d=cpu/$SHERPA_ONNX_VERSION
|
d=cpu/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/build-wheels-armv7l.yaml
vendored
2
.github/workflows/build-wheels-armv7l.yaml
vendored
@@ -102,7 +102,7 @@ jobs:
|
|||||||
|
|
||||||
d=cpu/$SHERPA_ONNX_VERSION
|
d=cpu/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ jobs:
|
|||||||
|
|
||||||
d=cuda/$SHERPA_ONNX_VERSION
|
d=cuda/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/build-wheels-linux.yaml
vendored
2
.github/workflows/build-wheels-linux.yaml
vendored
@@ -96,7 +96,7 @@ jobs:
|
|||||||
|
|
||||||
d=cpu/$SHERPA_ONNX_VERSION
|
d=cpu/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
|
|
||||||
d=cpu/$SHERPA_ONNX_VERSION
|
d=cpu/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
|
|
||||||
d=cpu/$SHERPA_ONNX_VERSION
|
d=cpu/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ jobs:
|
|||||||
|
|
||||||
d=cpu/$SHERPA_ONNX_VERSION
|
d=cpu/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/build-wheels-win32.yaml
vendored
2
.github/workflows/build-wheels-win32.yaml
vendored
@@ -67,7 +67,7 @@ jobs:
|
|||||||
|
|
||||||
d=cpu/$SHERPA_ONNX_VERSION
|
d=cpu/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ jobs:
|
|||||||
|
|
||||||
d=cuda/$SHERPA_ONNX_VERSION
|
d=cuda/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/build-wheels-win64.yaml
vendored
2
.github/workflows/build-wheels-win64.yaml
vendored
@@ -73,7 +73,7 @@ jobs:
|
|||||||
|
|
||||||
d=cpu/$SHERPA_ONNX_VERSION
|
d=cpu/$SHERPA_ONNX_VERSION
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-wheels huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/build-xcframework.yaml
vendored
2
.github/workflows/build-xcframework.yaml
vendored
@@ -135,7 +135,7 @@ jobs:
|
|||||||
|
|
||||||
rm -rf huggingface
|
rm -rf huggingface
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
||||||
|
|
||||||
cd huggingface
|
cd huggingface
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/c-api.yaml
vendored
2
.github/workflows/c-api.yaml
vendored
@@ -4,8 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
tags:
|
|
||||||
- 'v[0-9]+.[0-9]+.[0-9]+*'
|
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/c-api.yaml'
|
- '.github/workflows/c-api.yaml'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
|
|||||||
117
.github/workflows/cxx-api.yaml
vendored
Normal file
117
.github/workflows/cxx-api.yaml
vendored
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
name: cxx-api
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/cxx-api.yaml'
|
||||||
|
- 'CMakeLists.txt'
|
||||||
|
- 'cmake/**'
|
||||||
|
- 'sherpa-onnx/csrc/*'
|
||||||
|
- 'sherpa-onnx/c-api/*'
|
||||||
|
- 'cxx-api-examples/**'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/cxx-api.yaml'
|
||||||
|
- 'CMakeLists.txt'
|
||||||
|
- 'cmake/**'
|
||||||
|
- 'sherpa-onnx/csrc/*'
|
||||||
|
- 'sherpa-onnx/c-api/*'
|
||||||
|
- 'cxx-api-examples/**'
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: cxx-api-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cxx_api:
|
||||||
|
name: ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: ccache
|
||||||
|
uses: hendrikmuhs/ccache-action@v1.2
|
||||||
|
with:
|
||||||
|
key: ${{ matrix.os }}-cxx-api-shared
|
||||||
|
|
||||||
|
- name: Build sherpa-onnx
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
|
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||||
|
cmake --version
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
|
||||||
|
cmake \
|
||||||
|
-D CMAKE_BUILD_TYPE=Release \
|
||||||
|
-D BUILD_SHARED_LIBS=ON \
|
||||||
|
-D CMAKE_INSTALL_PREFIX=./install \
|
||||||
|
-D SHERPA_ONNX_ENABLE_BINARY=OFF \
|
||||||
|
..
|
||||||
|
|
||||||
|
make -j2 install
|
||||||
|
|
||||||
|
ls -lh install/lib
|
||||||
|
ls -lh install/include
|
||||||
|
|
||||||
|
if [[ ${{ matrix.os }} == ubuntu-latest ]]; then
|
||||||
|
ldd ./install/lib/libsherpa-onnx-c-api.so
|
||||||
|
ldd ./install/lib/libsherpa-onnx-cxx-api.so
|
||||||
|
echo "---"
|
||||||
|
readelf -d ./install/lib/libsherpa-onnx-c-api.so
|
||||||
|
readelf -d ./install/lib/libsherpa-onnx-cxx-api.so
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${{ matrix.os }} == macos-latest ]]; then
|
||||||
|
otool -L ./install/lib/libsherpa-onnx-c-api.dylib
|
||||||
|
otool -L ./install/lib/libsherpa-onnx-cxx-api.dylib
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Test streaming zipformer
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
g++ -std=c++17 -o streaming-zipformer-cxx-api ./cxx-api-examples/streaming-zipformer-cxx-api.cc \
|
||||||
|
-I ./build/install/include \
|
||||||
|
-L ./build/install/lib/ \
|
||||||
|
-l sherpa-onnx-cxx-api \
|
||||||
|
-l sherpa-onnx-c-api \
|
||||||
|
-l onnxruntime
|
||||||
|
|
||||||
|
ls -lh streaming-zipformer-cxx-api
|
||||||
|
|
||||||
|
if [[ ${{ matrix.os }} == ubuntu-latest ]]; then
|
||||||
|
ldd ./streaming-zipformer-cxx-api
|
||||||
|
echo "----"
|
||||||
|
readelf -d ./streaming-zipformer-cxx-api
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
|
||||||
|
ls -lh sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20
|
||||||
|
echo "---"
|
||||||
|
ls -lh sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/test_wavs
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH=$PWD/build/install/lib:$LD_LIBRARY_PATH
|
||||||
|
export DYLD_LIBRARY_PATH=$PWD/build/install/lib:$DYLD_LIBRARY_PATH
|
||||||
|
|
||||||
|
./streaming-zipformer-cxx-api
|
||||||
|
|
||||||
|
rm -rf sherpa-onnx-streaming-zipformer-*
|
||||||
|
rm ./streaming-zipformer-cxx-api
|
||||||
2
.github/workflows/dot-net.yaml
vendored
2
.github/workflows/dot-net.yaml
vendored
@@ -90,7 +90,7 @@ jobs:
|
|||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
|
||||||
|
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ jobs:
|
|||||||
d=speaker-embedding-models
|
d=speaker-embedding-models
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
git clone https://huggingface.co/csukuangfj/$d huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
|
||||||
mv -v ./*.onnx ./huggingface
|
mv -v ./*.onnx ./huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git lfs track "*.onnx"
|
git lfs track "*.onnx"
|
||||||
|
|||||||
2
.github/workflows/export-ced-to-onnx.yaml
vendored
2
.github/workflows/export-ced-to-onnx.yaml
vendored
@@ -66,7 +66,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
d=sherpa-onnx-ced-$m-audio-tagging-2024-04-19
|
d=sherpa-onnx-ced-$m-audio-tagging-2024-04-19
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
git clone https://huggingface.co/k2-fsa/$d huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/$d huggingface
|
||||||
mv -v $d/* huggingface
|
mv -v $d/* huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git lfs track "*.onnx"
|
git lfs track "*.onnx"
|
||||||
|
|||||||
4
.github/workflows/export-libriheavy.yaml
vendored
4
.github/workflows/export-libriheavy.yaml
vendored
@@ -56,7 +56,7 @@ jobs:
|
|||||||
src=sherpa-onnx-zipformer-en-libriheavy-20230926-$m
|
src=sherpa-onnx-zipformer-en-libriheavy-20230926-$m
|
||||||
echo "Process $src"
|
echo "Process $src"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/$src huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$src huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
@@ -100,7 +100,7 @@ jobs:
|
|||||||
src=sherpa-onnx-zipformer-en-libriheavy-20230830-$m-punct-case
|
src=sherpa-onnx-zipformer-en-libriheavy-20230830-$m-punct-case
|
||||||
echo "Process $src"
|
echo "Process $src"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/$src huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$src huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/vits-melo-tts-zh_en huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/vits-melo-tts-zh_en huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
rm -rf huggingface
|
rm -rf huggingface
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
git clone https://huggingface.co/csukuangfj/$m huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$m huggingface
|
||||||
cp -av $m/* huggingface
|
cp -av $m/* huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git lfs track "*.onnx"
|
git lfs track "*.onnx"
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
rm -rf huggingface
|
rm -rf huggingface
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
git clone https://huggingface.co/csukuangfj/$m huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$m huggingface
|
||||||
cp -av $m/* huggingface
|
cp -av $m/* huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git lfs track "*.onnx"
|
git lfs track "*.onnx"
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ jobs:
|
|||||||
d=speaker-embedding-models
|
d=speaker-embedding-models
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
git clone https://huggingface.co/csukuangfj/$d huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
|
||||||
mv -v ./*.onnx ./huggingface
|
mv -v ./*.onnx ./huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git lfs track "*.onnx"
|
git lfs track "*.onnx"
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ jobs:
|
|||||||
d=sherpa-onnx-pyannote-segmentation-3-0
|
d=sherpa-onnx-pyannote-segmentation-3-0
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
git clone https://huggingface.co/csukuangfj/$d huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
|
||||||
cp -v $d/* ./huggingface
|
cp -v $d/* ./huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git lfs track "*.onnx"
|
git lfs track "*.onnx"
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ jobs:
|
|||||||
d=sherpa-onnx-reverb-diarization-v1
|
d=sherpa-onnx-reverb-diarization-v1
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
git clone https://huggingface.co/csukuangfj/$d huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
|
||||||
cp -v $d/* ./huggingface
|
cp -v $d/* ./huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git lfs track "*.onnx"
|
git lfs track "*.onnx"
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17 huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17 huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
4
.github/workflows/export-telespeech-ctc.yaml
vendored
4
.github/workflows/export-telespeech-ctc.yaml
vendored
@@ -60,7 +60,7 @@ jobs:
|
|||||||
|
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-telespeech-ctc-zh-2024-06-04 hf
|
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-telespeech-ctc-zh-2024-06-04 hf
|
||||||
cp -a $src/* hf/
|
cp -a $src/* hf/
|
||||||
cd hf
|
cd hf
|
||||||
git lfs track "*.pdf"
|
git lfs track "*.pdf"
|
||||||
@@ -84,7 +84,7 @@ jobs:
|
|||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
rm -rf hf
|
rm -rf hf
|
||||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04 hf
|
GIT_LFS_SKIP_SMUDGE=1 git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04 hf
|
||||||
cp -a $src/* hf/
|
cp -a $src/* hf/
|
||||||
cd hf
|
cd hf
|
||||||
git lfs track "*.pdf"
|
git lfs track "*.pdf"
|
||||||
|
|||||||
12
.github/workflows/export-wenet-to-onnx.yaml
vendored
12
.github/workflows/export-wenet-to-onnx.yaml
vendored
@@ -49,7 +49,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-aishell huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-aishell huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
@@ -98,7 +98,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-aishell2 huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-aishell2 huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
@@ -147,7 +147,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-multi-cn huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-multi-cn huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
@@ -196,7 +196,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-wenetspeech huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-wenetspeech huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
@@ -245,7 +245,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-en-wenet-librispeech huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-en-wenet-librispeech huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
@@ -295,7 +295,7 @@ jobs:
|
|||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-en-wenet-gigaspeech huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-en-wenet-gigaspeech huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
d=speaker-embedding-models
|
d=speaker-embedding-models
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
export GIT_CLONE_PROTECTION_ACTIVE=false
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
git clone https://huggingface.co/csukuangfj/$d huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/$d huggingface
|
||||||
mv -v ./*.onnx ./huggingface
|
mv -v ./*.onnx ./huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git lfs track "*.onnx"
|
git lfs track "*.onnx"
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ jobs:
|
|||||||
|
|
||||||
export GIT_LFS_SKIP_SMUDGE=1
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-whisper-${{ matrix.model }} huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-whisper-${{ matrix.model }} huggingface
|
||||||
|
|
||||||
rm -rf huggingface/*
|
rm -rf huggingface/*
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/flutter-android.yaml
vendored
2
.github/workflows/flutter-android.yaml
vendored
@@ -214,7 +214,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/flutter-linux.yaml
vendored
2
.github/workflows/flutter-linux.yaml
vendored
@@ -261,7 +261,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
4
.github/workflows/flutter-macos.yaml
vendored
4
.github/workflows/flutter-macos.yaml
vendored
@@ -101,7 +101,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
@@ -207,7 +207,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
4
.github/workflows/flutter-windows-x64.yaml
vendored
4
.github/workflows/flutter-windows-x64.yaml
vendored
@@ -94,7 +94,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
@@ -192,7 +192,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
2
.github/workflows/lazarus.yaml
vendored
2
.github/workflows/lazarus.yaml
vendored
@@ -355,7 +355,7 @@ jobs:
|
|||||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||||
|
|
||||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-bin huggingface
|
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-bin huggingface
|
||||||
cd huggingface
|
cd huggingface
|
||||||
git fetch
|
git fetch
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
14
.github/workflows/linux.yaml
vendored
14
.github/workflows/linux.yaml
vendored
@@ -19,6 +19,8 @@ on:
|
|||||||
- '.github/scripts/test-offline-punctuation.sh'
|
- '.github/scripts/test-offline-punctuation.sh'
|
||||||
- '.github/scripts/test-online-punctuation.sh'
|
- '.github/scripts/test-online-punctuation.sh'
|
||||||
- '.github/scripts/test-speaker-diarization.sh'
|
- '.github/scripts/test-speaker-diarization.sh'
|
||||||
|
- '.github/scripts/test-c-api.sh'
|
||||||
|
- '.github/scripts/test-cxx-api.sh'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'cmake/**'
|
- 'cmake/**'
|
||||||
- 'sherpa-onnx/csrc/*'
|
- 'sherpa-onnx/csrc/*'
|
||||||
@@ -40,6 +42,8 @@ on:
|
|||||||
- '.github/scripts/test-offline-punctuation.sh'
|
- '.github/scripts/test-offline-punctuation.sh'
|
||||||
- '.github/scripts/test-online-punctuation.sh'
|
- '.github/scripts/test-online-punctuation.sh'
|
||||||
- '.github/scripts/test-speaker-diarization.sh'
|
- '.github/scripts/test-speaker-diarization.sh'
|
||||||
|
- '.github/scripts/test-c-api.sh'
|
||||||
|
- '.github/scripts/test-cxx-api.sh'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'cmake/**'
|
- 'cmake/**'
|
||||||
- 'sherpa-onnx/csrc/*'
|
- 'sherpa-onnx/csrc/*'
|
||||||
@@ -145,6 +149,16 @@ jobs:
|
|||||||
name: release-${{ matrix.build_type }}-with-shared-lib-${{ matrix.shared_lib }}-with-tts-${{ matrix.with_tts }}
|
name: release-${{ matrix.build_type }}-with-shared-lib-${{ matrix.shared_lib }}-with-tts-${{ matrix.with_tts }}
|
||||||
path: install/*
|
path: install/*
|
||||||
|
|
||||||
|
- name: Test C++ API
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
du -h -d1 .
|
||||||
|
export PATH=$PWD/build/bin:$PATH
|
||||||
|
export CXX_STREAMING_ZIPFORMER_EXE=streaming-zipformer-cxx-api
|
||||||
|
|
||||||
|
.github/scripts/test-cxx-api.sh
|
||||||
|
du -h -d1 .
|
||||||
|
|
||||||
- name: Test offline speaker diarization
|
- name: Test offline speaker diarization
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
14
.github/workflows/macos.yaml
vendored
14
.github/workflows/macos.yaml
vendored
@@ -19,6 +19,8 @@ on:
|
|||||||
- '.github/scripts/test-offline-punctuation.sh'
|
- '.github/scripts/test-offline-punctuation.sh'
|
||||||
- '.github/scripts/test-online-punctuation.sh'
|
- '.github/scripts/test-online-punctuation.sh'
|
||||||
- '.github/scripts/test-speaker-diarization.sh'
|
- '.github/scripts/test-speaker-diarization.sh'
|
||||||
|
- '.github/scripts/test-c-api.sh'
|
||||||
|
- '.github/scripts/test-cxx-api.sh'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'cmake/**'
|
- 'cmake/**'
|
||||||
- 'sherpa-onnx/csrc/*'
|
- 'sherpa-onnx/csrc/*'
|
||||||
@@ -39,6 +41,8 @@ on:
|
|||||||
- '.github/scripts/test-offline-punctuation.sh'
|
- '.github/scripts/test-offline-punctuation.sh'
|
||||||
- '.github/scripts/test-online-punctuation.sh'
|
- '.github/scripts/test-online-punctuation.sh'
|
||||||
- '.github/scripts/test-speaker-diarization.sh'
|
- '.github/scripts/test-speaker-diarization.sh'
|
||||||
|
- '.github/scripts/test-c-api.sh'
|
||||||
|
- '.github/scripts/test-cxx-api.sh'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'cmake/**'
|
- 'cmake/**'
|
||||||
- 'sherpa-onnx/csrc/*'
|
- 'sherpa-onnx/csrc/*'
|
||||||
@@ -117,6 +121,16 @@ jobs:
|
|||||||
otool -L build/bin/sherpa-onnx
|
otool -L build/bin/sherpa-onnx
|
||||||
otool -l build/bin/sherpa-onnx
|
otool -l build/bin/sherpa-onnx
|
||||||
|
|
||||||
|
- name: Test C++ API
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
du -h -d1 .
|
||||||
|
export PATH=$PWD/build/bin:$PATH
|
||||||
|
export CXX_STREAMING_ZIPFORMER_EXE=streaming-zipformer-cxx-api
|
||||||
|
|
||||||
|
.github/scripts/test-cxx-api.sh
|
||||||
|
du -h -d1 .
|
||||||
|
|
||||||
- name: Test offline speaker diarization
|
- name: Test offline speaker diarization
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
9
.github/workflows/sanitizer.yaml
vendored
9
.github/workflows/sanitizer.yaml
vendored
@@ -76,6 +76,14 @@ jobs:
|
|||||||
otool -L build/bin/sherpa-onnx
|
otool -L build/bin/sherpa-onnx
|
||||||
otool -l build/bin/sherpa-onnx
|
otool -l build/bin/sherpa-onnx
|
||||||
|
|
||||||
|
- name: Test C++ API
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
export PATH=$PWD/build/bin:$PATH
|
||||||
|
export CXX_STREAMING_ZIPFORMER_EXE=streaming-zipformer-cxx-api
|
||||||
|
|
||||||
|
.github/scripts/test-cxx-api.sh
|
||||||
|
|
||||||
- name: Test online punctuation
|
- name: Test online punctuation
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -109,7 +117,6 @@ jobs:
|
|||||||
.github/scripts/test-online-ctc.sh
|
.github/scripts/test-online-ctc.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Test C API
|
- name: Test C API
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
13
.github/workflows/windows-x64.yaml
vendored
13
.github/workflows/windows-x64.yaml
vendored
@@ -18,6 +18,8 @@ on:
|
|||||||
- '.github/scripts/test-offline-punctuation.sh'
|
- '.github/scripts/test-offline-punctuation.sh'
|
||||||
- '.github/scripts/test-online-punctuation.sh'
|
- '.github/scripts/test-online-punctuation.sh'
|
||||||
- '.github/scripts/test-speaker-diarization.sh'
|
- '.github/scripts/test-speaker-diarization.sh'
|
||||||
|
- '.github/scripts/test-c-api.sh'
|
||||||
|
- '.github/scripts/test-cxx-api.sh'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'cmake/**'
|
- 'cmake/**'
|
||||||
- 'sherpa-onnx/csrc/*'
|
- 'sherpa-onnx/csrc/*'
|
||||||
@@ -36,6 +38,8 @@ on:
|
|||||||
- '.github/scripts/test-offline-punctuation.sh'
|
- '.github/scripts/test-offline-punctuation.sh'
|
||||||
- '.github/scripts/test-online-punctuation.sh'
|
- '.github/scripts/test-online-punctuation.sh'
|
||||||
- '.github/scripts/test-speaker-diarization.sh'
|
- '.github/scripts/test-speaker-diarization.sh'
|
||||||
|
- '.github/scripts/test-c-api.sh'
|
||||||
|
- '.github/scripts/test-cxx-api.sh'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'cmake/**'
|
- 'cmake/**'
|
||||||
- 'sherpa-onnx/csrc/*'
|
- 'sherpa-onnx/csrc/*'
|
||||||
@@ -89,10 +93,17 @@ jobs:
|
|||||||
name: release-windows-x64-${{ matrix.shared_lib }}-${{ matrix.with_tts }}
|
name: release-windows-x64-${{ matrix.shared_lib }}-${{ matrix.with_tts }}
|
||||||
path: build/install/*
|
path: build/install/*
|
||||||
|
|
||||||
|
- name: Test C++ API
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
export PATH=$PWD/build/bin/Release:$PATH
|
||||||
|
export CXX_STREAMING_ZIPFORMER_EXE=streaming-zipformer-cxx-api.exe
|
||||||
|
|
||||||
|
.github/scripts/test-cxx-api.sh
|
||||||
|
|
||||||
- name: Test offline speaker diarization
|
- name: Test offline speaker diarization
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
du -h -d1 .
|
|
||||||
export PATH=$PWD/build/bin/Release:$PATH
|
export PATH=$PWD/build/bin/Release:$PATH
|
||||||
export EXE=sherpa-onnx-offline-speaker-diarization.exe
|
export EXE=sherpa-onnx-offline-speaker-diarization.exe
|
||||||
|
|
||||||
|
|||||||
13
.github/workflows/windows-x86.yaml
vendored
13
.github/workflows/windows-x86.yaml
vendored
@@ -18,6 +18,8 @@ on:
|
|||||||
- '.github/scripts/test-offline-punctuation.sh'
|
- '.github/scripts/test-offline-punctuation.sh'
|
||||||
- '.github/scripts/test-online-punctuation.sh'
|
- '.github/scripts/test-online-punctuation.sh'
|
||||||
- '.github/scripts/test-speaker-diarization.sh'
|
- '.github/scripts/test-speaker-diarization.sh'
|
||||||
|
- '.github/scripts/test-c-api.sh'
|
||||||
|
- '.github/scripts/test-cxx-api.sh'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'cmake/**'
|
- 'cmake/**'
|
||||||
- 'sherpa-onnx/csrc/*'
|
- 'sherpa-onnx/csrc/*'
|
||||||
@@ -36,6 +38,8 @@ on:
|
|||||||
- '.github/scripts/test-offline-punctuation.sh'
|
- '.github/scripts/test-offline-punctuation.sh'
|
||||||
- '.github/scripts/test-online-punctuation.sh'
|
- '.github/scripts/test-online-punctuation.sh'
|
||||||
- '.github/scripts/test-speaker-diarization.sh'
|
- '.github/scripts/test-speaker-diarization.sh'
|
||||||
|
- '.github/scripts/test-c-api.sh'
|
||||||
|
- '.github/scripts/test-cxx-api.sh'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'cmake/**'
|
- 'cmake/**'
|
||||||
- 'sherpa-onnx/csrc/*'
|
- 'sherpa-onnx/csrc/*'
|
||||||
@@ -89,10 +93,17 @@ jobs:
|
|||||||
name: release-windows-x86-${{ matrix.shared_lib }}-${{ matrix.with_tts }}
|
name: release-windows-x86-${{ matrix.shared_lib }}-${{ matrix.with_tts }}
|
||||||
path: build/install/*
|
path: build/install/*
|
||||||
|
|
||||||
|
- name: Test C++ API
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
export PATH=$PWD/build/bin/Release:$PATH
|
||||||
|
export CXX_STREAMING_ZIPFORMER_EXE=streaming-zipformer-cxx-api.exe
|
||||||
|
|
||||||
|
.github/scripts/test-cxx-api.sh
|
||||||
|
|
||||||
- name: Test offline speaker diarization
|
- name: Test offline speaker diarization
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
du -h -d1 .
|
|
||||||
export PATH=$PWD/build/bin/Release:$PATH
|
export PATH=$PWD/build/bin/Release:$PATH
|
||||||
export EXE=sherpa-onnx-offline-speaker-diarization.exe
|
export EXE=sherpa-onnx-offline-speaker-diarization.exe
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
|
||||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
if(NOT WIN32)
|
||||||
set(BUILD_RPATH_USE_ORIGIN TRUE)
|
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set(BUILD_RPATH_USE_ORIGIN TRUE)
|
||||||
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT APPLE)
|
if(NOT APPLE)
|
||||||
set(SHERPA_ONNX_RPATH_ORIGIN "$ORIGIN")
|
set(SHERPA_ONNX_RPATH_ORIGIN "$ORIGIN")
|
||||||
@@ -399,6 +401,7 @@ add_subdirectory(sherpa-onnx)
|
|||||||
if(SHERPA_ONNX_ENABLE_C_API AND SHERPA_ONNX_ENABLE_BINARY AND SHERPA_ONNX_BUILD_C_API_EXAMPLES)
|
if(SHERPA_ONNX_ENABLE_C_API AND SHERPA_ONNX_ENABLE_BINARY AND SHERPA_ONNX_BUILD_C_API_EXAMPLES)
|
||||||
set(SHERPA_ONNX_PKG_WITH_CARGS "-lcargs")
|
set(SHERPA_ONNX_PKG_WITH_CARGS "-lcargs")
|
||||||
add_subdirectory(c-api-examples)
|
add_subdirectory(c-api-examples)
|
||||||
|
add_subdirectory(cxx-api-examples)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SHERPA_ONNX_ENABLE_WASM)
|
if(SHERPA_ONNX_ENABLE_WASM)
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ int32_t main() {
|
|||||||
recognizer_config.decoding_method = "greedy_search";
|
recognizer_config.decoding_method = "greedy_search";
|
||||||
recognizer_config.model_config = online_model_config;
|
recognizer_config.model_config = online_model_config;
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *recognizer =
|
const SherpaOnnxOnlineRecognizer *recognizer =
|
||||||
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
||||||
|
|
||||||
free((void *)tokens_buf);
|
free((void *)tokens_buf);
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ int32_t main() {
|
|||||||
recognizer_config.decoding_method = "greedy_search";
|
recognizer_config.decoding_method = "greedy_search";
|
||||||
recognizer_config.model_config = online_model_config;
|
recognizer_config.model_config = online_model_config;
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *recognizer =
|
const SherpaOnnxOnlineRecognizer *recognizer =
|
||||||
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
||||||
|
|
||||||
free((void *)tokens_buf);
|
free((void *)tokens_buf);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ int32_t main() {
|
|||||||
recognizer_config.decoding_method = "greedy_search";
|
recognizer_config.decoding_method = "greedy_search";
|
||||||
recognizer_config.model_config = online_model_config;
|
recognizer_config.model_config = online_model_config;
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *recognizer =
|
const SherpaOnnxOnlineRecognizer *recognizer =
|
||||||
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
||||||
|
|
||||||
if (recognizer == NULL) {
|
if (recognizer == NULL) {
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ int32_t main() {
|
|||||||
recognizer_config.hotwords_buf = hotwords_buf;
|
recognizer_config.hotwords_buf = hotwords_buf;
|
||||||
recognizer_config.hotwords_buf_size = hotwords_buf_size;
|
recognizer_config.hotwords_buf_size = hotwords_buf_size;
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *recognizer =
|
const SherpaOnnxOnlineRecognizer *recognizer =
|
||||||
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
||||||
|
|
||||||
free((void *)tokens_buf);
|
free((void *)tokens_buf);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ int32_t main() {
|
|||||||
recognizer_config.decoding_method = "greedy_search";
|
recognizer_config.decoding_method = "greedy_search";
|
||||||
recognizer_config.model_config = online_model_config;
|
recognizer_config.model_config = online_model_config;
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *recognizer =
|
const SherpaOnnxOnlineRecognizer *recognizer =
|
||||||
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
SherpaOnnxCreateOnlineRecognizer(&recognizer_config);
|
||||||
|
|
||||||
if (recognizer == NULL) {
|
if (recognizer == NULL) {
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ def get_binaries():
|
|||||||
binaries += [
|
binaries += [
|
||||||
"onnxruntime.dll",
|
"onnxruntime.dll",
|
||||||
"sherpa-onnx-c-api.dll",
|
"sherpa-onnx-c-api.dll",
|
||||||
|
"sherpa-onnx-cxx-api.dll",
|
||||||
]
|
]
|
||||||
|
|
||||||
return binaries
|
return binaries
|
||||||
|
|||||||
4
cxx-api-examples/CMakeLists.txt
Normal file
4
cxx-api-examples/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
include_directories(${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
add_executable(streaming-zipformer-cxx-api ./streaming-zipformer-cxx-api.cc)
|
||||||
|
target_link_libraries(streaming-zipformer-cxx-api sherpa-onnx-cxx-api)
|
||||||
91
cxx-api-examples/streaming-zipformer-cxx-api.cc
Normal file
91
cxx-api-examples/streaming-zipformer-cxx-api.cc
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
// cxx-api-examples/streaming-zipformer-cxx-api.cc
|
||||||
|
// Copyright (c) 2024 Xiaomi Corporation
|
||||||
|
|
||||||
|
//
|
||||||
|
// This file demonstrates how to use streaming Zipformer
|
||||||
|
// with sherpa-onnx's C++ API.
|
||||||
|
//
|
||||||
|
// clang-format off
|
||||||
|
//
|
||||||
|
// wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
// tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
// rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
|
||||||
|
//
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
#include <chrono> // NOLINT
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "sherpa-onnx/c-api/cxx-api.h"
|
||||||
|
|
||||||
|
int32_t main() {
|
||||||
|
using namespace sherpa_onnx::cxx;
|
||||||
|
OnlineRecognizerConfig config;
|
||||||
|
|
||||||
|
// please see
|
||||||
|
// 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
|
||||||
|
config.model_config.transducer.encoder =
|
||||||
|
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
|
||||||
|
"encoder-epoch-99-avg-1.int8.onnx";
|
||||||
|
|
||||||
|
// Note: We recommend not using int8.onnx for the decoder.
|
||||||
|
config.model_config.transducer.decoder =
|
||||||
|
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
|
||||||
|
"decoder-epoch-99-avg-1.onnx";
|
||||||
|
|
||||||
|
config.model_config.transducer.joiner =
|
||||||
|
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
|
||||||
|
"joiner-epoch-99-avg-1.int8.onnx";
|
||||||
|
|
||||||
|
config.model_config.tokens =
|
||||||
|
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt";
|
||||||
|
|
||||||
|
config.model_config.num_threads = 1;
|
||||||
|
|
||||||
|
std::cout << "Loading model\n";
|
||||||
|
OnlineRecognizer recongizer = OnlineRecognizer::Create(config);
|
||||||
|
if (!recongizer.Get()) {
|
||||||
|
std::cerr << "Please check your config\n";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
std::cout << "Loading model done\n";
|
||||||
|
|
||||||
|
std::string wave_filename =
|
||||||
|
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/test_wavs/"
|
||||||
|
"0.wav";
|
||||||
|
Wave wave = ReadWave(wave_filename);
|
||||||
|
if (wave.samples.empty()) {
|
||||||
|
std::cerr << "Failed to read: '" << wave_filename << "'\n";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Start recognition\n";
|
||||||
|
const auto begin = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
OnlineStream stream = recongizer.CreateStream();
|
||||||
|
stream.AcceptWaveform(wave.sample_rate, wave.samples.data(),
|
||||||
|
wave.samples.size());
|
||||||
|
while (recongizer.IsReady(&stream)) {
|
||||||
|
recongizer.Decode(&stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnlineRecognizerResult result = recongizer.GetResult(&stream);
|
||||||
|
|
||||||
|
const auto end = std::chrono::steady_clock::now();
|
||||||
|
const float elapsed_seconds =
|
||||||
|
std::chrono::duration_cast<std::chrono::milliseconds>(end - begin)
|
||||||
|
.count() /
|
||||||
|
1000.;
|
||||||
|
float duration = wave.samples.size() / static_cast<float>(wave.sample_rate);
|
||||||
|
float rtf = elapsed_seconds / duration;
|
||||||
|
|
||||||
|
std::cout << "text: " << result.text << "\n";
|
||||||
|
printf("Number of threads: %d\n", config.model_config.num_threads);
|
||||||
|
printf("Duration: %.3fs\n", duration);
|
||||||
|
printf("Elapsed seconds: %.3fs\n", elapsed_seconds);
|
||||||
|
printf("(Real time factor) RTF = %.3f / %.3f = %.3f\n", elapsed_seconds,
|
||||||
|
duration, rtf);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -290,7 +290,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizerConfig config;
|
SherpaOnnxOnlineRecognizerConfig config;
|
||||||
memset(&config, 0, sizeof(config));
|
memset(&config, 0, sizeof(config));
|
||||||
config.model_config.tokens = argv[1];
|
config.model_config.tokens = argv[1];
|
||||||
config.model_config.transducer.encoder = argv[2];
|
config.model_config.transducer.encoder = argv[2];
|
||||||
config.model_config.transducer.decoder = argv[3];
|
config.model_config.transducer.decoder = argv[3];
|
||||||
@@ -318,7 +318,7 @@ int main(int argc, char **argv) {
|
|||||||
config.rule2_min_trailing_silence = 1.2;
|
config.rule2_min_trailing_silence = 1.2;
|
||||||
config.rule3_min_utterance_length = 300;
|
config.rule3_min_utterance_length = 300;
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *recognizer =
|
const SherpaOnnxOnlineRecognizer *recognizer =
|
||||||
SherpaOnnxCreateOnlineRecognizer(&config);
|
SherpaOnnxCreateOnlineRecognizer(&config);
|
||||||
SherpaOnnxOnlineStream *stream = SherpaOnnxCreateOnlineStream(recognizer);
|
SherpaOnnxOnlineStream *stream = SherpaOnnxCreateOnlineStream(recognizer);
|
||||||
const SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(50);
|
const SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(50);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class CStreamingSpeechRecognitionDlg : public CDialogEx {
|
|||||||
private:
|
private:
|
||||||
Microphone mic_;
|
Microphone mic_;
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *recognizer_ = nullptr;
|
const SherpaOnnxOnlineRecognizer *recognizer_ = nullptr;
|
||||||
|
|
||||||
PaStream *pa_stream_ = nullptr;
|
PaStream *pa_stream_ = nullptr;
|
||||||
RecognizerThread *thread_ = nullptr;
|
RecognizerThread *thread_ = nullptr;
|
||||||
@@ -54,7 +54,7 @@ class CStreamingSpeechRecognitionDlg : public CDialogEx {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool started_ = false;
|
bool started_ = false;
|
||||||
SherpaOnnxOnlineStream *stream_ = nullptr;
|
const SherpaOnnxOnlineStream *stream_ = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int RunThread();
|
int RunThread();
|
||||||
@@ -79,4 +79,4 @@ class RecognizerThread : public CWinThread {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CStreamingSpeechRecognitionDlg *dlg_;
|
CStreamingSpeechRecognitionDlg *dlg_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -199,7 +199,8 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
|
|||||||
|
|
||||||
c.ctc_fst_decoder_config = GetCtcFstDecoderConfig(o);
|
c.ctc_fst_decoder_config = GetCtcFstDecoderConfig(o);
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *recognizer = SherpaOnnxCreateOnlineRecognizer(&c);
|
const SherpaOnnxOnlineRecognizer *recognizer =
|
||||||
|
SherpaOnnxCreateOnlineRecognizer(&c);
|
||||||
|
|
||||||
if (c.model_config.transducer.encoder) {
|
if (c.model_config.transducer.encoder) {
|
||||||
delete[] c.model_config.transducer.encoder;
|
delete[] c.model_config.transducer.encoder;
|
||||||
@@ -281,7 +282,7 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Napi::External<SherpaOnnxOnlineRecognizer>::New(
|
return Napi::External<SherpaOnnxOnlineRecognizer>::New(
|
||||||
env, recognizer,
|
env, const_cast<SherpaOnnxOnlineRecognizer *>(recognizer),
|
||||||
[](Napi::Env env, SherpaOnnxOnlineRecognizer *recognizer) {
|
[](Napi::Env env, SherpaOnnxOnlineRecognizer *recognizer) {
|
||||||
SherpaOnnxDestroyOnlineRecognizer(recognizer);
|
SherpaOnnxDestroyOnlineRecognizer(recognizer);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,12 +3,25 @@ add_library(sherpa-onnx-c-api c-api.cc)
|
|||||||
target_link_libraries(sherpa-onnx-c-api sherpa-onnx-core)
|
target_link_libraries(sherpa-onnx-c-api sherpa-onnx-core)
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
target_compile_definitions(sherpa-onnx-c-api PRIVATE SHERPA_ONNX_BUILD_SHARED_LIBS=1)
|
target_compile_definitions(sherpa-onnx-c-api PUBLIC SHERPA_ONNX_BUILD_SHARED_LIBS=1)
|
||||||
target_compile_definitions(sherpa-onnx-c-api PRIVATE SHERPA_ONNX_BUILD_MAIN_LIB=1)
|
target_compile_definitions(sherpa-onnx-c-api PUBLIC SHERPA_ONNX_BUILD_MAIN_LIB=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS sherpa-onnx-c-api DESTINATION lib)
|
add_library(sherpa-onnx-cxx-api cxx-api.cc)
|
||||||
|
target_link_libraries(sherpa-onnx-cxx-api sherpa-onnx-c-api)
|
||||||
|
|
||||||
install(FILES c-api.h
|
install(
|
||||||
DESTINATION include/sherpa-onnx/c-api
|
TARGETS
|
||||||
|
sherpa-onnx-c-api
|
||||||
|
sherpa-onnx-cxx-api
|
||||||
|
DESTINATION
|
||||||
|
lib
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
c-api.h
|
||||||
|
cxx-api.h
|
||||||
|
DESTINATION
|
||||||
|
include/sherpa-onnx/c-api
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "sherpa-onnx/c-api/c-api.h"
|
#include "sherpa-onnx/c-api/c-api.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -51,7 +52,7 @@ struct SherpaOnnxDisplay {
|
|||||||
|
|
||||||
#define SHERPA_ONNX_OR(x, y) (x ? x : y)
|
#define SHERPA_ONNX_OR(x, y) (x ? x : y)
|
||||||
|
|
||||||
SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer(
|
const SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer(
|
||||||
const SherpaOnnxOnlineRecognizerConfig *config) {
|
const SherpaOnnxOnlineRecognizerConfig *config) {
|
||||||
sherpa_onnx::OnlineRecognizerConfig recognizer_config;
|
sherpa_onnx::OnlineRecognizerConfig recognizer_config;
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,8 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineStream SherpaOnnxOnlineStream;
|
|||||||
/// @param config Config for the recognizer.
|
/// @param config Config for the recognizer.
|
||||||
/// @return Return a pointer to the recognizer. The user has to invoke
|
/// @return Return a pointer to the recognizer. The user has to invoke
|
||||||
// SherpaOnnxDestroyOnlineRecognizer() to free it to avoid memory leak.
|
// SherpaOnnxDestroyOnlineRecognizer() to free it to avoid memory leak.
|
||||||
SHERPA_ONNX_API SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer(
|
SHERPA_ONNX_API const SherpaOnnxOnlineRecognizer *
|
||||||
|
SherpaOnnxCreateOnlineRecognizer(
|
||||||
const SherpaOnnxOnlineRecognizerConfig *config);
|
const SherpaOnnxOnlineRecognizerConfig *config);
|
||||||
|
|
||||||
/// Free a pointer returned by SherpaOnnxCreateOnlineRecognizer()
|
/// Free a pointer returned by SherpaOnnxCreateOnlineRecognizer()
|
||||||
|
|||||||
159
sherpa-onnx/c-api/cxx-api.cc
Normal file
159
sherpa-onnx/c-api/cxx-api.cc
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
// sherpa-onnx/c-api/cxx-api.cc
|
||||||
|
//
|
||||||
|
// Copyright (c) 2024 Xiaomi Corporation
|
||||||
|
#include "sherpa-onnx/c-api/cxx-api.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace sherpa_onnx::cxx {
|
||||||
|
|
||||||
|
Wave ReadWave(const std::string &filename) {
|
||||||
|
auto p = SherpaOnnxReadWave(filename.c_str());
|
||||||
|
|
||||||
|
Wave ans;
|
||||||
|
if (p) {
|
||||||
|
ans.samples.resize(p->num_samples);
|
||||||
|
|
||||||
|
std::copy(p->samples, p->samples + p->num_samples, ans.samples.data());
|
||||||
|
|
||||||
|
ans.sample_rate = p->sample_rate;
|
||||||
|
SherpaOnnxFreeWave(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnlineStream::OnlineStream(const SherpaOnnxOnlineStream *p)
|
||||||
|
: MoveOnly<OnlineStream, SherpaOnnxOnlineStream>(p) {}
|
||||||
|
|
||||||
|
void OnlineStream::Destroy(const SherpaOnnxOnlineStream *p) const {
|
||||||
|
SherpaOnnxDestroyOnlineStream(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineStream::AcceptWaveform(int32_t sample_rate, const float *samples,
|
||||||
|
int32_t n) const {
|
||||||
|
SherpaOnnxOnlineStreamAcceptWaveform(p_, sample_rate, samples, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnlineRecognizer OnlineRecognizer::Create(
|
||||||
|
const OnlineRecognizerConfig &config) {
|
||||||
|
struct SherpaOnnxOnlineRecognizerConfig c;
|
||||||
|
memset(&c, 0, sizeof(c));
|
||||||
|
|
||||||
|
c.feat_config.sample_rate = config.feat_config.sample_rate;
|
||||||
|
c.feat_config.feature_dim = config.feat_config.feature_dim;
|
||||||
|
|
||||||
|
c.model_config.transducer.encoder =
|
||||||
|
config.model_config.transducer.encoder.c_str();
|
||||||
|
c.model_config.transducer.decoder =
|
||||||
|
config.model_config.transducer.decoder.c_str();
|
||||||
|
c.model_config.transducer.joiner =
|
||||||
|
config.model_config.transducer.joiner.c_str();
|
||||||
|
|
||||||
|
c.model_config.paraformer.encoder =
|
||||||
|
config.model_config.paraformer.encoder.c_str();
|
||||||
|
c.model_config.paraformer.decoder =
|
||||||
|
config.model_config.paraformer.decoder.c_str();
|
||||||
|
|
||||||
|
c.model_config.zipformer2_ctc.model =
|
||||||
|
config.model_config.zipformer2_ctc.model.c_str();
|
||||||
|
|
||||||
|
c.model_config.tokens = config.model_config.tokens.c_str();
|
||||||
|
c.model_config.num_threads = config.model_config.num_threads;
|
||||||
|
c.model_config.provider = config.model_config.provider.c_str();
|
||||||
|
c.model_config.debug = config.model_config.debug;
|
||||||
|
c.model_config.model_type = config.model_config.model_type.c_str();
|
||||||
|
c.model_config.modeling_unit = config.model_config.modeling_unit.c_str();
|
||||||
|
c.model_config.bpe_vocab = config.model_config.bpe_vocab.c_str();
|
||||||
|
c.model_config.tokens_buf = config.model_config.tokens_buf.c_str();
|
||||||
|
c.model_config.tokens_buf_size = config.model_config.tokens_buf.size();
|
||||||
|
|
||||||
|
c.decoding_method = config.decoding_method.c_str();
|
||||||
|
c.max_active_paths = config.max_active_paths;
|
||||||
|
c.enable_endpoint = config.enable_endpoint;
|
||||||
|
c.rule1_min_trailing_silence = config.rule1_min_trailing_silence;
|
||||||
|
c.rule2_min_trailing_silence = config.rule2_min_trailing_silence;
|
||||||
|
c.rule3_min_utterance_length = config.rule3_min_utterance_length;
|
||||||
|
c.hotwords_file = config.hotwords_file.c_str();
|
||||||
|
c.hotwords_score = config.hotwords_score;
|
||||||
|
|
||||||
|
c.ctc_fst_decoder_config.graph = config.ctc_fst_decoder_config.graph.c_str();
|
||||||
|
c.ctc_fst_decoder_config.max_active =
|
||||||
|
config.ctc_fst_decoder_config.max_active;
|
||||||
|
|
||||||
|
c.rule_fsts = config.rule_fsts.c_str();
|
||||||
|
c.rule_fars = config.rule_fars.c_str();
|
||||||
|
|
||||||
|
c.blank_penalty = config.blank_penalty;
|
||||||
|
|
||||||
|
c.hotwords_buf = config.hotwords_buf.c_str();
|
||||||
|
c.hotwords_buf_size = config.hotwords_buf.size();
|
||||||
|
|
||||||
|
auto p = SherpaOnnxCreateOnlineRecognizer(&c);
|
||||||
|
return OnlineRecognizer(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnlineRecognizer::OnlineRecognizer(const SherpaOnnxOnlineRecognizer *p)
|
||||||
|
: MoveOnly<OnlineRecognizer, SherpaOnnxOnlineRecognizer>(p) {}
|
||||||
|
|
||||||
|
void OnlineRecognizer::Destroy(const SherpaOnnxOnlineRecognizer *p) const {
|
||||||
|
SherpaOnnxDestroyOnlineRecognizer(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnlineStream OnlineRecognizer::CreateStream() const {
|
||||||
|
auto s = SherpaOnnxCreateOnlineStream(p_);
|
||||||
|
return OnlineStream{s};
|
||||||
|
}
|
||||||
|
|
||||||
|
OnlineStream OnlineRecognizer::CreateStream(const std::string &hotwords) const {
|
||||||
|
auto s = SherpaOnnxCreateOnlineStreamWithHotwords(p_, hotwords.c_str());
|
||||||
|
return OnlineStream{s};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnlineRecognizer::IsReady(const OnlineStream *s) const {
|
||||||
|
return SherpaOnnxIsOnlineStreamReady(p_, s->Get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineRecognizer::Decode(const OnlineStream *s) const {
|
||||||
|
SherpaOnnxDecodeOnlineStream(p_, s->Get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineRecognizer::Decode(const OnlineStream *ss, int32_t n) const {
|
||||||
|
if (n <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<const SherpaOnnxOnlineStream *> streams(n);
|
||||||
|
for (int32_t i = 0; i != n; ++n) {
|
||||||
|
streams[i] = ss[i].Get();
|
||||||
|
}
|
||||||
|
|
||||||
|
SherpaOnnxDecodeMultipleOnlineStreams(p_, streams.data(), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnlineRecognizerResult OnlineRecognizer::GetResult(
|
||||||
|
const OnlineStream *s) const {
|
||||||
|
auto r = SherpaOnnxGetOnlineStreamResult(p_, s->Get());
|
||||||
|
|
||||||
|
OnlineRecognizerResult ans;
|
||||||
|
ans.text = r->text;
|
||||||
|
|
||||||
|
ans.tokens.resize(r->count);
|
||||||
|
for (int32_t i = 0; i != r->count; ++i) {
|
||||||
|
ans.tokens[i] = r->tokens_arr[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r->timestamps) {
|
||||||
|
ans.timestamps.resize(r->count);
|
||||||
|
std::copy(r->timestamps, r->timestamps + r->count, ans.timestamps.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
ans.json = r->json;
|
||||||
|
|
||||||
|
SherpaOnnxDestroyOnlineRecognizerResult(r);
|
||||||
|
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace sherpa_onnx::cxx
|
||||||
179
sherpa-onnx/c-api/cxx-api.h
Normal file
179
sherpa-onnx/c-api/cxx-api.h
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
// sherpa-onnx/c-api/cxx-api.h
|
||||||
|
//
|
||||||
|
// Copyright (c) 2024 Xiaomi Corporation
|
||||||
|
|
||||||
|
// C++ Wrapper of the C API for sherpa-onnx
|
||||||
|
#ifndef SHERPA_ONNX_C_API_CXX_API_H_
|
||||||
|
#define SHERPA_ONNX_C_API_CXX_API_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "sherpa-onnx/c-api/c-api.h"
|
||||||
|
|
||||||
|
namespace sherpa_onnx::cxx {
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API OnlineTransducerModelConfig {
|
||||||
|
std::string encoder;
|
||||||
|
std::string decoder;
|
||||||
|
std::string joiner;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API OnlineParaformerModelConfig {
|
||||||
|
std::string encoder;
|
||||||
|
std::string decoder;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API OnlineZipformer2CtcModelConfig {
|
||||||
|
std::string model;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API OnlineModelConfig {
|
||||||
|
OnlineTransducerModelConfig transducer;
|
||||||
|
OnlineParaformerModelConfig paraformer;
|
||||||
|
OnlineZipformer2CtcModelConfig zipformer2_ctc;
|
||||||
|
std::string tokens;
|
||||||
|
int32_t num_threads = 1;
|
||||||
|
std::string provider = "cpu";
|
||||||
|
bool debug = false;
|
||||||
|
std::string model_type;
|
||||||
|
std::string modeling_unit = "cjkchar";
|
||||||
|
std::string bpe_vocab;
|
||||||
|
std::string tokens_buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API FeatureConfig {
|
||||||
|
int32_t sample_rate = 16000;
|
||||||
|
int32_t feature_dim = 80;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API OnlineCtcFstDecoderConfig {
|
||||||
|
std::string graph;
|
||||||
|
int32_t max_active = 3000;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API OnlineRecognizerConfig {
|
||||||
|
FeatureConfig feat_config;
|
||||||
|
OnlineModelConfig model_config;
|
||||||
|
|
||||||
|
std::string decoding_method = "greedy_search";
|
||||||
|
|
||||||
|
int32_t max_active_paths = 4;
|
||||||
|
|
||||||
|
bool enable_endpoint = false;
|
||||||
|
|
||||||
|
float rule1_min_trailing_silence = 2.4;
|
||||||
|
|
||||||
|
float rule2_min_trailing_silence = 1.2;
|
||||||
|
|
||||||
|
float rule3_min_utterance_length = 20;
|
||||||
|
|
||||||
|
std::string hotwords_file;
|
||||||
|
|
||||||
|
float hotwords_score = 1.5;
|
||||||
|
|
||||||
|
OnlineCtcFstDecoderConfig ctc_fst_decoder_config;
|
||||||
|
std::string rule_fsts;
|
||||||
|
std::string rule_fars;
|
||||||
|
float blank_penalty = 0;
|
||||||
|
|
||||||
|
std::string hotwords_buf;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API OnlineRecognizerResult {
|
||||||
|
std::string text;
|
||||||
|
std::vector<std::string> tokens;
|
||||||
|
std::vector<float> timestamps;
|
||||||
|
std::string json;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SHERPA_ONNX_API Wave {
|
||||||
|
std::vector<float> samples;
|
||||||
|
int32_t sample_rate;
|
||||||
|
};
|
||||||
|
|
||||||
|
SHERPA_ONNX_API Wave ReadWave(const std::string &filename);
|
||||||
|
|
||||||
|
template <typename Derived, typename T>
|
||||||
|
class SHERPA_ONNX_API MoveOnly {
|
||||||
|
public:
|
||||||
|
explicit MoveOnly(const T *p) : p_(p) {}
|
||||||
|
|
||||||
|
~MoveOnly() { Destroy(); }
|
||||||
|
|
||||||
|
MoveOnly(const MoveOnly &) = delete;
|
||||||
|
|
||||||
|
MoveOnly &operator=(const MoveOnly &) = delete;
|
||||||
|
|
||||||
|
MoveOnly(MoveOnly &&other) : p_(other.Release()) {}
|
||||||
|
|
||||||
|
MoveOnly &operator=(MoveOnly &&other) {
|
||||||
|
if (&other == this) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Destroy();
|
||||||
|
|
||||||
|
p_ = other.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
const T *Get() const { return p_; }
|
||||||
|
|
||||||
|
const T *Release() {
|
||||||
|
const T *p = p_;
|
||||||
|
p_ = nullptr;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Destroy() {
|
||||||
|
if (p_ == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static_cast<Derived *>(this)->Destroy(p_);
|
||||||
|
|
||||||
|
p_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const T *p_ = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SHERPA_ONNX_API OnlineStream
|
||||||
|
: public MoveOnly<OnlineStream, SherpaOnnxOnlineStream> {
|
||||||
|
public:
|
||||||
|
explicit OnlineStream(const SherpaOnnxOnlineStream *p);
|
||||||
|
|
||||||
|
void AcceptWaveform(int32_t sample_rate, const float *samples,
|
||||||
|
int32_t n) const;
|
||||||
|
|
||||||
|
void Destroy(const SherpaOnnxOnlineStream *p) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SHERPA_ONNX_API OnlineRecognizer
|
||||||
|
: public MoveOnly<OnlineRecognizer, SherpaOnnxOnlineRecognizer> {
|
||||||
|
public:
|
||||||
|
static OnlineRecognizer Create(const OnlineRecognizerConfig &config);
|
||||||
|
|
||||||
|
void Destroy(const SherpaOnnxOnlineRecognizer *p) const;
|
||||||
|
|
||||||
|
OnlineStream CreateStream() const;
|
||||||
|
|
||||||
|
OnlineStream CreateStream(const std::string &hotwords) const;
|
||||||
|
|
||||||
|
bool IsReady(const OnlineStream *s) const;
|
||||||
|
|
||||||
|
void Decode(const OnlineStream *s) const;
|
||||||
|
|
||||||
|
void Decode(const OnlineStream *ss, int32_t n) const;
|
||||||
|
|
||||||
|
OnlineRecognizerResult GetResult(const OnlineStream *s) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit OnlineRecognizer(const SherpaOnnxOnlineRecognizer *p);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sherpa_onnx::cxx
|
||||||
|
|
||||||
|
#endif // SHERPA_ONNX_C_API_CXX_API_H_
|
||||||
Reference in New Issue
Block a user