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-08-15 14:48:11 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-08-15 14:48:11 +0800
Commit
7a8e52b7d308cc8c76fab351a9e780abea11fa55
7a8e52b7
1 parent
5c0f7f69
Fix java test (#2496)
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
31 行增加
和
34 行删除
.github/workflows/run-python-test-macos.yaml
.github/workflows/run-python-test.yaml
sherpa-onnx/csrc/offline-recognizer-transducer-nemo-impl.h
sherpa-onnx/java-api/Makefile
sherpa-onnx/java-api/src/main/java/com/k2fsa/sherpa/onnx/LibraryLoader.java
sherpa-onnx/java-api/src/main/java/com/k2fsa/sherpa/onnx/utils/LibraryUtils.java → sherpa-onnx/java-api/src/main/java/com/k2fsa/sherpa/onnx/LibraryUtils.java
sherpa-onnx/java-api/src/main/java/com/k2fsa/sherpa/onnx/core/Core.java
.github/workflows/run-python-test-macos.yaml
查看文件 @
7a8e52b
...
...
@@ -85,7 +85,7 @@ jobs:
-
name
:
Install Python dependencies
shell
:
bash
run
:
|
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile setuptools wheel
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile setuptools wheel
librosa
-
name
:
Install sherpa-onnx
shell
:
bash
...
...
.github/workflows/run-python-test.yaml
查看文件 @
7a8e52b
...
...
@@ -80,7 +80,7 @@ jobs:
-
name
:
Install Python dependencies
shell
:
bash
run
:
|
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece>=0.1.96 soundfile
librosa
python3 -m pip install wheel twine setuptools
-
uses
:
afoley587/setup-ffmpeg@main
...
...
sherpa-onnx/csrc/offline-recognizer-transducer-nemo-impl.h
查看文件 @
7a8e52b
...
...
@@ -47,7 +47,7 @@ class OfflineRecognizerTransducerNeMoImpl : public OfflineRecognizerImpl {
}
else
{
SHERPA_ONNX_LOGE
(
"Unsupported decoding method: %s"
,
config_
.
decoding_method
.
c_str
());
exit
(
-
1
);
SHERPA_ONNX_EXIT
(
-
1
);
}
PostInit
();
}
...
...
@@ -62,11 +62,11 @@ class OfflineRecognizerTransducerNeMoImpl : public OfflineRecognizerImpl {
mgr
,
config_
.
model_config
))
{
if
(
config_
.
decoding_method
==
"greedy_search"
)
{
decoder_
=
std
::
make_unique
<
OfflineTransducerGreedySearchNeMoDecoder
>
(
model_
.
get
(),
config_
.
blank_penalty
);
model_
.
get
(),
config_
.
blank_penalty
,
model_
->
IsTDT
()
);
}
else
{
SHERPA_ONNX_LOGE
(
"Unsupported decoding method: %s"
,
config_
.
decoding_method
.
c_str
());
exit
(
-
1
);
SHERPA_ONNX_EXIT
(
-
1
);
}
PostInit
();
...
...
@@ -175,18 +175,18 @@ class OfflineRecognizerTransducerNeMoImpl : public OfflineRecognizerImpl {
// check the blank ID
if
(
!
symbol_table_
.
Contains
(
"<blk>"
))
{
SHERPA_ONNX_LOGE
(
"tokens.txt does not include the blank token <blk>"
);
exit
(
-
1
);
SHERPA_ONNX_EXIT
(
-
1
);
}
if
(
symbol_table_
[
"<blk>"
]
!=
vocab_size
-
1
)
{
SHERPA_ONNX_LOGE
(
"<blk> is not the last token!"
);
exit
(
-
1
);
SHERPA_ONNX_EXIT
(
-
1
);
}
if
(
symbol_table_
.
NumSymbols
()
!=
vocab_size
)
{
SHERPA_ONNX_LOGE
(
"number of lines in tokens.txt %d != %d (vocab_size)"
,
symbol_table_
.
NumSymbols
(),
vocab_size
);
exit
(
-
1
);
SHERPA_ONNX_EXIT
(
-
1
);
}
}
...
...
sherpa-onnx/java-api/Makefile
查看文件 @
7a8e52b
...
...
@@ -6,7 +6,8 @@ out_jar := $(out_dir)/sherpa-onnx.jar
package_dir
:=
com/k2fsa/sherpa/onnx
java_files
:=
LibraryLoader.java
java_files
:=
LibraryUtils.java
java_files
+=
LibraryLoader.java
java_files
+=
VersionInfo.java
java_files
+=
WaveReader.java
...
...
sherpa-onnx/java-api/src/main/java/com/k2fsa/sherpa/onnx/LibraryLoader.java
查看文件 @
7a8e52b
package
com
.
k2fsa
.
sherpa
.
onnx
;
import
com.k2fsa.sherpa.onnx.utils.LibraryUtils
;
public
class
LibraryLoader
{
private
static
volatile
boolean
autoLoadEnabled
=
true
;
private
static
volatile
boolean
isLoaded
=
false
;
...
...
sherpa-onnx/java-api/src/main/java/com/k2fsa/sherpa/onnx/
utils/
LibraryUtils.java → sherpa-onnx/java-api/src/main/java/com/k2fsa/sherpa/onnx/LibraryUtils.java
查看文件 @
7a8e52b
package
com
.
k2fsa
.
sherpa
.
onnx
.
utils
;
package
com
.
k2fsa
.
sherpa
.
onnx
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -7,31 +7,34 @@ import java.nio.file.Files;
import
java.nio.file.StandardCopyOption
;
import
java.util.Locale
;
import
com.k2fsa.sherpa.onnx.core.Core
;
public
class
LibraryUtils
{
// System property to override native library path
private
static
final
String
NATIVE_PATH_PROP
=
"sherpa_onnx.native.path"
;
private
static
final
String
LIB_NAME
=
"sherpa-onnx-jni"
;
public
static
void
load
()
{
String
libFileName
=
System
.
mapLibraryName
(
Core
.
NATIVE_LIBRARY
_NAME
);
String
libFileName
=
System
.
mapLibraryName
(
LIB
_NAME
);
// 1. Try loading from external directory if provided
String
nativePath
=
System
.
getProperty
(
NATIVE_PATH_PROP
);
if
(
nativePath
!=
null
)
{
File
nativeDir
=
new
File
(
nativePath
);
File
libInDir
=
new
File
(
nativeDir
,
libFileName
);
if
(
nativeDir
.
isDirectory
()
&&
libInDir
.
exists
())
{
System
.
out
.
println
(
"Loading native lib from external directory: "
+
libInDir
.
getAbsolutePath
());
System
.
load
(
libInDir
.
getAbsolutePath
());
return
;
try
{
// 1. Try loading from external directory if provided
String
nativePath
=
System
.
getProperty
(
NATIVE_PATH_PROP
);
if
(
nativePath
!=
null
)
{
File
nativeDir
=
new
File
(
nativePath
);
File
libInDir
=
new
File
(
nativeDir
,
libFileName
);
if
(
nativeDir
.
isDirectory
()
&&
libInDir
.
exists
())
{
System
.
out
.
println
(
"Loading native lib from external directory: "
+
libInDir
.
getAbsolutePath
());
System
.
load
(
libInDir
.
getAbsolutePath
());
return
;
}
}
}
// 2. Fallback to extracting and loading from the JAR
File
libFile
=
init
(
libFileName
);
System
.
out
.
println
(
"Loading native lib from: "
+
libFile
.
getAbsolutePath
());
System
.
load
(
libFile
.
getAbsolutePath
());
// 2. Fallback to extracting and loading from the JAR
File
libFile
=
init
(
libFileName
);
System
.
out
.
println
(
"Loading native lib from: "
+
libFile
.
getAbsolutePath
());
System
.
load
(
libFile
.
getAbsolutePath
());
}
catch
(
RuntimeException
ex
)
{
System
.
loadLibrary
(
LIB_NAME
);
}
}
/* Computes and initializes OS_ARCH_STR (such as linux-x64) */
...
...
sherpa-onnx/java-api/src/main/java/com/k2fsa/sherpa/onnx/core/Core.java
已删除
100644 → 0
查看文件 @
5c0f7f6
package
com
.
k2fsa
.
sherpa
.
onnx
.
core
;
public
interface
Core
{
String
NATIVE_LIBRARY_NAME
=
"sherpa-onnx-jni"
;
}
请
注册
或
登录
后发表评论