Add C# API for SenseVoice models (#1151)

This commit is contained in:
Fangjun Kuang
2024-07-20 17:09:23 +08:00
committed by GitHub
parent 25f0a10468
commit e472180f2c
8 changed files with 79 additions and 28 deletions

View File

@@ -36,7 +36,7 @@ windows_x64_wheel=$src_dir/$windows_x64_wheel_filename
function process_linux() {
mkdir -p t
cd t
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$linux_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$linux_wheel_filename
unzip $linux_wheel_filename
cp -v sherpa_onnx/lib/*.so* ../linux
cd ..
@@ -50,7 +50,7 @@ function process_linux() {
function process_windows_x64() {
mkdir -p t
cd t
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$windows_x64_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$windows_x64_wheel_filename
unzip $windows_x64_wheel_filename
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll ../windows
cd ..
@@ -60,7 +60,7 @@ function process_windows_x64() {
function process_macos() {
mkdir -p t
cd t
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$macos_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$macos_wheel_filename
unzip $macos_wheel_filename
cp -v sherpa_onnx/lib/*.dylib ../macos
cd ..

View File

@@ -23,6 +23,7 @@ namespace SherpaOnnx
ModelingUnit = "cjkchar";
BpeVocab = "";
TeleSpeechCtc = "";
SenseVoice = new OfflineSenseVoiceModelConfig();
}
public OfflineTransducerModelConfig Transducer;
public OfflineParaformerModelConfig Paraformer;
@@ -51,7 +52,7 @@ namespace SherpaOnnx
[MarshalAs(UnmanagedType.LPStr)]
public string TeleSpeechCtc;
public OfflineSenseVoiceModelConfig SenseVoice;
}
}
}

View File

@@ -0,0 +1,24 @@
/// Copyright (c) 2024 Xiaomi Corporation (authors: Fangjun Kuang)
using System.Runtime.InteropServices;
namespace SherpaOnnx
{
[StructLayout(LayoutKind.Sequential)]
public struct OfflineSenseVoiceModelConfig
{
public OfflineSenseVoiceModelConfig()
{
Model = "";
Language = "";
UseInverseTextNormalization = 0;
}
[MarshalAs(UnmanagedType.LPStr)]
public string Model;
[MarshalAs(UnmanagedType.LPStr)]
public string Language;
public int UseInverseTextNormalization;
}
}

View File

@@ -55,7 +55,7 @@ if [ ! -f $src_dir/linux-x64/libsherpa-onnx-c-api.so ]; then
if [ -f $linux_x64_wheel ]; then
cp -v $linux_x64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$linux_x64_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$linux_x64_wheel_filename
fi
unzip $linux_x64_wheel_filename
cp -v sherpa_onnx/lib/*.so* ../
@@ -73,7 +73,7 @@ if [ ! -f $src_dir/linux-arm64/libsherpa-onnx-c-api.so ]; then
if [ -f $linux_arm64_wheel ]; then
cp -v $linux_arm64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$linux_arm64_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$linux_arm64_wheel_filename
fi
unzip $linux_arm64_wheel_filename
cp -v sherpa_onnx/lib/*.so* ../
@@ -91,7 +91,7 @@ if [ ! -f $src_dir/macos-x64/libsherpa-onnx-c-api.dylib ]; then
if [ -f $macos_x64_wheel ]; then
cp -v $macos_x64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$macos_x64_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$macos_x64_wheel_filename
fi
unzip $macos_x64_wheel_filename
cp -v sherpa_onnx/lib/*.dylib ../
@@ -111,7 +111,7 @@ if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-c-api.dylib ]; then
if [ -f $macos_arm64_wheel ]; then
cp -v $macos_arm64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$macos_arm64_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$macos_arm64_wheel_filename
fi
unzip $macos_arm64_wheel_filename
cp -v sherpa_onnx/lib/*.dylib ../
@@ -131,7 +131,7 @@ if [ ! -f $src_dir/windows-x64/sherpa-onnx-c-api.dll ]; then
if [ -f $windows_x64_wheel ]; then
cp -v $windows_x64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$windows_x64_wheel_filename
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$windows_x64_wheel_filename
fi
unzip $windows_x64_wheel_filename
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll ../

View File

@@ -27,7 +27,7 @@ function linux() {
dst=$(realpath sherpa-onnx-go-linux/lib/x86_64-unknown-linux-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cp -v sherpa_onnx/lib/*.so* $dst
@@ -39,7 +39,7 @@ function linux() {
dst=$(realpath sherpa-onnx-go-linux/lib/aarch64-unknown-linux-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
cp -v sherpa_onnx/lib/*.so* $dst
@@ -51,7 +51,7 @@ function linux() {
dst=$(realpath sherpa-onnx-go-linux/lib/arm-unknown-linux-gnueabihf)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-linux_armv7l.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-linux_armv7l.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-linux_armv7l.whl
cp -v sherpa_onnx/lib/*.so* $dst
@@ -84,7 +84,7 @@ function osx() {
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
cp -v sherpa_onnx/lib/*.dylib $dst/
@@ -102,7 +102,7 @@ function osx() {
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl
cp -v sherpa_onnx/lib/*.dylib $dst/
@@ -137,7 +137,7 @@ function windows() {
dst=$(realpath sherpa-onnx-go-windows/lib/x86_64-pc-windows-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst
@@ -149,7 +149,7 @@ function windows() {
dst=$(realpath sherpa-onnx-go-windows/lib/i686-pc-windows-gnu)
mkdir t
cd t
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl
wget -q https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl
unzip ./sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll $dst