Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Fangjun Kuang
2025-07-12 18:39:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-07-12 18:39:18 +0800
Commit
71aea2f19c4744c1eef4bcaa5f30c7527575ee8e
71aea2f1
1 parent
0b8ce73d
Add C# API for ten-vad (#2385)
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
104 行增加
和
6 行删除
.github/scripts/test-dot-net.sh
.github/workflows/test-dot-net.yaml
dotnet-examples/vad-non-streaming-asr-paraformer/Program.cs
dotnet-examples/vad-non-streaming-asr-paraformer/run-ten-vad.sh
dotnet-examples/vad-non-streaming-asr-paraformer/run.sh
scripts/dotnet/TenVadModelConfig.cs
scripts/dotnet/VadModelConfig.cs
.github/scripts/test-dot-net.sh
查看文件 @
71aea2f
#!/usr/bin/env bash
set
-ex
cd
dotnet-examples/
cd
./version-test
./run.sh
ls -lh
cd
../vad-non-streaming-asr-paraformer
./run-ten-vad.sh
rm -fv
*
.onnx
./run.sh
rm -fv
*
.onnx
cd
../non-streaming-canary-decode-files
./run.sh
ls -lh
...
...
@@ -106,9 +115,6 @@ rm -rf sherpa-onnx-*
./run-paraformer.sh
rm -rf sherpa-onnx-
*
cd
../vad-non-streaming-asr-paraformer
./run.sh
cd
../offline-punctuation
./run.sh
rm -rf sherpa-onnx-
*
...
...
.github/workflows/test-dot-net.yaml
查看文件 @
71aea2f
...
...
@@ -102,6 +102,7 @@ jobs:
df -h
-
name
:
Free space
if
:
false
shell
:
bash
run
:
|
df -h
...
...
@@ -109,6 +110,7 @@ jobs:
df -h
-
name
:
Free more space
if
:
false
shell
:
bash
run
:
|
# https://github.com/orgs/community/discussions/25678
...
...
@@ -120,6 +122,7 @@ jobs:
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
-
name
:
Free Disk Space (Ubuntu)
if
:
false
uses
:
jlumbroso/free-disk-space@main
with
:
# this might remove tools that are actually needed,
...
...
@@ -136,6 +139,7 @@ jobs:
swap-storage
:
true
-
name
:
Check space
if
:
false
shell
:
bash
run
:
|
df -h
...
...
dotnet-examples/vad-non-streaming-asr-paraformer/Program.cs
查看文件 @
71aea2f
// Copyright (c) 2024 Xiaomi Corporation
//
// This file shows how to use a silero_vad model with a non-streaming Paraformer
// for speech recognition.
// This file shows how to use a silero_vad model or ten-vad model
// with a non-streaming Paraformer for speech recognition.
using
SherpaOnnx
;
using
System.IO
;
class
VadNonStreamingAsrParaformer
{
...
...
@@ -17,7 +19,31 @@ class VadNonStreamingAsrParaformer
var
recognizer
=
new
OfflineRecognizer
(
config
);
var
vadModelConfig
=
new
VadModelConfig
();
vadModelConfig
.
SileroVad
.
Model
=
"./silero_vad.onnx"
;
if
(
File
.
Exists
(
"./silero_vad.onnx"
))
{
Console
.
WriteLine
(
"Use silero-vad"
);
vadModelConfig
.
SileroVad
.
Model
=
"./silero_vad.onnx"
;
vadModelConfig
.
SileroVad
.
Threshold
=
0.3F
;
vadModelConfig
.
SileroVad
.
MinSilenceDuration
=
0.5F
;
vadModelConfig
.
SileroVad
.
MinSpeechDuration
=
0.25F
;
vadModelConfig
.
SileroVad
.
MaxSpeechDuration
=
5.0F
;
vadModelConfig
.
SileroVad
.
WindowSize
=
512
;
}
else
if
(
File
.
Exists
(
"./ten-vad.onnx"
))
{
Console
.
WriteLine
(
"Use ten-vad"
);
vadModelConfig
.
TenVad
.
Model
=
"./ten-vad.onnx"
;
vadModelConfig
.
TenVad
.
Threshold
=
0.3F
;
vadModelConfig
.
TenVad
.
MinSilenceDuration
=
0.5F
;
vadModelConfig
.
TenVad
.
MinSpeechDuration
=
0.25F
;
vadModelConfig
.
TenVad
.
MaxSpeechDuration
=
5.0F
;
vadModelConfig
.
TenVad
.
WindowSize
=
256
;
}
else
{
Console
.
WriteLine
(
"Please download ./silero_vad.onnx or ./ten-vad.onnx"
);
return
;
}
vadModelConfig
.
Debug
=
0
;
var
vad
=
new
VoiceActivityDetector
(
vadModelConfig
,
60
);
...
...
@@ -27,6 +53,12 @@ class VadNonStreamingAsrParaformer
int
numSamples
=
reader
.
Samples
.
Length
;
int
windowSize
=
vadModelConfig
.
SileroVad
.
WindowSize
;
if
(
vadModelConfig
.
TenVad
.
Model
!=
""
)
{
windowSize
=
vadModelConfig
.
TenVad
.
WindowSize
;
}
int
sampleRate
=
vadModelConfig
.
SampleRate
;
int
numIter
=
numSamples
/
windowSize
;
...
...
dotnet-examples/vad-non-streaming-asr-paraformer/run-ten-vad.sh
0 → 100755
查看文件 @
71aea2f
#!/usr/bin/env bash
set
-ex
if
[
! -f ./ten-vad.onnx
]
;
then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/ten-vad.onnx
fi
if
[
! -f ./lei-jun-test.wav
]
;
then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/lei-jun-test.wav
fi
if
[
! -f ./sherpa-onnx-paraformer-zh-2023-09-14/tokens.txt
]
;
then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2
tar xvf sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2
rm sherpa-onnx-paraformer-zh-2023-09-14.tar.bz2
fi
dotnet run
...
...
dotnet-examples/vad-non-streaming-asr-paraformer/run.sh
100644 → 100755
查看文件 @
71aea2f
scripts/dotnet/TenVadModelConfig.cs
0 → 100644
查看文件 @
71aea2f
/// Copyright (c) 2025 Xiaomi Corporation (authors: Fangjun Kuang)
using
System.Runtime.InteropServices
;
namespace
SherpaOnnx
{
[
StructLayout
(
LayoutKind
.
Sequential
)]
public
struct
TenVadModelConfig
{
public
TenVadModelConfig
()
{
Model
=
""
;
Threshold
=
0.5F
;
MinSilenceDuration
=
0.5F
;
MinSpeechDuration
=
0.25F
;
WindowSize
=
256
;
MaxSpeechDuration
=
5.0F
;
}
[
MarshalAs
(
UnmanagedType
.
LPStr
)]
public
string
Model
;
public
float
Threshold
;
public
float
MinSilenceDuration
;
public
float
MinSpeechDuration
;
public
int
WindowSize
;
public
float
MaxSpeechDuration
;
}
}
...
...
scripts/dotnet/VadModelConfig.cs
查看文件 @
71aea2f
...
...
@@ -14,6 +14,7 @@ namespace SherpaOnnx
NumThreads
=
1
;
Provider
=
"cpu"
;
Debug
=
0
;
TenVad
=
new
TenVadModelConfig
();
}
public
SileroVadModelConfig
SileroVad
;
...
...
@@ -26,6 +27,8 @@ namespace SherpaOnnx
public
string
Provider
;
public
int
Debug
;
public
TenVadModelConfig
TenVad
;
}
}
...
...
请
注册
或
登录
后发表评论