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
2024-08-08 10:43:31 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-08-08 10:43:31 +0800
Commit
94e256244d3ed15123f1ab159839c5ae62454d3d
94e25624
1 parent
ba4cb616
Add blank penalty for various language bindings. (#1234)
显示空白字符变更
内嵌
并排对比
正在显示
38 个修改的文件
包含
121 行增加
和
40 行删除
.gitignore
CHANGELOG.md
CMakeLists.txt
build-ios-no-tts.sh
dart-api-examples/add-punctuations/pubspec.yaml
dart-api-examples/audio-tagging/pubspec.yaml
dart-api-examples/keyword-spotter/pubspec.yaml
dart-api-examples/non-streaming-asr/pubspec.yaml
dart-api-examples/speaker-identification/pubspec.yaml
dart-api-examples/streaming-asr/pubspec.yaml
dart-api-examples/tts/pubspec.yaml
dart-api-examples/vad-with-non-streaming-asr/pubspec.yaml
dart-api-examples/vad/pubspec.yaml
flutter-examples/streaming_asr/pubspec.yaml
flutter-examples/tts/pubspec.yaml
flutter/sherpa_onnx/lib/src/offline_recognizer.dart
flutter/sherpa_onnx/lib/src/online_recognizer.dart
flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart
flutter/sherpa_onnx/pubspec.yaml
flutter/sherpa_onnx_ios/ios/sherpa_onnx_ios.podspec
flutter/sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
nodejs-addon-examples/package.json
scripts/dotnet/OfflineRecognizerConfig.cs
scripts/dotnet/OnlineRecognizerConfig.cs
scripts/node-addon-api/src/non-streaming-asr.cc
scripts/node-addon-api/src/streaming-asr.cc
sherpa-onnx/c-api/c-api.cc
sherpa-onnx/c-api/c-api.h
sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/OfflineRecognizerConfig.java
sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/OnlineRecognizerConfig.java
sherpa-onnx/jni/offline-recognizer.cc
sherpa-onnx/jni/online-recognizer.cc
sherpa-onnx/kotlin-api/OfflineRecognizer.kt
sherpa-onnx/kotlin-api/OnlineRecognizer.kt
swift-api-examples/SherpaOnnx.swift
wasm/asr/sherpa-onnx-asr.js
wasm/asr/sherpa-onnx-wasm-main-asr.cc
wasm/nodejs/sherpa-onnx-wasm-nodejs.cc
.gitignore
查看文件 @
94e2562
...
...
@@ -113,3 +113,4 @@ sherpa-onnx-telespeech-ctc-*
lib*.a
sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17
*.bak
vits-melo-tts-zh_en
...
...
CHANGELOG.md
查看文件 @
94e2562
## 1.10.21
*
Fix ffmpeg c api example (#1185)
*
Fix splitting sentences for MeloTTS (#1186)
*
Non-streaming WebSocket client for Java. (#1190)
*
Fix copying asset files for flutter examples. (#1191)
*
Add Chinese+English tts example for flutter (#1192)
*
Add speaker identification and verification exmaple for Dart API (#1194)
*
Fix reading non-standard wav files. (#1199)
*
Add ReazonSpeech Japanese pre-trained model (#1203)
*
Describe how to add new words for MeloTTS models (#1209)
*
Remove libonnxruntime_providers_cuda.so as a dependency. (#1210)
*
Fix setting SenseVoice language. (#1214)
*
Support passing TTS callback in Swift API (#1218)
*
Add MeloTTS example for ios (#1223)
*
Add online punctuation and casing prediction model for English language (#1224)
*
Fix python two pass ASR examples (#1230)
*
Add blank penalty for various language bindings
## 1.10.20
*
Add Dart API for audio tagging
...
...
CMakeLists.txt
查看文件 @
94e2562
...
...
@@ -11,7 +11,7 @@ project(sherpa-onnx)
# ./nodejs-addon-examples
# ./dart-api-examples/
# ./CHANGELOG.md
set
(
SHERPA_ONNX_VERSION
"1.10.2
0
"
)
set
(
SHERPA_ONNX_VERSION
"1.10.2
1
"
)
# Disable warning about
#
...
...
build-ios-no-tts.sh
查看文件 @
94e2562
...
...
@@ -126,7 +126,7 @@ echo "Generate xcframework"
mkdir -p
"build/simulator/lib"
for
f
in
libkaldi-native-fbank-core.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a
\
libsherpa-onnx-fst.a libsherpa-onnx-kaldifst-core.a libkaldi-decoder-core.a libssentencepiece_core.a;
do
libsherpa-onnx-fst.a libsherpa-onnx-
fstfar.a libsherpa-onnx-
kaldifst-core.a libkaldi-decoder-core.a libssentencepiece_core.a;
do
lipo -create build/simulator_arm64/lib/
${
f
}
\
build/simulator_x86_64/lib/
${
f
}
\
-output build/simulator/lib/
${
f
}
...
...
@@ -139,6 +139,7 @@ libtool -static -o build/simulator/sherpa-onnx.a \
build/simulator/lib/libsherpa-onnx-c-api.a
\
build/simulator/lib/libsherpa-onnx-core.a
\
build/simulator/lib/libsherpa-onnx-fst.a
\
build/simulator/lib/libsherpa-onnx-fstfar.a
\
build/simulator/lib/libsherpa-onnx-kaldifst-core.a
\
build/simulator/lib/libkaldi-decoder-core.a
\
build/simulator/lib/libssentencepiece_core.a
...
...
@@ -148,6 +149,7 @@ libtool -static -o build/os64/sherpa-onnx.a \
build/os64/lib/libsherpa-onnx-c-api.a
\
build/os64/lib/libsherpa-onnx-core.a
\
build/os64/lib/libsherpa-onnx-fst.a
\
build/os64/lib/libsherpa-onnx-fstfar.a
\
build/os64/lib/libsherpa-onnx-kaldifst-core.a
\
build/os64/lib/libkaldi-decoder-core.a
\
build/os64/lib/libssentencepiece_core.a
...
...
dart-api-examples/add-punctuations/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -9,7 +9,7 @@ environment:
sdk
:
^3.4.0
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
path
:
^1.9.0
args
:
^2.5.0
...
...
dart-api-examples/audio-tagging/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -9,7 +9,7 @@ environment:
sdk
:
^3.4.0
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
path
:
^1.9.0
args
:
^2.5.0
...
...
dart-api-examples/keyword-spotter/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -9,7 +9,7 @@ environment:
sdk
:
^3.4.0
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
# sherpa_onnx:
# path: ../../flutter/sherpa_onnx
path
:
^1.9.0
...
...
dart-api-examples/non-streaming-asr/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -10,7 +10,7 @@ environment:
# Add regular dependencies here.
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
path
:
^1.9.0
args
:
^2.5.0
...
...
dart-api-examples/speaker-identification/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -9,7 +9,7 @@ environment:
sdk
:
^3.4.0
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
path
:
^1.9.0
args
:
^2.5.0
...
...
dart-api-examples/streaming-asr/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -11,7 +11,7 @@ environment:
# Add regular dependencies here.
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
path
:
^1.9.0
args
:
^2.5.0
...
...
dart-api-examples/tts/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -8,7 +8,7 @@ environment:
# Add regular dependencies here.
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
path
:
^1.9.0
args
:
^2.5.0
...
...
dart-api-examples/vad-with-non-streaming-asr/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -10,7 +10,7 @@ environment:
sdk
:
^3.4.0
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
path
:
^1.9.0
args
:
^2.5.0
...
...
dart-api-examples/vad/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -9,7 +9,7 @@ environment:
sdk
:
^3.4.0
dependencies
:
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
path
:
^1.9.0
args
:
^2.5.0
...
...
flutter-examples/streaming_asr/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -5,7 +5,7 @@ description: >
publish_to
:
'
none'
version
:
1.10.2
0
version
:
1.10.2
1
topics
:
-
speech-recognition
...
...
@@ -30,7 +30,7 @@ dependencies:
record
:
^5.1.0
url_launcher
:
^6.2.6
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
# sherpa_onnx:
# path: ../../flutter/sherpa_onnx
...
...
flutter-examples/tts/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -5,7 +5,7 @@ description: >
publish_to
:
'
none'
# Remove this line if you wish to publish to pub.dev
version
:
1.10.2
0
version
:
1.10.2
1
environment
:
sdk
:
'
>=3.4.0
<4.0.0'
...
...
@@ -17,7 +17,7 @@ dependencies:
cupertino_icons
:
^1.0.6
path_provider
:
^2.1.3
path
:
^1.9.0
sherpa_onnx
:
^1.10.2
0
sherpa_onnx
:
^1.10.2
1
url_launcher
:
^6.2.6
audioplayers
:
^5.0.0
...
...
flutter/sherpa_onnx/lib/src/offline_recognizer.dart
查看文件 @
94e2562
...
...
@@ -159,11 +159,12 @@ class OfflineRecognizerConfig {
this
.
hotwordsScore
=
1.5
,
this
.
ruleFsts
=
''
,
this
.
ruleFars
=
''
,
this
.
blankPenalty
=
0.0
,
});
@override
String
toString
()
{
return
'OfflineRecognizerConfig(feat:
$feat
, model:
$model
, lm:
$lm
, decodingMethod:
$decodingMethod
, maxActivePaths:
$maxActivePaths
, hotwordsFile:
$hotwordsFile
, hotwordsScore:
$hotwordsScore
, ruleFsts:
$ruleFsts
, ruleFars:
$ruleFars
)'
;
return
'OfflineRecognizerConfig(feat:
$feat
, model:
$model
, lm:
$lm
, decodingMethod:
$decodingMethod
, maxActivePaths:
$maxActivePaths
, hotwordsFile:
$hotwordsFile
, hotwordsScore:
$hotwordsScore
, ruleFsts:
$ruleFsts
, ruleFars:
$ruleFars
, blankPenalty:
$blankPenalty
)'
;
}
final
FeatureConfig
feat
;
...
...
@@ -179,6 +180,8 @@ class OfflineRecognizerConfig {
final
String
ruleFsts
;
final
String
ruleFars
;
final
double
blankPenalty
;
}
class
OfflineRecognizerResult
{
...
...
@@ -268,6 +271,8 @@ class OfflineRecognizer {
c
.
ref
.
ruleFsts
=
config
.
ruleFsts
.
toNativeUtf8
();
c
.
ref
.
ruleFars
=
config
.
ruleFars
.
toNativeUtf8
();
c
.
ref
.
blankPenalty
=
config
.
blankPenalty
;
final
ptr
=
SherpaOnnxBindings
.
createOfflineRecognizer
?.
call
(
c
)
??
nullptr
;
calloc
.
free
(
c
.
ref
.
ruleFars
);
...
...
flutter/sherpa_onnx/lib/src/online_recognizer.dart
查看文件 @
94e2562
...
...
@@ -114,11 +114,12 @@ class OnlineRecognizerConfig {
this
.
ctcFstDecoderConfig
=
const
OnlineCtcFstDecoderConfig
(),
this
.
ruleFsts
=
''
,
this
.
ruleFars
=
''
,
this
.
blankPenalty
=
0.0
,
});
@override
String
toString
()
{
return
'OnlineRecognizerConfig(feat:
$feat
, model:
$model
, decodingMethod:
$decodingMethod
, maxActivePaths:
$maxActivePaths
, enableEndpoint:
$enableEndpoint
, rule1MinTrailingSilence:
$rule1MinTrailingSilence
, rule2MinTrailingSilence:
$rule2MinTrailingSilence
, rule3MinUtteranceLength:
$rule3MinUtteranceLength
, hotwordsFile:
$hotwordsFile
, hotwordsScore:
$hotwordsScore
, ctcFstDecoderConfig:
$ctcFstDecoderConfig
, ruleFsts:
$ruleFsts
, ruleFars:
$ruleFars
)'
;
return
'OnlineRecognizerConfig(feat:
$feat
, model:
$model
, decodingMethod:
$decodingMethod
, maxActivePaths:
$maxActivePaths
, enableEndpoint:
$enableEndpoint
, rule1MinTrailingSilence:
$rule1MinTrailingSilence
, rule2MinTrailingSilence:
$rule2MinTrailingSilence
, rule3MinUtteranceLength:
$rule3MinUtteranceLength
, hotwordsFile:
$hotwordsFile
, hotwordsScore:
$hotwordsScore
, ctcFstDecoderConfig:
$ctcFstDecoderConfig
, ruleFsts:
$ruleFsts
, ruleFars:
$ruleFars
, blankPenalty:
$blankPenalty
)'
;
}
final
FeatureConfig
feat
;
...
...
@@ -142,6 +143,8 @@ class OnlineRecognizerConfig {
final
OnlineCtcFstDecoderConfig
ctcFstDecoderConfig
;
final
String
ruleFsts
;
final
String
ruleFars
;
final
double
blankPenalty
;
}
class
OnlineRecognizerResult
{
...
...
@@ -209,6 +212,8 @@ class OnlineRecognizer {
c
.
ref
.
ruleFsts
=
config
.
ruleFsts
.
toNativeUtf8
();
c
.
ref
.
ruleFars
=
config
.
ruleFars
.
toNativeUtf8
();
c
.
ref
.
blankPenalty
=
config
.
blankPenalty
;
final
ptr
=
SherpaOnnxBindings
.
createOnlineRecognizer
?.
call
(
c
)
??
nullptr
;
calloc
.
free
(
c
.
ref
.
ruleFars
);
...
...
flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart
查看文件 @
94e2562
...
...
@@ -194,6 +194,9 @@ final class SherpaOnnxOfflineRecognizerConfig extends Struct {
external
Pointer
<
Utf8
>
ruleFsts
;
external
Pointer
<
Utf8
>
ruleFars
;
@Float
()
external
double
blankPenalty
;
}
final
class
SherpaOnnxOnlineTransducerModelConfig
extends
Struct
{
...
...
@@ -269,6 +272,9 @@ final class SherpaOnnxOnlineRecognizerConfig extends Struct {
external
Pointer
<
Utf8
>
ruleFsts
;
external
Pointer
<
Utf8
>
ruleFars
;
@Float
()
external
double
blankPenalty
;
}
final
class
SherpaOnnxSileroVadModelConfig
extends
Struct
{
...
...
flutter/sherpa_onnx/pubspec.yaml
查看文件 @
94e2562
...
...
@@ -17,7 +17,7 @@ topics:
-
voice-activity-detection
# remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
version
:
1.10.2
0
version
:
1.10.2
1
homepage
:
https://github.com/k2-fsa/sherpa-onnx
...
...
@@ -30,23 +30,23 @@ dependencies:
flutter
:
sdk
:
flutter
sherpa_onnx_android
:
^1.10.2
0
sherpa_onnx_android
:
^1.10.2
1
# sherpa_onnx_android:
# path: ../sherpa_onnx_android
sherpa_onnx_macos
:
^1.10.2
0
sherpa_onnx_macos
:
^1.10.2
1
# sherpa_onnx_macos:
# path: ../sherpa_onnx_macos
sherpa_onnx_linux
:
^1.10.2
0
sherpa_onnx_linux
:
^1.10.2
1
# sherpa_onnx_linux:
# path: ../sherpa_onnx_linux
#
sherpa_onnx_windows
:
^1.10.2
0
sherpa_onnx_windows
:
^1.10.2
1
# sherpa_onnx_windows:
# path: ../sherpa_onnx_windows
sherpa_onnx_ios
:
^1.10.2
0
sherpa_onnx_ios
:
^1.10.2
1
# sherpa_onnx_ios:
# path: ../sherpa_onnx_ios
...
...
flutter/sherpa_onnx_ios/ios/sherpa_onnx_ios.podspec
查看文件 @
94e2562
...
...
@@ -7,7 +7,7 @@
# https://groups.google.com/g/dart-ffi/c/nUATMBy7r0c
Pod
::
Spec
.
new
do
|
s
|
s
.
name
=
'sherpa_onnx_ios'
s
.
version
=
'1.10.2
0
'
s
.
version
=
'1.10.2
1
'
s
.
summary
=
'A new Flutter FFI plugin project.'
s
.
description
=
<<-
DESC
A new Flutter FFI plugin project.
...
...
flutter/sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
查看文件 @
94e2562
...
...
@@ -4,7 +4,7 @@
#
Pod
::
Spec
.
new
do
|
s
|
s
.
name
=
'sherpa_onnx_macos'
s
.
version
=
'1.10.2
0
'
s
.
version
=
'1.10.2
1
'
s
.
summary
=
'sherpa-onnx Flutter FFI plugin project.'
s
.
description
=
<<-
DESC
sherpa-onnx Flutter FFI plugin project.
...
...
nodejs-addon-examples/package.json
查看文件 @
94e2562
{
"dependencies"
:
{
"sherpa-onnx-node"
:
"^1.10.2
0
"
"sherpa-onnx-node"
:
"^1.10.2
1
"
}
}
...
...
scripts/dotnet/OfflineRecognizerConfig.cs
查看文件 @
94e2562
...
...
@@ -4,7 +4,6 @@ using System.Runtime.InteropServices;
namespace
SherpaOnnx
{
[
StructLayout
(
LayoutKind
.
Sequential
)]
public
struct
OfflineRecognizerConfig
{
...
...
@@ -20,6 +19,7 @@ namespace SherpaOnnx
HotwordsScore
=
1.5F
;
RuleFsts
=
""
;
RuleFars
=
""
;
BlankPenalty
=
0.0F
;
}
public
FeatureConfig
FeatConfig
;
public
OfflineModelConfig
ModelConfig
;
...
...
@@ -40,7 +40,7 @@ namespace SherpaOnnx
[
MarshalAs
(
UnmanagedType
.
LPStr
)]
public
string
RuleFars
;
}
public
float
BlankPenalty
;
}
}
...
...
scripts/dotnet/OnlineRecognizerConfig.cs
查看文件 @
94e2562
...
...
@@ -25,6 +25,7 @@ namespace SherpaOnnx
CtcFstDecoderConfig
=
new
OnlineCtcFstDecoderConfig
();
RuleFsts
=
""
;
RuleFars
=
""
;
BlankPenalty
=
0.0F
;
}
public
FeatureConfig
FeatConfig
;
public
OnlineModelConfig
ModelConfig
;
...
...
@@ -69,6 +70,7 @@ namespace SherpaOnnx
[
MarshalAs
(
UnmanagedType
.
LPStr
)]
public
string
RuleFars
;
}
public
float
BlankPenalty
;
}
}
...
...
scripts/node-addon-api/src/non-streaming-asr.cc
查看文件 @
94e2562
...
...
@@ -201,6 +201,7 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) {
SHERPA_ONNX_ASSIGN_ATTR_FLOAT
(
hotwords_score
,
hotwordsScore
);
SHERPA_ONNX_ASSIGN_ATTR_STR
(
rule_fsts
,
ruleFsts
);
SHERPA_ONNX_ASSIGN_ATTR_STR
(
rule_fars
,
ruleFars
);
SHERPA_ONNX_ASSIGN_ATTR_FLOAT
(
blank_penalty
,
blankPenalty
);
SherpaOnnxOfflineRecognizer
*
recognizer
=
SherpaOnnxCreateOfflineRecognizer
(
&
c
);
...
...
scripts/node-addon-api/src/streaming-asr.cc
查看文件 @
94e2562
...
...
@@ -191,6 +191,7 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
SHERPA_ONNX_ASSIGN_ATTR_FLOAT
(
hotwords_score
,
hotwordsScore
);
SHERPA_ONNX_ASSIGN_ATTR_STR
(
rule_fsts
,
ruleFsts
);
SHERPA_ONNX_ASSIGN_ATTR_STR
(
rule_fars
,
ruleFars
);
SHERPA_ONNX_ASSIGN_ATTR_FLOAT
(
blank_penalty
,
blankPenalty
);
c
.
ctc_fst_decoder_config
=
GetCtcFstDecoderConfig
(
o
);
...
...
sherpa-onnx/c-api/c-api.cc
查看文件 @
94e2562
...
...
@@ -105,7 +105,7 @@ SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer(
recognizer_config
.
hotwords_score
=
SHERPA_ONNX_OR
(
config
->
hotwords_score
,
1.5
);
recognizer_config
.
blank_penalty
=
SHERPA_ONNX_OR
(
config
->
blank_penalty
,
0.0
)
;
recognizer_config
.
blank_penalty
=
config
->
blank_penalty
;
recognizer_config
.
ctc_fst_decoder_config
.
graph
=
SHERPA_ONNX_OR
(
config
->
ctc_fst_decoder_config
.
graph
,
""
);
...
...
@@ -429,6 +429,8 @@ sherpa_onnx::OfflineRecognizerConfig convertConfig(
recognizer_config
.
hotwords_score
=
SHERPA_ONNX_OR
(
config
->
hotwords_score
,
1.5
);
recognizer_config
.
blank_penalty
=
config
->
blank_penalty
;
recognizer_config
.
rule_fsts
=
SHERPA_ONNX_OR
(
config
->
rule_fsts
,
""
);
recognizer_config
.
rule_fars
=
SHERPA_ONNX_OR
(
config
->
rule_fars
,
""
);
...
...
sherpa-onnx/c-api/c-api.h
查看文件 @
94e2562
...
...
@@ -142,11 +142,11 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerConfig {
/// Bonus score for each token in hotwords.
float
hotwords_score
;
float
blank_penalty
;
SherpaOnnxOnlineCtcFstDecoderConfig
ctc_fst_decoder_config
;
const
char
*
rule_fsts
;
const
char
*
rule_fars
;
float
blank_penalty
;
}
SherpaOnnxOnlineRecognizerConfig
;
SHERPA_ONNX_API
typedef
struct
SherpaOnnxOnlineRecognizerResult
{
...
...
@@ -430,6 +430,7 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizerConfig {
float
hotwords_score
;
const
char
*
rule_fsts
;
const
char
*
rule_fars
;
float
blank_penalty
;
}
SherpaOnnxOfflineRecognizerConfig
;
SHERPA_ONNX_API
typedef
struct
SherpaOnnxOfflineRecognizer
...
...
sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/OfflineRecognizerConfig.java
查看文件 @
94e2562
...
...
@@ -11,6 +11,7 @@ public class OfflineRecognizerConfig {
private
final
float
hotwordsScore
;
private
final
String
ruleFsts
;
private
final
String
ruleFars
;
private
final
float
blankPenalty
;
private
OfflineRecognizerConfig
(
Builder
builder
)
{
this
.
featConfig
=
builder
.
featConfig
;
...
...
@@ -21,6 +22,7 @@ public class OfflineRecognizerConfig {
this
.
hotwordsScore
=
builder
.
hotwordsScore
;
this
.
ruleFsts
=
builder
.
ruleFsts
;
this
.
ruleFars
=
builder
.
ruleFars
;
this
.
blankPenalty
=
builder
.
blankPenalty
;
}
public
static
Builder
builder
()
{
...
...
@@ -40,6 +42,7 @@ public class OfflineRecognizerConfig {
private
float
hotwordsScore
=
1.5f
;
private
String
ruleFsts
=
""
;
private
String
ruleFars
=
""
;
private
float
blankPenalty
=
0.0f
;
public
OfflineRecognizerConfig
build
()
{
return
new
OfflineRecognizerConfig
(
this
);
...
...
@@ -84,5 +87,10 @@ public class OfflineRecognizerConfig {
this
.
ruleFars
=
ruleFars
;
return
this
;
}
public
Builder
setBlankPenalty
(
float
blankPenalty
)
{
this
.
blankPenalty
=
blankPenalty
;
return
this
;
}
}
}
...
...
sherpa-onnx/java-api/src/com/k2fsa/sherpa/onnx/OnlineRecognizerConfig.java
查看文件 @
94e2562
...
...
@@ -17,6 +17,7 @@ public class OnlineRecognizerConfig {
private
final
float
hotwordsScore
;
private
final
String
ruleFsts
;
private
final
String
ruleFars
;
private
final
float
blankPenalty
;
private
OnlineRecognizerConfig
(
Builder
builder
)
{
this
.
featConfig
=
builder
.
featConfig
;
...
...
@@ -31,6 +32,7 @@ public class OnlineRecognizerConfig {
this
.
hotwordsScore
=
builder
.
hotwordsScore
;
this
.
ruleFsts
=
builder
.
ruleFsts
;
this
.
ruleFars
=
builder
.
ruleFars
;
this
.
blankPenalty
=
builder
.
blankPenalty
;
}
public
static
Builder
builder
()
{
...
...
@@ -54,6 +56,7 @@ public class OnlineRecognizerConfig {
private
float
hotwordsScore
=
1.5f
;
private
String
ruleFsts
=
""
;
private
String
ruleFars
=
""
;
private
float
blankPenalty
=
0.0f
;
public
OnlineRecognizerConfig
build
()
{
return
new
OnlineRecognizerConfig
(
this
);
...
...
@@ -118,5 +121,10 @@ public class OnlineRecognizerConfig {
this
.
ruleFars
=
ruleFars
;
return
this
;
}
public
Builder
setBlankPenalty
(
float
blankPenalty
)
{
this
.
blankPenalty
=
blankPenalty
;
return
this
;
}
}
}
...
...
sherpa-onnx/jni/offline-recognizer.cc
查看文件 @
94e2562
...
...
@@ -46,6 +46,9 @@ static OfflineRecognizerConfig GetOfflineConfig(JNIEnv *env, jobject config) {
ans
.
rule_fars
=
p
;
env
->
ReleaseStringUTFChars
(
s
,
p
);
fid
=
env
->
GetFieldID
(
cls
,
"blankPenalty"
,
"F"
);
ans
.
blank_penalty
=
env
->
GetFloatField
(
config
,
fid
);
//---------- feat config ----------
fid
=
env
->
GetFieldID
(
cls
,
"featConfig"
,
"Lcom/k2fsa/sherpa/onnx/FeatureConfig;"
);
...
...
sherpa-onnx/jni/online-recognizer.cc
查看文件 @
94e2562
...
...
@@ -49,6 +49,9 @@ static OnlineRecognizerConfig GetConfig(JNIEnv *env, jobject config) {
ans
.
rule_fars
=
p
;
env
->
ReleaseStringUTFChars
(
s
,
p
);
fid
=
env
->
GetFieldID
(
cls
,
"blankPenalty"
,
"F"
);
ans
.
blank_penalty
=
env
->
GetFloatField
(
config
,
fid
);
//---------- feat config ----------
fid
=
env
->
GetFieldID
(
cls
,
"featConfig"
,
"Lcom/k2fsa/sherpa/onnx/FeatureConfig;"
);
...
...
sherpa-onnx/kotlin-api/OfflineRecognizer.kt
查看文件 @
94e2562
...
...
@@ -62,6 +62,7 @@ data class OfflineRecognizerConfig(
var hotwordsScore: Float = 1.5f,
var ruleFsts: String = "",
var ruleFars: String = "",
var blankPenalty: Float = 0.0f,
)
class OfflineRecognizer(
...
...
sherpa-onnx/kotlin-api/OnlineRecognizer.kt
查看文件 @
94e2562
...
...
@@ -71,6 +71,7 @@ data class OnlineRecognizerConfig(
var hotwordsScore: Float = 1.5f,
var ruleFsts: String = "",
var ruleFars: String = "",
var blankPenalty: Float = 0.0f,
)
data class OnlineRecognizerResult(
...
...
swift-api-examples/SherpaOnnx.swift
查看文件 @
94e2562
...
...
@@ -137,7 +137,8 @@ func sherpaOnnxOnlineRecognizerConfig(
hotwordsScore
:
Float
=
1.5
,
ctcFstDecoderConfig
:
SherpaOnnxOnlineCtcFstDecoderConfig
=
sherpaOnnxOnlineCtcFstDecoderConfig
(),
ruleFsts
:
String
=
""
,
ruleFars
:
String
=
""
ruleFars
:
String
=
""
,
blankPenalty
:
Float
=
0.0
)
->
SherpaOnnxOnlineRecognizerConfig
{
return
SherpaOnnxOnlineRecognizerConfig
(
feat_config
:
featConfig
,
...
...
@@ -152,7 +153,8 @@ func sherpaOnnxOnlineRecognizerConfig(
hotwords_score
:
hotwordsScore
,
ctc_fst_decoder_config
:
ctcFstDecoderConfig
,
rule_fsts
:
toCPointer
(
ruleFsts
),
rule_fars
:
toCPointer
(
ruleFars
)
rule_fars
:
toCPointer
(
ruleFars
),
blank_penalty
:
blankPenalty
)
}
...
...
@@ -420,7 +422,8 @@ func sherpaOnnxOfflineRecognizerConfig(
hotwordsFile
:
String
=
""
,
hotwordsScore
:
Float
=
1.5
,
ruleFsts
:
String
=
""
,
ruleFars
:
String
=
""
ruleFars
:
String
=
""
,
blankPenalty
:
Float
=
0.0
)
->
SherpaOnnxOfflineRecognizerConfig
{
return
SherpaOnnxOfflineRecognizerConfig
(
feat_config
:
featConfig
,
...
...
@@ -431,7 +434,8 @@ func sherpaOnnxOfflineRecognizerConfig(
hotwords_file
:
toCPointer
(
hotwordsFile
),
hotwords_score
:
hotwordsScore
,
rule_fsts
:
toCPointer
(
ruleFsts
),
rule_fars
:
toCPointer
(
ruleFars
)
rule_fars
:
toCPointer
(
ruleFars
),
blank_penalty
:
blankPenalty
)
}
...
...
wasm/asr/sherpa-onnx-asr.js
查看文件 @
94e2562
...
...
@@ -280,7 +280,7 @@ function initSherpaOnnxOnlineRecognizerConfig(config, Module) {
const
ctcFstDecoder
=
initSherpaOnnxOnlineCtcFstDecoderConfig
(
config
.
ctcFstDecoderConfig
,
Module
)
const
len
=
feat
.
len
+
model
.
len
+
8
*
4
+
ctcFstDecoder
.
len
+
2
*
4
;
const
len
=
feat
.
len
+
model
.
len
+
8
*
4
+
ctcFstDecoder
.
len
+
3
*
4
;
const
ptr
=
Module
.
_malloc
(
len
);
let
offset
=
0
;
...
...
@@ -351,6 +351,9 @@ function initSherpaOnnxOnlineRecognizerConfig(config, Module) {
buffer
+
decodingMethodLen
+
hotwordsFileLen
+
ruleFstsFileLen
,
'i8*'
);
offset
+=
4
;
Module
.
setValue
(
ptr
+
offset
,
config
.
blankPenalty
||
0
,
'float'
);
offset
+=
4
;
return
{
buffer
:
buffer
,
ptr
:
ptr
,
len
:
len
,
feat
:
feat
,
model
:
model
,
ctcFstDecoder
:
ctcFstDecoder
...
...
@@ -796,7 +799,7 @@ function initSherpaOnnxOfflineRecognizerConfig(config, Module) {
const
model
=
initSherpaOnnxOfflineModelConfig
(
config
.
modelConfig
,
Module
);
const
lm
=
initSherpaOnnxOfflineLMConfig
(
config
.
lmConfig
,
Module
);
const
len
=
feat
.
len
+
model
.
len
+
lm
.
len
+
6
*
4
;
const
len
=
feat
.
len
+
model
.
len
+
lm
.
len
+
7
*
4
;
const
ptr
=
Module
.
_malloc
(
len
);
let
offset
=
0
;
...
...
@@ -856,6 +859,9 @@ function initSherpaOnnxOfflineRecognizerConfig(config, Module) {
'i8*'
);
offset
+=
4
;
Module
.
setValue
(
ptr
+
offset
,
config
.
blankPenalty
||
0
,
'float'
);
offset
+=
4
;
return
{
buffer
:
buffer
,
ptr
:
ptr
,
len
:
len
,
feat
:
feat
,
model
:
model
,
lm
:
lm
}
...
...
wasm/asr/sherpa-onnx-wasm-main-asr.cc
查看文件 @
94e2562
...
...
@@ -26,7 +26,7 @@ static_assert(sizeof(SherpaOnnxOnlineCtcFstDecoderConfig) == 2 * 4, "");
static_assert
(
sizeof
(
SherpaOnnxOnlineRecognizerConfig
)
==
sizeof
(
SherpaOnnxFeatureConfig
)
+
sizeof
(
SherpaOnnxOnlineModelConfig
)
+
8
*
4
+
sizeof
(
SherpaOnnxOnlineCtcFstDecoderConfig
)
+
2
*
4
,
sizeof
(
SherpaOnnxOnlineCtcFstDecoderConfig
)
+
3
*
4
,
""
);
void
MyPrint
(
SherpaOnnxOnlineRecognizerConfig
*
config
)
{
...
...
@@ -73,6 +73,7 @@ void MyPrint(SherpaOnnxOnlineRecognizerConfig *config) {
fprintf
(
stdout
,
"hotwords_score: %.2f
\n
"
,
config
->
hotwords_score
);
fprintf
(
stdout
,
"rule_fsts: %s
\n
"
,
config
->
rule_fsts
);
fprintf
(
stdout
,
"rule_fars: %s
\n
"
,
config
->
rule_fars
);
fprintf
(
stdout
,
"blank_penalty: %f
\n
"
,
config
->
blank_penalty
);
fprintf
(
stdout
,
"----------ctc fst decoder config----------
\n
"
);
fprintf
(
stdout
,
"graph: %s
\n
"
,
config
->
ctc_fst_decoder_config
.
graph
);
...
...
wasm/nodejs/sherpa-onnx-wasm-nodejs.cc
查看文件 @
94e2562
...
...
@@ -31,7 +31,7 @@ static_assert(sizeof(SherpaOnnxFeatureConfig) == 2 * 4, "");
static_assert
(
sizeof
(
SherpaOnnxOfflineRecognizerConfig
)
==
sizeof
(
SherpaOnnxFeatureConfig
)
+
sizeof
(
SherpaOnnxOfflineLMConfig
)
+
sizeof
(
SherpaOnnxOfflineModelConfig
)
+
6
*
4
,
sizeof
(
SherpaOnnxOfflineModelConfig
)
+
7
*
4
,
""
);
void
PrintOfflineTtsConfig
(
SherpaOnnxOfflineTtsConfig
*
tts_config
)
{
...
...
@@ -113,6 +113,7 @@ void PrintOfflineRecognizerConfig(SherpaOnnxOfflineRecognizerConfig *config) {
fprintf
(
stdout
,
"hotwords_score: %.2f
\n
"
,
config
->
hotwords_score
);
fprintf
(
stdout
,
"rule_fsts: %s
\n
"
,
config
->
rule_fsts
);
fprintf
(
stdout
,
"rule_fars: %s
\n
"
,
config
->
rule_fars
);
fprintf
(
stdout
,
"blank_penalty: %f
\n
"
,
config
->
blank_penalty
);
}
void
CopyHeap
(
const
char
*
src
,
int32_t
num_bytes
,
char
*
dst
)
{
...
...
请
注册
或
登录
后发表评论