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
2023-08-09 10:00:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-08-09 10:00:34 +0800
Commit
aeb112dd067f970bcd6a7345c05c9b1aa5dc0745
aeb112dd
1 parent
6235cb9f
Support specifying provider for python examples (#244)
显示空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
35 行增加
和
1 行删除
python-api-examples/online-decode-files.py
python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py
python-api-examples/speech-recognition-from-microphone.py
python-api-examples/streaming_server.py
python-api-examples/online-decode-files.py
查看文件 @
aeb112d
...
...
@@ -80,6 +80,13 @@ def get_args():
)
parser
.
add_argument
(
"--provider"
,
type
=
str
,
default
=
"cpu"
,
help
=
"Valid values: cpu, cuda, coreml"
,
)
parser
.
add_argument
(
"--bpe-model"
,
type
=
str
,
default
=
""
,
...
...
@@ -204,6 +211,7 @@ def main():
decoder
=
args
.
decoder
,
joiner
=
args
.
joiner
,
num_threads
=
args
.
num_threads
,
provider
=
args
.
provider
,
sample_rate
=
16000
,
feature_dim
=
80
,
decoding_method
=
args
.
decoding_method
,
...
...
@@ -220,7 +228,6 @@ def main():
print
(
f
"Contexts list: {contexts}"
)
contexts_list
=
encode_contexts
(
args
,
contexts
)
streams
=
[]
total_duration
=
0
for
wave_filename
in
args
.
sound_files
:
...
...
python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py
查看文件 @
aeb112d
...
...
@@ -72,6 +72,13 @@ def get_args():
help
=
"Valid values are greedy_search and modified_beam_search"
,
)
parser
.
add_argument
(
"--provider"
,
type
=
str
,
default
=
"cpu"
,
help
=
"Valid values: cpu, cuda, coreml"
,
)
return
parser
.
parse_args
()
...
...
@@ -97,6 +104,7 @@ def create_recognizer():
rule2_min_trailing_silence
=
1.2
,
rule3_min_utterance_length
=
300
,
# it essentially disables this rule
decoding_method
=
args
.
decoding_method
,
provider
=
args
.
provider
,
)
return
recognizer
...
...
python-api-examples/speech-recognition-from-microphone.py
查看文件 @
aeb112d
...
...
@@ -83,6 +83,13 @@ def get_args():
)
parser
.
add_argument
(
"--provider"
,
type
=
str
,
default
=
"cpu"
,
help
=
"Valid values: cpu, cuda, coreml"
,
)
parser
.
add_argument
(
"--bpe-model"
,
type
=
str
,
default
=
""
,
...
...
@@ -148,10 +155,12 @@ def create_recognizer():
feature_dim
=
80
,
decoding_method
=
args
.
decoding_method
,
max_active_paths
=
args
.
max_active_paths
,
provider
=
args
.
provider
,
context_score
=
args
.
context_score
,
)
return
recognizer
def
encode_contexts
(
args
,
contexts
:
List
[
str
])
->
List
[
List
[
int
]]:
sp
=
None
if
"bpe"
in
args
.
modeling_unit
:
...
...
@@ -172,6 +181,7 @@ def encode_contexts(args, contexts: List[str]) -> List[List[int]]:
tokens_table
=
tokens
,
)
def
main
():
args
=
get_args
()
...
...
@@ -205,6 +215,7 @@ def main():
last_result
=
result
print
(
"
\r
{}"
.
format
(
result
),
end
=
""
,
flush
=
True
)
if
__name__
==
"__main__"
:
devices
=
sd
.
query_devices
()
print
(
devices
)
...
...
python-api-examples/streaming_server.py
查看文件 @
aeb112d
...
...
@@ -129,6 +129,13 @@ def add_model_args(parser: argparse.ArgumentParser):
help
=
"Feature dimension of the model"
,
)
parser
.
add_argument
(
"--provider"
,
type
=
str
,
default
=
"cpu"
,
help
=
"Valid values: cpu, cuda, coreml"
,
)
def
add_decoding_args
(
parser
:
argparse
.
ArgumentParser
):
parser
.
add_argument
(
...
...
@@ -301,6 +308,7 @@ def create_recognizer(args) -> sherpa_onnx.OnlineRecognizer:
rule1_min_trailing_silence
=
args
.
rule1_min_trailing_silence
,
rule2_min_trailing_silence
=
args
.
rule2_min_trailing_silence
,
rule3_min_utterance_length
=
args
.
rule3_min_utterance_length
,
provider
=
args
.
provider
,
)
return
recognizer
...
...
请
注册
或
登录
后发表评论