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-04-29 15:59:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2025-04-29 15:59:34 +0800
Commit
51f8824219538a18ae836849b65a6a42c27efb50
51f88242
1 parent
73dba271
Add homonphone replacer example for Python API. (#2161)
显示空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
133 行增加
和
2 行删除
.github/scripts/test-offline-transducer.sh
.github/workflows/rknn-linux-aarch64.yaml
python-api-examples/speech-recognition-from-microphone-with-endpoint-detection-alsa.py
python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py
python-api-examples/speech-recognition-from-microphone.py
python-api-examples/speech-recognition-from-url.py
python-api-examples/vad-with-non-streaming-asr.py
.github/scripts/test-offline-transducer.sh
查看文件 @
51f8824
...
...
@@ -30,7 +30,7 @@ $EXE \
--model-type
=
nemo_transducer
\
./sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19/test_wavs/example.wav
rm sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19
rm
-rf
sherpa-onnx-nemo-transducer-giga-am-v2-russian-2025-04-19
log
"------------------------------------------------------------------------"
...
...
.github/workflows/rknn-linux-aarch64.yaml
查看文件 @
51f8824
...
...
@@ -28,7 +28,7 @@ on:
workflow_dispatch
:
concurrency
:
group
:
aarch64-linux-gnu-shared
-${{ github.ref }}
group
:
rknn-linux-aarch64
-${{ github.ref }}
cancel-in-progress
:
true
jobs
:
...
...
python-api-examples/speech-recognition-from-microphone-with-endpoint-detection-alsa.py
查看文件 @
51f8824
...
...
@@ -107,6 +107,27 @@ def get_args():
)
parser
.
add_argument
(
"--hr-dict-dir"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the jieba dict directory for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-lexicon"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the lexicon.txt for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-rule-fsts"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the replace.fst for homophone replacer"
,
)
parser
.
add_argument
(
"--device-name"
,
type
=
str
,
required
=
True
,
...
...
@@ -159,6 +180,9 @@ def create_recognizer(args):
hotwords_file
=
args
.
hotwords_file
,
hotwords_score
=
args
.
hotwords_score
,
blank_penalty
=
args
.
blank_penalty
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
return
recognizer
...
...
python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py
查看文件 @
51f8824
...
...
@@ -114,6 +114,27 @@ def get_args():
"""
,
)
parser
.
add_argument
(
"--hr-dict-dir"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the jieba dict directory for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-lexicon"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the lexicon.txt for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-rule-fsts"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the replace.fst for homophone replacer"
,
)
return
parser
.
parse_args
()
...
...
@@ -142,6 +163,9 @@ def create_recognizer(args):
hotwords_file
=
args
.
hotwords_file
,
hotwords_score
=
args
.
hotwords_score
,
blank_penalty
=
args
.
blank_penalty
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
return
recognizer
...
...
python-api-examples/speech-recognition-from-microphone.py
查看文件 @
51f8824
...
...
@@ -123,6 +123,27 @@ def get_args():
"""
,
)
parser
.
add_argument
(
"--hr-dict-dir"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the jieba dict directory for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-lexicon"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the lexicon.txt for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-rule-fsts"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the replace.fst for homophone replacer"
,
)
return
parser
.
parse_args
()
...
...
@@ -148,6 +169,9 @@ def create_recognizer(args):
hotwords_file
=
args
.
hotwords_file
,
hotwords_score
=
args
.
hotwords_score
,
blank_penalty
=
args
.
blank_penalty
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
return
recognizer
...
...
python-api-examples/speech-recognition-from-url.py
查看文件 @
51f8824
...
...
@@ -110,6 +110,26 @@ def get_args():
"""
,
)
parser
.
add_argument
(
"--hr-dict-dir"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the jieba dict directory for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-lexicon"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the lexicon.txt for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-rule-fsts"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the replace.fst for homophone replacer"
,
)
return
parser
.
parse_args
()
...
...
@@ -133,6 +153,9 @@ def create_recognizer(args):
rule3_min_utterance_length
=
300
,
# it essentially disables this rule
hotwords_file
=
args
.
hotwords_file
,
hotwords_score
=
args
.
hotwords_score
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
return
recognizer
...
...
python-api-examples/vad-with-non-streaming-asr.py
查看文件 @
51f8824
...
...
@@ -273,6 +273,27 @@ def get_args():
help
=
"Feature dimension. Must match the one expected by the model"
,
)
parser
.
add_argument
(
"--hr-dict-dir"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the jieba dict directory for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-lexicon"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the lexicon.txt for homophone replacer"
,
)
parser
.
add_argument
(
"--hr-rule-fsts"
,
type
=
str
,
default
=
""
,
help
=
"If not empty, it is the replace.fst for homophone replacer"
,
)
return
parser
.
parse_args
()
...
...
@@ -312,6 +333,9 @@ def create_recognizer(args) -> sherpa_onnx.OfflineRecognizer:
decoding_method
=
args
.
decoding_method
,
blank_penalty
=
args
.
blank_penalty
,
debug
=
args
.
debug
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
elif
args
.
paraformer
:
assert
len
(
args
.
sense_voice
)
==
0
,
args
.
sense_voice
...
...
@@ -334,6 +358,9 @@ def create_recognizer(args) -> sherpa_onnx.OfflineRecognizer:
feature_dim
=
args
.
feature_dim
,
decoding_method
=
args
.
decoding_method
,
debug
=
args
.
debug
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
elif
args
.
sense_voice
:
assert
len
(
args
.
whisper_encoder
)
==
0
,
args
.
whisper_encoder
...
...
@@ -352,6 +379,9 @@ def create_recognizer(args) -> sherpa_onnx.OfflineRecognizer:
num_threads
=
args
.
num_threads
,
use_itn
=
True
,
debug
=
args
.
debug
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
elif
args
.
whisper_encoder
:
assert_file_exists
(
args
.
whisper_encoder
)
...
...
@@ -373,6 +403,9 @@ def create_recognizer(args) -> sherpa_onnx.OfflineRecognizer:
language
=
args
.
whisper_language
,
task
=
args
.
whisper_task
,
tail_paddings
=
args
.
whisper_tail_paddings
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
elif
args
.
moonshine_preprocessor
:
assert_file_exists
(
args
.
moonshine_preprocessor
)
...
...
@@ -389,6 +422,9 @@ def create_recognizer(args) -> sherpa_onnx.OfflineRecognizer:
num_threads
=
args
.
num_threads
,
decoding_method
=
args
.
decoding_method
,
debug
=
args
.
debug
,
hr_dict_dir
=
args
.
hr_dict_dir
,
hr_rule_fsts
=
args
.
hr_rule_fsts
,
hr_lexicon
=
args
.
hr_lexicon
,
)
else
:
raise
ValueError
(
"Please specify at least one model"
)
...
...
请
注册
或
登录
后发表评论