Add Go API for Dolphin CTC models (#2090)
This commit is contained in:
4
.github/workflows/test-go.yaml
vendored
4
.github/workflows/test-go.yaml
vendored
@@ -179,6 +179,10 @@ jobs:
|
||||
go build
|
||||
ls -lh
|
||||
|
||||
echo "Test Dolphin CTC"
|
||||
./run-dolphin-ctc-base.sh
|
||||
rm -rf sherpa-onnx-dolphin-*
|
||||
|
||||
echo "Test FireRedAsr"
|
||||
./run-fire-red-asr.sh
|
||||
rm -rf sherpa-onnx-fire-red-asr-*
|
||||
|
||||
@@ -86,7 +86,7 @@ int32_t main() {
|
||||
vadConfig.num_threads = 1;
|
||||
vadConfig.debug = 1;
|
||||
|
||||
SherpaOnnxVoiceActivityDetector *vad =
|
||||
const SherpaOnnxVoiceActivityDetector *vad =
|
||||
SherpaOnnxCreateVoiceActivityDetector(&vadConfig, 30);
|
||||
|
||||
if (vad == NULL) {
|
||||
|
||||
@@ -87,7 +87,7 @@ int32_t main() {
|
||||
vadConfig.num_threads = 1;
|
||||
vadConfig.debug = 1;
|
||||
|
||||
SherpaOnnxVoiceActivityDetector *vad =
|
||||
const SherpaOnnxVoiceActivityDetector *vad =
|
||||
SherpaOnnxCreateVoiceActivityDetector(&vadConfig, 30);
|
||||
|
||||
if (vad == NULL) {
|
||||
|
||||
@@ -84,7 +84,7 @@ int32_t main() {
|
||||
vadConfig.num_threads = 1;
|
||||
vadConfig.debug = 1;
|
||||
|
||||
SherpaOnnxVoiceActivityDetector *vad =
|
||||
const SherpaOnnxVoiceActivityDetector *vad =
|
||||
SherpaOnnxCreateVoiceActivityDetector(&vadConfig, 30);
|
||||
|
||||
if (vad == NULL) {
|
||||
|
||||
@@ -28,6 +28,8 @@ func main() {
|
||||
|
||||
flag.StringVar(&config.ModelConfig.NemoCTC.Model, "nemo-ctc", "", "Path to the NeMo CTC model")
|
||||
|
||||
flag.StringVar(&config.ModelConfig.Dolphin.Model, "dolphin-model", "", "Path to the Dolphin CTC model")
|
||||
|
||||
flag.StringVar(&config.ModelConfig.FireRedAsr.Encoder, "fire-red-asr-encoder", "", "Path to the FireRedAsr encoder model")
|
||||
flag.StringVar(&config.ModelConfig.FireRedAsr.Decoder, "fire-red-asr-decoder", "", "Path to the FireRedAsr decoder model")
|
||||
|
||||
|
||||
19
go-api-examples/non-streaming-decode-files/run-dolphin-ctc-base.sh
Executable file
19
go-api-examples/non-streaming-decode-files/run-dolphin-ctc-base.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/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
|
||||
|
||||
go mod tidy
|
||||
go build
|
||||
|
||||
./non-streaming-decode-files \
|
||||
--dolphin-model ./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/model.int8.onnx \
|
||||
--tokens ./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/tokens.txt \
|
||||
--debug 0 \
|
||||
./sherpa-onnx-dolphin-base-ctc-multi-lang-int8-2025-04-02/test_wavs/0.wav
|
||||
@@ -0,0 +1 @@
|
||||
../../../../go-api-examples/non-streaming-decode-files/run-dolphin-ctc-base.sh
|
||||
@@ -377,6 +377,10 @@ type OfflineNemoEncDecCtcModelConfig struct {
|
||||
Model string // Path to the model, e.g., model.onnx or model.int8.onnx
|
||||
}
|
||||
|
||||
type OfflineDolphinModelConfig struct {
|
||||
Model string // Path to the model, e.g., model.onnx or model.int8.onnx
|
||||
}
|
||||
|
||||
type OfflineWhisperModelConfig struct {
|
||||
Encoder string
|
||||
Decoder string
|
||||
@@ -422,6 +426,7 @@ type OfflineModelConfig struct {
|
||||
SenseVoice OfflineSenseVoiceModelConfig
|
||||
Moonshine OfflineMoonshineModelConfig
|
||||
FireRedAsr OfflineFireRedAsrModelConfig
|
||||
Dolphin OfflineDolphinModelConfig
|
||||
Tokens string // Path to tokens.txt
|
||||
|
||||
// Number of threads to use for neural network computation
|
||||
@@ -512,6 +517,8 @@ func newCOfflineRecognizerConfig(config *OfflineRecognizerConfig) *C.struct_Sher
|
||||
c.model_config.fire_red_asr.encoder = C.CString(config.ModelConfig.FireRedAsr.Encoder)
|
||||
c.model_config.fire_red_asr.decoder = C.CString(config.ModelConfig.FireRedAsr.Decoder)
|
||||
|
||||
c.model_config.dolphin.model = C.CString(config.ModelConfig.Dolphin.Model)
|
||||
|
||||
c.model_config.tokens = C.CString(config.ModelConfig.Tokens)
|
||||
|
||||
c.model_config.num_threads = C.int(config.ModelConfig.NumThreads)
|
||||
|
||||
Reference in New Issue
Block a user