Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
61d85404
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看板
提交
61d85404
编写于
8月 05, 2021
作者:
H
huangyuxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reconstruct the export function and the run.sh in aishell and librispeech
上级
722c55e4
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
57 addition
and
40 deletion
+57
-40
deepspeech/exps/deepspeech2/model.py
deepspeech/exps/deepspeech2/model.py
+2
-14
deepspeech/models/ds2_online/deepspeech2.py
deepspeech/models/ds2_online/deepspeech2.py
+17
-0
examples/aishell/s0/local/export.sh
examples/aishell/s0/local/export.sh
+5
-4
examples/aishell/s0/local/test.sh
examples/aishell/s0/local/test.sh
+5
-3
examples/aishell/s0/local/train.sh
examples/aishell/s0/local/train.sh
+5
-3
examples/aishell/s0/run.sh
examples/aishell/s0/run.sh
+4
-3
examples/librispeech/s0/local/export.sh
examples/librispeech/s0/local/export.sh
+5
-4
examples/librispeech/s0/local/test.sh
examples/librispeech/s0/local/test.sh
+5
-3
examples/librispeech/s0/local/train.sh
examples/librispeech/s0/local/train.sh
+5
-3
examples/librispeech/s0/run.sh
examples/librispeech/s0/run.sh
+4
-3
未找到文件。
deepspeech/exps/deepspeech2/model.py
浏览文件 @
61d85404
...
@@ -367,20 +367,8 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
...
@@ -367,20 +367,8 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
dtype
=
'int64'
),
# audio_length, [B]
dtype
=
'int64'
),
# audio_length, [B]
])
])
elif
self
.
args
.
model_type
==
'online'
:
elif
self
.
args
.
model_type
==
'online'
:
static_model
=
paddle
.
jit
.
to_static
(
static_model
=
DeepSpeech2InferModelOnline
.
export
(
infer_model
,
infer_model
,
feat_dim
)
input_spec
=
[
paddle
.
static
.
InputSpec
(
shape
=
[
None
,
None
,
feat_dim
],
#[B, chunk_size, feat_dim]
dtype
=
'float32'
),
# audio, [B,T,D]
paddle
.
static
.
InputSpec
(
shape
=
[
None
],
dtype
=
'int64'
),
# audio_length, [B]
paddle
.
static
.
InputSpec
(
shape
=
[
None
,
None
,
None
],
dtype
=
'float32'
),
paddle
.
static
.
InputSpec
(
shape
=
[
None
,
None
,
None
],
dtype
=
'float32'
)
])
else
:
else
:
raise
Exception
(
"wrong model type"
)
raise
Exception
(
"wrong model type"
)
logger
.
info
(
f
"Export code:
{
static_model
.
forward
.
code
}
"
)
logger
.
info
(
f
"Export code:
{
static_model
.
forward
.
code
}
"
)
...
...
deepspeech/models/ds2_online/deepspeech2.py
浏览文件 @
61d85404
...
@@ -424,3 +424,20 @@ class DeepSpeech2InferModelOnline(DeepSpeech2ModelOnline):
...
@@ -424,3 +424,20 @@ class DeepSpeech2InferModelOnline(DeepSpeech2ModelOnline):
audio_chunk
,
audio_chunk_lens
,
chunk_state_h_box
,
chunk_state_c_box
)
audio_chunk
,
audio_chunk_lens
,
chunk_state_h_box
,
chunk_state_c_box
)
probs_chunk
=
self
.
decoder
.
softmax
(
eouts_chunk
)
probs_chunk
=
self
.
decoder
.
softmax
(
eouts_chunk
)
return
probs_chunk
,
eouts_chunk_lens
,
final_state_h_box
,
final_state_c_box
return
probs_chunk
,
eouts_chunk_lens
,
final_state_h_box
,
final_state_c_box
@
classmethod
def
export
(
self
,
infer_model
,
feat_dim
):
static_model
=
paddle
.
jit
.
to_static
(
infer_model
,
input_spec
=
[
paddle
.
static
.
InputSpec
(
shape
=
[
None
,
None
,
feat_dim
],
#[B, chunk_size, feat_dim]
dtype
=
'float32'
),
# audio, [B,T,D]
paddle
.
static
.
InputSpec
(
shape
=
[
None
],
dtype
=
'int64'
),
# audio_length, [B]
paddle
.
static
.
InputSpec
(
shape
=
[
None
,
None
,
None
],
dtype
=
'float32'
),
paddle
.
static
.
InputSpec
(
shape
=
[
None
,
None
,
None
],
dtype
=
'float32'
)
])
return
static_model
examples/aishell/s0/local/export.sh
浏览文件 @
61d85404
#!/bin/bash
#!/bin/bash
if
[
$#
!=
3
]
;
then
if
[
$#
!=
4
]
;
then
echo
"usage:
$0
config_path ckpt_prefix jit_model_path"
echo
"usage:
$0
config_path ckpt_prefix jit_model_path
model_type
"
exit
-1
exit
-1
fi
fi
...
@@ -11,6 +11,7 @@ echo "using $ngpu gpus..."
...
@@ -11,6 +11,7 @@ echo "using $ngpu gpus..."
config_path
=
$1
config_path
=
$1
ckpt_path_prefix
=
$2
ckpt_path_prefix
=
$2
jit_model_export_path
=
$3
jit_model_export_path
=
$3
model_type
=
$4
device
=
gpu
device
=
gpu
if
[
${
ngpu
}
==
0
]
;
then
if
[
${
ngpu
}
==
0
]
;
then
...
@@ -22,8 +23,8 @@ python3 -u ${BIN_DIR}/export.py \
...
@@ -22,8 +23,8 @@ python3 -u ${BIN_DIR}/export.py \
--nproc
${
ngpu
}
\
--nproc
${
ngpu
}
\
--config
${
config_path
}
\
--config
${
config_path
}
\
--checkpoint_path
${
ckpt_path_prefix
}
\
--checkpoint_path
${
ckpt_path_prefix
}
\
--export_path
${
jit_model_export_path
}
--export_path
${
jit_model_export_path
}
\
--model_type
${
model_type
}
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"Failed in export!"
echo
"Failed in export!"
...
...
examples/aishell/s0/local/test.sh
浏览文件 @
61d85404
#!/bin/bash
#!/bin/bash
if
[
$#
!=
2
]
;
then
if
[
$#
!=
3
]
;
then
echo
"usage:
${
0
}
config_path ckpt_path_prefix"
echo
"usage:
${
0
}
config_path ckpt_path_prefix
model_type
"
exit
-1
exit
-1
fi
fi
...
@@ -14,6 +14,7 @@ if [ ${ngpu} == 0 ];then
...
@@ -14,6 +14,7 @@ if [ ${ngpu} == 0 ];then
fi
fi
config_path
=
$1
config_path
=
$1
ckpt_prefix
=
$2
ckpt_prefix
=
$2
model_type
=
$3
# download language model
# download language model
bash
local
/download_lm_ch.sh
bash
local
/download_lm_ch.sh
...
@@ -26,7 +27,8 @@ python3 -u ${BIN_DIR}/test.py \
...
@@ -26,7 +27,8 @@ python3 -u ${BIN_DIR}/test.py \
--nproc
1
\
--nproc
1
\
--config
${
config_path
}
\
--config
${
config_path
}
\
--result_file
${
ckpt_prefix
}
.rsl
\
--result_file
${
ckpt_prefix
}
.rsl
\
--checkpoint_path
${
ckpt_prefix
}
--checkpoint_path
${
ckpt_prefix
}
\
--model_type
${
model_type
}
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"Failed in evaluation!"
echo
"Failed in evaluation!"
...
...
examples/aishell/s0/local/train.sh
浏览文件 @
61d85404
#!/bin/bash
#!/bin/bash
if
[
$#
!=
2
]
;
then
if
[
$#
!=
3
]
;
then
echo
"usage: CUDA_VISIBLE_DEVICES=0
${
0
}
config_path ckpt_name"
echo
"usage: CUDA_VISIBLE_DEVICES=0
${
0
}
config_path ckpt_name
model_type
"
exit
-1
exit
-1
fi
fi
...
@@ -10,6 +10,7 @@ echo "using $ngpu gpus..."
...
@@ -10,6 +10,7 @@ echo "using $ngpu gpus..."
config_path
=
$1
config_path
=
$1
ckpt_name
=
$2
ckpt_name
=
$2
model_type
=
$3
device
=
gpu
device
=
gpu
if
[
${
ngpu
}
==
0
]
;
then
if
[
${
ngpu
}
==
0
]
;
then
...
@@ -22,7 +23,8 @@ python3 -u ${BIN_DIR}/train.py \
...
@@ -22,7 +23,8 @@ python3 -u ${BIN_DIR}/train.py \
--device
${
device
}
\
--device
${
device
}
\
--nproc
${
ngpu
}
\
--nproc
${
ngpu
}
\
--config
${
config_path
}
\
--config
${
config_path
}
\
--output
exp/
${
ckpt_name
}
--output
exp/
${
ckpt_name
}
\
--model_type
${
model_type
}
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"Failed in training!"
echo
"Failed in training!"
...
...
examples/aishell/s0/run.sh
浏览文件 @
61d85404
...
@@ -7,6 +7,7 @@ stage=0
...
@@ -7,6 +7,7 @@ stage=0
stop_stage
=
100
stop_stage
=
100
conf_path
=
conf/deepspeech2.yaml
conf_path
=
conf/deepspeech2.yaml
avg_num
=
1
avg_num
=
1
model_type
=
offline
source
${
MAIN_ROOT
}
/utils/parse_options.sh
||
exit
1
;
source
${
MAIN_ROOT
}
/utils/parse_options.sh
||
exit
1
;
...
@@ -21,7 +22,7 @@ fi
...
@@ -21,7 +22,7 @@ fi
if
[
${
stage
}
-le
1
]
&&
[
${
stop_stage
}
-ge
1
]
;
then
if
[
${
stage
}
-le
1
]
&&
[
${
stop_stage
}
-ge
1
]
;
then
# train model, all `ckpt` under `exp` dir
# train model, all `ckpt` under `exp` dir
CUDA_VISIBLE_DEVICES
=
${
gpus
}
./local/train.sh
${
conf_path
}
${
ckpt
}
CUDA_VISIBLE_DEVICES
=
${
gpus
}
./local/train.sh
${
conf_path
}
${
ckpt
}
${
model_type
}
fi
fi
if
[
${
stage
}
-le
2
]
&&
[
${
stop_stage
}
-ge
2
]
;
then
if
[
${
stage
}
-le
2
]
&&
[
${
stop_stage
}
-ge
2
]
;
then
...
@@ -31,10 +32,10 @@ fi
...
@@ -31,10 +32,10 @@ fi
if
[
${
stage
}
-le
3
]
&&
[
${
stop_stage
}
-ge
3
]
;
then
if
[
${
stage
}
-le
3
]
&&
[
${
stop_stage
}
-ge
3
]
;
then
# test ckpt avg_n
# test ckpt avg_n
CUDA_VISIBLE_DEVICES
=
0 ./local/test.sh
${
conf_path
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
||
exit
-1
CUDA_VISIBLE_DEVICES
=
0 ./local/test.sh
${
conf_path
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
${
model_type
}
||
exit
-1
fi
fi
if
[
${
stage
}
-le
4
]
&&
[
${
stop_stage
}
-ge
4
]
;
then
if
[
${
stage
}
-le
4
]
&&
[
${
stop_stage
}
-ge
4
]
;
then
# export ckpt avg_n
# export ckpt avg_n
CUDA_VISIBLE_DEVICES
=
0 ./local/export.sh
${
conf_path
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
.jit
CUDA_VISIBLE_DEVICES
=
0 ./local/export.sh
${
conf_path
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
.jit
${
model_type
}
fi
fi
examples/librispeech/s0/local/export.sh
浏览文件 @
61d85404
#!/bin/bash
#!/bin/bash
if
[
$#
!=
3
]
;
then
if
[
$#
!=
4
]
;
then
echo
"usage:
$0
config_path ckpt_prefix jit_model_path"
echo
"usage:
$0
config_path ckpt_prefix jit_model_path
model_type
"
exit
-1
exit
-1
fi
fi
...
@@ -11,6 +11,7 @@ echo "using $ngpu gpus..."
...
@@ -11,6 +11,7 @@ echo "using $ngpu gpus..."
config_path
=
$1
config_path
=
$1
ckpt_path_prefix
=
$2
ckpt_path_prefix
=
$2
jit_model_export_path
=
$3
jit_model_export_path
=
$3
model_type
=
$4
device
=
gpu
device
=
gpu
if
[
${
ngpu
}
==
0
]
;
then
if
[
${
ngpu
}
==
0
]
;
then
...
@@ -22,8 +23,8 @@ python3 -u ${BIN_DIR}/export.py \
...
@@ -22,8 +23,8 @@ python3 -u ${BIN_DIR}/export.py \
--nproc
${
ngpu
}
\
--nproc
${
ngpu
}
\
--config
${
config_path
}
\
--config
${
config_path
}
\
--checkpoint_path
${
ckpt_path_prefix
}
\
--checkpoint_path
${
ckpt_path_prefix
}
\
--export_path
${
jit_model_export_path
}
--export_path
${
jit_model_export_path
}
\
--model_type
${
model_type
}
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"Failed in export!"
echo
"Failed in export!"
...
...
examples/librispeech/s0/local/test.sh
浏览文件 @
61d85404
#!/bin/bash
#!/bin/bash
if
[
$#
!=
2
]
;
then
if
[
$#
!=
3
]
;
then
echo
"usage:
${
0
}
config_path ckpt_path_prefix"
echo
"usage:
${
0
}
config_path ckpt_path_prefix
model_type
"
exit
-1
exit
-1
fi
fi
...
@@ -14,6 +14,7 @@ if [ ${ngpu} == 0 ];then
...
@@ -14,6 +14,7 @@ if [ ${ngpu} == 0 ];then
fi
fi
config_path
=
$1
config_path
=
$1
ckpt_prefix
=
$2
ckpt_prefix
=
$2
model_type
=
$3
# download language model
# download language model
bash
local
/download_lm_en.sh
bash
local
/download_lm_en.sh
...
@@ -26,7 +27,8 @@ python3 -u ${BIN_DIR}/test.py \
...
@@ -26,7 +27,8 @@ python3 -u ${BIN_DIR}/test.py \
--nproc
1
\
--nproc
1
\
--config
${
config_path
}
\
--config
${
config_path
}
\
--result_file
${
ckpt_prefix
}
.rsl
\
--result_file
${
ckpt_prefix
}
.rsl
\
--checkpoint_path
${
ckpt_prefix
}
--checkpoint_path
${
ckpt_prefix
}
\
--model_type
${
model_type
}
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"Failed in evaluation!"
echo
"Failed in evaluation!"
...
...
examples/librispeech/s0/local/train.sh
浏览文件 @
61d85404
#!/bin/bash
#!/bin/bash
if
[
$#
!=
2
]
;
then
if
[
$#
!=
3
]
;
then
echo
"usage: CUDA_VISIBLE_DEVICES=0
${
0
}
config_path ckpt_name"
echo
"usage: CUDA_VISIBLE_DEVICES=0
${
0
}
config_path ckpt_name
model_type
"
exit
-1
exit
-1
fi
fi
...
@@ -10,6 +10,7 @@ echo "using $ngpu gpus..."
...
@@ -10,6 +10,7 @@ echo "using $ngpu gpus..."
config_path
=
$1
config_path
=
$1
ckpt_name
=
$2
ckpt_name
=
$2
model_type
=
$3
device
=
gpu
device
=
gpu
if
[
${
ngpu
}
==
0
]
;
then
if
[
${
ngpu
}
==
0
]
;
then
...
@@ -23,7 +24,8 @@ python3 -u ${BIN_DIR}/train.py \
...
@@ -23,7 +24,8 @@ python3 -u ${BIN_DIR}/train.py \
--device
${
device
}
\
--device
${
device
}
\
--nproc
${
ngpu
}
\
--nproc
${
ngpu
}
\
--config
${
config_path
}
\
--config
${
config_path
}
\
--output
exp/
${
ckpt_name
}
--output
exp/
${
ckpt_name
}
\
--model_type
${
model_type
}
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"Failed in training!"
echo
"Failed in training!"
...
...
examples/librispeech/s0/run.sh
浏览文件 @
61d85404
...
@@ -6,6 +6,7 @@ stage=0
...
@@ -6,6 +6,7 @@ stage=0
stop_stage
=
100
stop_stage
=
100
conf_path
=
conf/deepspeech2.yaml
conf_path
=
conf/deepspeech2.yaml
avg_num
=
30
avg_num
=
30
model_type
=
offline
source
${
MAIN_ROOT
}
/utils/parse_options.sh
||
exit
1
;
source
${
MAIN_ROOT
}
/utils/parse_options.sh
||
exit
1
;
avg_ckpt
=
avg_
${
avg_num
}
avg_ckpt
=
avg_
${
avg_num
}
...
@@ -19,7 +20,7 @@ fi
...
@@ -19,7 +20,7 @@ fi
if
[
${
stage
}
-le
1
]
&&
[
${
stop_stage
}
-ge
1
]
;
then
if
[
${
stage
}
-le
1
]
&&
[
${
stop_stage
}
-ge
1
]
;
then
# train model, all `ckpt` under `exp` dir
# train model, all `ckpt` under `exp` dir
CUDA_VISIBLE_DEVICES
=
0,1,2,3,4,5,6,7 ./local/train.sh
${
conf_path
}
${
ckpt
}
CUDA_VISIBLE_DEVICES
=
0,1,2,3,4,5,6,7 ./local/train.sh
${
conf_path
}
${
ckpt
}
${
model_type
}
fi
fi
if
[
${
stage
}
-le
2
]
&&
[
${
stop_stage
}
-ge
2
]
;
then
if
[
${
stage
}
-le
2
]
&&
[
${
stop_stage
}
-ge
2
]
;
then
...
@@ -29,10 +30,10 @@ fi
...
@@ -29,10 +30,10 @@ fi
if
[
${
stage
}
-le
3
]
&&
[
${
stop_stage
}
-ge
3
]
;
then
if
[
${
stage
}
-le
3
]
&&
[
${
stop_stage
}
-ge
3
]
;
then
# test ckpt avg_n
# test ckpt avg_n
CUDA_VISIBLE_DEVICES
=
7 ./local/test.sh
${
conf_path
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
||
exit
-1
CUDA_VISIBLE_DEVICES
=
7 ./local/test.sh
${
conf_path
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
${
model_type
}
||
exit
-1
fi
fi
if
[
${
stage
}
-le
4
]
&&
[
${
stop_stage
}
-ge
4
]
;
then
if
[
${
stage
}
-le
4
]
&&
[
${
stop_stage
}
-ge
4
]
;
then
# export ckpt avg_n
# export ckpt avg_n
CUDA_VISIBLE_DEVICES
=
./local/export.sh
${
conf_path
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
.jit
CUDA_VISIBLE_DEVICES
=
./local/export.sh
${
conf_path
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
exp/
${
ckpt
}
/checkpoints/
${
avg_ckpt
}
.jit
${
model_type
}
fi
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录