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

@@ -61,6 +61,12 @@ class OfflineDecodeFiles
[Option("telespeech-ctc", Required = false, HelpText = "Path to model.onnx. Used only for TeleSpeech CTC models")]
public string TeleSpeechCtc { get; set; } = "";
[Option("sense-voice-model", Required = false, HelpText = "Path to model.onnx. Used only for SenseVoice CTC models")]
public string SenseVoiceModel { get; set; } = "";
[Option("sense-voice-use-itn", Required = false, HelpText = "1 to use inverse text normalization for sense voice.")]
public int SenseVoiceUseItn { get; set; } = 1;
[Option("num-threads", Required = false, Default = 1, HelpText = "Number of threads for computation")]
public int NumThreads { get; set; } = 1;
@@ -225,6 +231,11 @@ to download pre-trained Tdnn models.
{
config.ModelConfig.Tdnn.Model = options.TdnnModel;
}
else if (!String.IsNullOrEmpty(options.SenseVoiceModel))
{
config.ModelConfig.SenseVoice.Model = options.SenseVoiceModel;
config.ModelConfig.SenseVoice.UseInverseTextNormalization = options.SenseVoiceUseItn;
}
else
{
Console.WriteLine("Please provide a model");

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -ex
if [ ! -d ./sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17 ]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2
tar xvf sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2
rm sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2
fi
dotnet run \
--sense-voice-model=./sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/model.int8.onnx \
--tokens=./sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/tokens.txt \
--files ./sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17/test_wavs/zh.wav