Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
147018a8
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
147018a8
编写于
2月 23, 2022
作者:
W
WilliamZhang06
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added cli changed code, test=doc
上级
7ebe904e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
11 deletion
+10
-11
paddlespeech/cli/asr/infer.py
paddlespeech/cli/asr/infer.py
+9
-10
paddlespeech/server/bin/paddlespeech_server.py
paddlespeech/server/bin/paddlespeech_server.py
+1
-1
未找到文件。
paddlespeech/cli/asr/infer.py
浏览文件 @
147018a8
...
@@ -287,7 +287,8 @@ class ASRExecutor(BaseExecutor):
...
@@ -287,7 +287,8 @@ class ASRExecutor(BaseExecutor):
"""
"""
audio_file
=
input
audio_file
=
input
logger
.
info
(
"Preprocess audio_file:"
+
audio_file
)
if
isinstance
(
audio_file
,
(
str
,
os
.
PathLike
)):
logger
.
info
(
"Preprocess audio_file:"
+
audio_file
)
# Get the object for feature extraction
# Get the object for feature extraction
if
"deepspeech2online"
in
model_type
or
"deepspeech2offline"
in
model_type
:
if
"deepspeech2online"
in
model_type
or
"deepspeech2offline"
in
model_type
:
...
@@ -408,13 +409,8 @@ class ASRExecutor(BaseExecutor):
...
@@ -408,13 +409,8 @@ class ASRExecutor(BaseExecutor):
def
_check
(
self
,
audio_file
:
str
,
sample_rate
:
int
,
force_yes
:
bool
):
def
_check
(
self
,
audio_file
:
str
,
sample_rate
:
int
,
force_yes
:
bool
):
self
.
sample_rate
=
sample_rate
self
.
sample_rate
=
sample_rate
if
self
.
sample_rate
!=
16000
and
self
.
sample_rate
!=
8000
:
if
self
.
sample_rate
!=
16000
and
self
.
sample_rate
!=
8000
:
logger
.
error
(
"please input --sr 8000 or --sr 16000"
)
logger
.
error
(
"invalid sample rate, please input --sr 8000 or --sr 16000"
)
raise
Exception
(
"invalid sample rate"
)
return
False
sys
.
exit
(
-
1
)
if
not
os
.
path
.
isfile
(
audio_file
):
logger
.
error
(
"Please input the right audio file path"
)
sys
.
exit
(
-
1
)
logger
.
info
(
"checking the audio file format......"
)
logger
.
info
(
"checking the audio file format......"
)
try
:
try
:
...
@@ -431,7 +427,7 @@ class ASRExecutor(BaseExecutor):
...
@@ -431,7 +427,7 @@ class ASRExecutor(BaseExecutor):
sample rate: 8k
\n
\
sample rate: 8k
\n
\
sox input_audio.xx --rate 8k --bits 16 --channels 1 output_audio.wav
\n
\
sox input_audio.xx --rate 8k --bits 16 --channels 1 output_audio.wav
\n
\
"
)
"
)
sys
.
exit
(
-
1
)
return
False
logger
.
info
(
"The sample rate is %d"
%
audio_sample_rate
)
logger
.
info
(
"The sample rate is %d"
%
audio_sample_rate
)
if
audio_sample_rate
!=
self
.
sample_rate
:
if
audio_sample_rate
!=
self
.
sample_rate
:
logger
.
warning
(
"The sample rate of the input file is not {}.
\n
\
logger
.
warning
(
"The sample rate of the input file is not {}.
\n
\
...
@@ -465,6 +461,8 @@ class ASRExecutor(BaseExecutor):
...
@@ -465,6 +461,8 @@ class ASRExecutor(BaseExecutor):
logger
.
info
(
"The audio file format is right"
)
logger
.
info
(
"The audio file format is right"
)
self
.
change_format
=
False
self
.
change_format
=
False
return
True
def
execute
(
self
,
argv
:
List
[
str
])
->
bool
:
def
execute
(
self
,
argv
:
List
[
str
])
->
bool
:
"""
"""
Command line entry.
Command line entry.
...
@@ -517,7 +515,8 @@ class ASRExecutor(BaseExecutor):
...
@@ -517,7 +515,8 @@ class ASRExecutor(BaseExecutor):
Python API to call an executor.
Python API to call an executor.
"""
"""
audio_file
=
os
.
path
.
abspath
(
audio_file
)
audio_file
=
os
.
path
.
abspath
(
audio_file
)
self
.
_check
(
audio_file
,
sample_rate
,
force_yes
)
if
not
self
.
_check
(
audio_file
,
sample_rate
,
force_yes
):
sys
.
exit
(
-
1
)
paddle
.
set_device
(
device
)
paddle
.
set_device
(
device
)
self
.
_init_from_path
(
model
,
lang
,
sample_rate
,
config
,
decode_method
,
self
.
_init_from_path
(
model
,
lang
,
sample_rate
,
config
,
decode_method
,
ckpt_path
)
ckpt_path
)
...
...
paddlespeech/server/bin/paddlespeech_server.py
浏览文件 @
147018a8
...
@@ -74,4 +74,4 @@ class ServerExecutor(BaseExecutor):
...
@@ -74,4 +74,4 @@ class ServerExecutor(BaseExecutor):
config
=
get_config
(
args
.
config_file
)
config
=
get_config
(
args
.
config_file
)
if
self
.
init
(
config
):
if
self
.
init
(
config
):
uvicorn
.
run
(
app
,
host
=
config
.
host
,
port
=
config
.
port
,
debug
=
True
)
v
uvicorn
.
run
(
app
,
host
=
config
.
host
,
port
=
config
.
port
,
debug
=
True
)
\ No newline at end of file
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录