Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
a9d206c1
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看板
提交
a9d206c1
编写于
12月 02, 2021
作者:
H
huangyuxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revise
上级
957f2e3a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
6 addition
and
5 deletion
+6
-5
paddlespeech/cli/asr/infer.py
paddlespeech/cli/asr/infer.py
+6
-5
未找到文件。
paddlespeech/cli/asr/infer.py
浏览文件 @
a9d206c1
...
@@ -22,6 +22,7 @@ import librosa
...
@@ -22,6 +22,7 @@ import librosa
import
paddle
import
paddle
import
soundfile
import
soundfile
from
yacs.config
import
CfgNode
from
yacs.config
import
CfgNode
import
numpy
as
np
from
..executor
import
BaseExecutor
from
..executor
import
BaseExecutor
from
..utils
import
cli_register
from
..utils
import
cli_register
...
@@ -81,6 +82,7 @@ class ASRExecutor(BaseExecutor):
...
@@ -81,6 +82,7 @@ class ASRExecutor(BaseExecutor):
"--sr"
,
"--sr"
,
type
=
int
,
type
=
int
,
default
=
16000
,
default
=
16000
,
choices
=
[
8000
,
16000
],
help
=
'Choose the audio sample rate of the model. 8000 or 16000'
)
help
=
'Choose the audio sample rate of the model. 8000 or 16000'
)
self
.
parser
.
add_argument
(
self
.
parser
.
add_argument
(
'--config'
,
'--config'
,
...
@@ -131,13 +133,13 @@ class ASRExecutor(BaseExecutor):
...
@@ -131,13 +133,13 @@ class ASRExecutor(BaseExecutor):
self
.
cfg_path
=
os
.
path
.
join
(
res_path
,
self
.
cfg_path
=
os
.
path
.
join
(
res_path
,
pretrained_models
[
tag
][
'cfg_path'
])
pretrained_models
[
tag
][
'cfg_path'
])
self
.
ckpt_path
=
os
.
path
.
join
(
res_path
,
self
.
ckpt_path
=
os
.
path
.
join
(
res_path
,
pretrained_models
[
tag
][
'ckpt_path'
])
pretrained_models
[
tag
][
'ckpt_path'
]
+
".pdparams"
)
logger
.
info
(
res_path
)
logger
.
info
(
res_path
)
logger
.
info
(
self
.
cfg_path
)
logger
.
info
(
self
.
cfg_path
)
logger
.
info
(
self
.
ckpt_path
)
logger
.
info
(
self
.
ckpt_path
)
else
:
else
:
self
.
cfg_path
=
os
.
path
.
abspath
(
cfg_path
)
self
.
cfg_path
=
os
.
path
.
abspath
(
cfg_path
)
self
.
ckpt_path
=
os
.
path
.
abspath
(
ckpt_path
)
self
.
ckpt_path
=
os
.
path
.
abspath
(
ckpt_path
+
".pdparams"
)
res_path
=
os
.
path
.
dirname
(
res_path
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
self
.
cfg_path
)))
os
.
path
.
dirname
(
os
.
path
.
abspath
(
self
.
cfg_path
)))
...
@@ -183,8 +185,7 @@ class ASRExecutor(BaseExecutor):
...
@@ -183,8 +185,7 @@ class ASRExecutor(BaseExecutor):
self
.
model
.
eval
()
self
.
model
.
eval
()
# load model
# load model
params_path
=
self
.
ckpt_path
+
".pdparams"
model_dict
=
paddle
.
load
(
self
.
ckpt_path
)
model_dict
=
paddle
.
load
(
params_path
)
self
.
model
.
set_state_dict
(
model_dict
)
self
.
model
.
set_state_dict
(
model_dict
)
def
preprocess
(
self
,
model_type
:
str
,
input
:
Union
[
str
,
os
.
PathLike
]):
def
preprocess
(
self
,
model_type
:
str
,
input
:
Union
[
str
,
os
.
PathLike
]):
...
@@ -231,7 +232,7 @@ class ASRExecutor(BaseExecutor):
...
@@ -231,7 +232,7 @@ class ASRExecutor(BaseExecutor):
audio
=
librosa
.
resample
(
audio
,
audio_sample_rate
,
audio
=
librosa
.
resample
(
audio
,
audio_sample_rate
,
self
.
sample_rate
)
self
.
sample_rate
)
audio_sample_rate
=
self
.
sample_rate
audio_sample_rate
=
self
.
sample_rate
audio
=
audio
.
astype
(
"int16"
)
audio
=
np
.
round
(
audio
)
.
astype
(
"int16"
)
else
:
else
:
audio
=
audio
[:,
0
]
audio
=
audio
[:,
0
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录