Add C# API for Dolphin CTC models (#2089)

This commit is contained in:
Fangjun Kuang
2025-04-02 23:36:22 +08:00
committed by GitHub
parent 18a6ed5ddc
commit 2dc0f91904
10 changed files with 52 additions and 4 deletions

View File

@@ -75,6 +75,9 @@ class OfflineDecodeFiles
[Option("nemo-ctc", Required = false, HelpText = "Path to model.onnx. Used only for NeMo CTC models")]
public string NeMoCtc { get; set; } = string.Empty;
[Option("dolphin-model", Required = false, Default = "", HelpText = "Path to dolphin ctc model")]
public string DolphinModel { get; set; } = string.Empty;
[Option("telespeech-ctc", Required = false, HelpText = "Path to model.onnx. Used only for TeleSpeech CTC models")]
public string TeleSpeechCtc { get; set; } = string.Empty;
@@ -233,6 +236,10 @@ to download pre-trained Tdnn models.
{
config.ModelConfig.NeMoCtc.Model = options.NeMoCtc;
}
else if (!string.IsNullOrEmpty(options.DolphinModel))
{
config.ModelConfig.Dolphin.Model = options.DolphinModel;
}
else if (!string.IsNullOrEmpty(options.TeleSpeechCtc))
{
config.ModelConfig.TeleSpeechCtc = options.TeleSpeechCtc;

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -ex
if [ ! -f ./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/model.int8.onnx ]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2
tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2
rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2
ls -lh sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02
fi
dotnet run \
--tokens=./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/tokens.txt \
--dolphin-model=./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/model.int8.onnx \
--num-threads=1 \
--files ./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/test_wavs/0.wav