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
esavin
2025-05-14 18:38:25 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-05-14 23:38:25 +0800
Commit
aeb311db50951a0585b8abbfbd06ca1a4e72130c
aeb311db
1 parent
2e9e0b4e
Expose dither for JNI (#2215)
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
21 行增加
和
0 行删除
sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/FeatureConfig.java
sherpa-onnx/jni/keyword-spotter.cc
sherpa-onnx/jni/offline-recognizer.cc
sherpa-onnx/jni/online-recognizer.cc
sherpa-onnx/kotlin-api/FeatureConfig.kt
sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/FeatureConfig.java
查看文件 @
aeb311d
...
...
@@ -6,10 +6,12 @@ package com.k2fsa.sherpa.onnx;
public
class
FeatureConfig
{
private
final
int
sampleRate
;
private
final
int
featureDim
;
private
final
float
dither
;
private
FeatureConfig
(
Builder
builder
)
{
this
.
sampleRate
=
builder
.
sampleRate
;
this
.
featureDim
=
builder
.
featureDim
;
this
.
dither
=
builder
.
dither
;
}
public
static
Builder
builder
()
{
...
...
@@ -24,9 +26,14 @@ public class FeatureConfig {
return
featureDim
;
}
public
float
getDither
()
{
return
dither
;
}
public
static
class
Builder
{
private
int
sampleRate
=
16000
;
private
int
featureDim
=
80
;
private
float
dither
=
0.0f
;
public
FeatureConfig
build
()
{
return
new
FeatureConfig
(
this
);
...
...
@@ -41,5 +48,9 @@ public class FeatureConfig {
this
.
featureDim
=
featureDim
;
return
this
;
}
public
Builder
setDither
(
float
dither
)
{
this
.
dither
=
dither
;
return
this
;
}
}
}
...
...
sherpa-onnx/jni/keyword-spotter.cc
查看文件 @
aeb311d
...
...
@@ -49,6 +49,9 @@ static KeywordSpotterConfig GetKwsConfig(JNIEnv *env, jobject config) {
fid
=
env
->
GetFieldID
(
feat_config_cls
,
"featureDim"
,
"I"
);
ans
.
feat_config
.
feature_dim
=
env
->
GetIntField
(
feat_config
,
fid
);
fid
=
env
->
GetFieldID
(
feat_config_cls
,
"dither"
,
"F"
);
ans
.
feat_config
.
dither
=
env
->
GetFloatField
(
feat_config
,
fid
);
//---------- model config ----------
fid
=
env
->
GetFieldID
(
cls
,
"modelConfig"
,
"Lcom/k2fsa/sherpa/onnx/OnlineModelConfig;"
);
...
...
sherpa-onnx/jni/offline-recognizer.cc
查看文件 @
aeb311d
...
...
@@ -62,6 +62,9 @@ static OfflineRecognizerConfig GetOfflineConfig(JNIEnv *env, jobject config) {
fid
=
env
->
GetFieldID
(
feat_config_cls
,
"featureDim"
,
"I"
);
ans
.
feat_config
.
feature_dim
=
env
->
GetIntField
(
feat_config
,
fid
);
fid
=
env
->
GetFieldID
(
feat_config_cls
,
"dither"
,
"F"
);
ans
.
feat_config
.
dither
=
env
->
GetFloatField
(
feat_config
,
fid
);
//---------- model config ----------
fid
=
env
->
GetFieldID
(
cls
,
"modelConfig"
,
"Lcom/k2fsa/sherpa/onnx/OfflineModelConfig;"
);
...
...
sherpa-onnx/jni/online-recognizer.cc
查看文件 @
aeb311d
...
...
@@ -65,6 +65,9 @@ static OnlineRecognizerConfig GetConfig(JNIEnv *env, jobject config) {
fid
=
env
->
GetFieldID
(
feat_config_cls
,
"featureDim"
,
"I"
);
ans
.
feat_config
.
feature_dim
=
env
->
GetIntField
(
feat_config
,
fid
);
fid
=
env
->
GetFieldID
(
feat_config_cls
,
"dither"
,
"F"
);
ans
.
feat_config
.
dither
=
env
->
GetFloatField
(
feat_config
,
fid
);
//---------- enable endpoint ----------
fid
=
env
->
GetFieldID
(
cls
,
"enableEndpoint"
,
"Z"
);
ans
.
enable_endpoint
=
env
->
GetBooleanField
(
config
,
fid
);
...
...
sherpa-onnx/kotlin-api/FeatureConfig.kt
查看文件 @
aeb311d
...
...
@@ -3,6 +3,7 @@ package com.k2fsa.sherpa.onnx
data class FeatureConfig(
var sampleRate: Int = 16000,
var featureDim: Int = 80,
var dither: Float = 0.0f
)
fun getFeatureConfig(sampleRate: Int, featureDim: Int): FeatureConfig {
...
...
请
注册
或
登录
后发表评论