Committed by
GitHub
Add C# API for Dolphin CTC models (#2089)
正在显示
10 个修改的文件
包含
52 行增加
和
4 行删除
| @@ -39,6 +39,9 @@ rm -rfv sherpa-onnx-pyannote-* | @@ -39,6 +39,9 @@ rm -rfv sherpa-onnx-pyannote-* | ||
| 39 | 39 | ||
| 40 | cd ../offline-decode-files | 40 | cd ../offline-decode-files |
| 41 | 41 | ||
| 42 | +./run-dolphin-ctc.sh | ||
| 43 | +rm -rf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02 | ||
| 44 | + | ||
| 42 | ./run-fire-red-asr.sh | 45 | ./run-fire-red-asr.sh |
| 43 | rm -rf sherpa-onnx-fire-red-asr-* | 46 | rm -rf sherpa-onnx-fire-red-asr-* |
| 44 | 47 |
| @@ -97,7 +97,7 @@ jobs: | @@ -97,7 +97,7 @@ jobs: | ||
| 97 | readelf -d ./$name | 97 | readelf -d ./$name |
| 98 | fi | 98 | fi |
| 99 | 99 | ||
| 100 | - 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 | 100 | + 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 |
| 101 | tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | 101 | tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 102 | rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | 102 | rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 103 | 103 |
| @@ -103,7 +103,7 @@ jobs: | @@ -103,7 +103,7 @@ jobs: | ||
| 103 | readelf -d ./$name | 103 | readelf -d ./$name |
| 104 | fi | 104 | fi |
| 105 | 105 | ||
| 106 | - 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 | 106 | + 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 |
| 107 | tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | 107 | tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 108 | rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | 108 | rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 109 | 109 |
| @@ -56,6 +56,9 @@ target_link_libraries(fire-red-asr-c-api sherpa-onnx-c-api) | @@ -56,6 +56,9 @@ target_link_libraries(fire-red-asr-c-api sherpa-onnx-c-api) | ||
| 56 | add_executable(sense-voice-c-api sense-voice-c-api.c) | 56 | add_executable(sense-voice-c-api sense-voice-c-api.c) |
| 57 | target_link_libraries(sense-voice-c-api sherpa-onnx-c-api) | 57 | target_link_libraries(sense-voice-c-api sherpa-onnx-c-api) |
| 58 | 58 | ||
| 59 | +add_executable(dolphin-ctc-c-api dolphin-ctc-c-api.c) | ||
| 60 | +target_link_libraries(dolphin-ctc-c-api sherpa-onnx-c-api) | ||
| 61 | + | ||
| 59 | add_executable(moonshine-c-api moonshine-c-api.c) | 62 | add_executable(moonshine-c-api moonshine-c-api.c) |
| 60 | target_link_libraries(moonshine-c-api sherpa-onnx-c-api) | 63 | target_link_libraries(moonshine-c-api sherpa-onnx-c-api) |
| 61 | 64 |
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | // This file demonstrates how to use Dolphin CTC model with sherpa-onnx's C API. | 6 | // This file demonstrates how to use Dolphin CTC model with sherpa-onnx's C API. |
| 7 | // clang-format off | 7 | // clang-format off |
| 8 | // | 8 | // |
| 9 | -// wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02 | 9 | +// wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 10 | // tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | 10 | // tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 11 | // rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | 11 | // rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 12 | // | 12 | // |
| @@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
| 7 | // | 7 | // |
| 8 | // clang-format off | 8 | // clang-format off |
| 9 | // | 9 | // |
| 10 | -// wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02 | 10 | +// wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 11 | // tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | 11 | // tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 12 | // rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | 12 | // rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 |
| 13 | // | 13 | // |
| @@ -75,6 +75,9 @@ class OfflineDecodeFiles | @@ -75,6 +75,9 @@ class OfflineDecodeFiles | ||
| 75 | [Option("nemo-ctc", Required = false, HelpText = "Path to model.onnx. Used only for NeMo CTC models")] | 75 | [Option("nemo-ctc", Required = false, HelpText = "Path to model.onnx. Used only for NeMo CTC models")] |
| 76 | public string NeMoCtc { get; set; } = string.Empty; | 76 | public string NeMoCtc { get; set; } = string.Empty; |
| 77 | 77 | ||
| 78 | + [Option("dolphin-model", Required = false, Default = "", HelpText = "Path to dolphin ctc model")] | ||
| 79 | + public string DolphinModel { get; set; } = string.Empty; | ||
| 80 | + | ||
| 78 | [Option("telespeech-ctc", Required = false, HelpText = "Path to model.onnx. Used only for TeleSpeech CTC models")] | 81 | [Option("telespeech-ctc", Required = false, HelpText = "Path to model.onnx. Used only for TeleSpeech CTC models")] |
| 79 | public string TeleSpeechCtc { get; set; } = string.Empty; | 82 | public string TeleSpeechCtc { get; set; } = string.Empty; |
| 80 | 83 | ||
| @@ -233,6 +236,10 @@ to download pre-trained Tdnn models. | @@ -233,6 +236,10 @@ to download pre-trained Tdnn models. | ||
| 233 | { | 236 | { |
| 234 | config.ModelConfig.NeMoCtc.Model = options.NeMoCtc; | 237 | config.ModelConfig.NeMoCtc.Model = options.NeMoCtc; |
| 235 | } | 238 | } |
| 239 | + else if (!string.IsNullOrEmpty(options.DolphinModel)) | ||
| 240 | + { | ||
| 241 | + config.ModelConfig.Dolphin.Model = options.DolphinModel; | ||
| 242 | + } | ||
| 236 | else if (!string.IsNullOrEmpty(options.TeleSpeechCtc)) | 243 | else if (!string.IsNullOrEmpty(options.TeleSpeechCtc)) |
| 237 | { | 244 | { |
| 238 | config.ModelConfig.TeleSpeechCtc = options.TeleSpeechCtc; | 245 | config.ModelConfig.TeleSpeechCtc = options.TeleSpeechCtc; |
| 1 | +#!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | +set -ex | ||
| 4 | + | ||
| 5 | +if [ ! -f ./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/model.int8.onnx ]; then | ||
| 6 | + 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 | ||
| 7 | + tar xvf sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | ||
| 8 | + rm sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02.tar.bz2 | ||
| 9 | + ls -lh sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02 | ||
| 10 | +fi | ||
| 11 | + | ||
| 12 | +dotnet run \ | ||
| 13 | + --tokens=./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/tokens.txt \ | ||
| 14 | + --dolphin-model=./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/model.int8.onnx \ | ||
| 15 | + --num-threads=1 \ | ||
| 16 | + --files ./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/test_wavs/0.wav |
scripts/dotnet/OfflineDolphinModelConfig.cs
0 → 100644
| 1 | +/// Copyright (c) 2025 Xiaomi Corporation (authors: Fangjun Kuang) | ||
| 2 | + | ||
| 3 | +using System.Runtime.InteropServices; | ||
| 4 | + | ||
| 5 | +namespace SherpaOnnx | ||
| 6 | +{ | ||
| 7 | + [StructLayout(LayoutKind.Sequential)] | ||
| 8 | + public struct OfflineDolphinModelConfig | ||
| 9 | + { | ||
| 10 | + public OfflineDolphinModelConfig() | ||
| 11 | + { | ||
| 12 | + Model = ""; | ||
| 13 | + } | ||
| 14 | + [MarshalAs(UnmanagedType.LPStr)] | ||
| 15 | + public string Model; | ||
| 16 | + } | ||
| 17 | +} |
| @@ -26,6 +26,7 @@ namespace SherpaOnnx | @@ -26,6 +26,7 @@ namespace SherpaOnnx | ||
| 26 | SenseVoice = new OfflineSenseVoiceModelConfig(); | 26 | SenseVoice = new OfflineSenseVoiceModelConfig(); |
| 27 | Moonshine = new OfflineMoonshineModelConfig(); | 27 | Moonshine = new OfflineMoonshineModelConfig(); |
| 28 | FireRedAsr = new OfflineFireRedAsrModelConfig(); | 28 | FireRedAsr = new OfflineFireRedAsrModelConfig(); |
| 29 | + Dolphin = new OfflineDolphinModelConfig(); | ||
| 29 | } | 30 | } |
| 30 | public OfflineTransducerModelConfig Transducer; | 31 | public OfflineTransducerModelConfig Transducer; |
| 31 | public OfflineParaformerModelConfig Paraformer; | 32 | public OfflineParaformerModelConfig Paraformer; |
| @@ -58,5 +59,6 @@ namespace SherpaOnnx | @@ -58,5 +59,6 @@ namespace SherpaOnnx | ||
| 58 | public OfflineSenseVoiceModelConfig SenseVoice; | 59 | public OfflineSenseVoiceModelConfig SenseVoice; |
| 59 | public OfflineMoonshineModelConfig Moonshine; | 60 | public OfflineMoonshineModelConfig Moonshine; |
| 60 | public OfflineFireRedAsrModelConfig FireRedAsr; | 61 | public OfflineFireRedAsrModelConfig FireRedAsr; |
| 62 | + public OfflineDolphinModelConfig Dolphin; | ||
| 61 | } | 63 | } |
| 62 | } | 64 | } |
-
请 注册 或 登录 后发表评论