Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
225737d4
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看板
未验证
提交
225737d4
编写于
4月 25, 2023
作者:
H
Hui Zhang
提交者:
GitHub
4月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[s2t] fix cli args to config (#3194)
* fix cli args to config * fix train cli
上级
e3dcfa88
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
83 addition
and
120 deletion
+83
-120
paddlespeech/dataset/s2t/build_vocab.py
paddlespeech/dataset/s2t/build_vocab.py
+3
-0
paddlespeech/dataset/s2t/format_data.py
paddlespeech/dataset/s2t/format_data.py
+1
-0
paddlespeech/s2t/exps/u2/bin/alignment.py
paddlespeech/s2t/exps/u2/bin/alignment.py
+4
-20
paddlespeech/s2t/exps/u2/bin/export.py
paddlespeech/s2t/exps/u2/bin/export.py
+4
-16
paddlespeech/s2t/exps/u2/bin/quant.py
paddlespeech/s2t/exps/u2/bin/quant.py
+3
-27
paddlespeech/s2t/exps/u2/bin/test.py
paddlespeech/s2t/exps/u2/bin/test.py
+4
-19
paddlespeech/s2t/exps/u2/bin/test_wav.py
paddlespeech/s2t/exps/u2/bin/test_wav.py
+2
-23
paddlespeech/s2t/exps/u2/bin/train.py
paddlespeech/s2t/exps/u2/bin/train.py
+4
-14
paddlespeech/s2t/training/cli.py
paddlespeech/s2t/training/cli.py
+58
-1
未找到文件。
paddlespeech/dataset/s2t/build_vocab.py
浏览文件 @
225737d4
...
@@ -74,6 +74,9 @@ def build_vocab(manifest_paths="",
...
@@ -74,6 +74,9 @@ def build_vocab(manifest_paths="",
spm_vocab_size
=
0
,
spm_vocab_size
=
0
,
spm_model_prefix
=
""
,
spm_model_prefix
=
""
,
spm_character_coverage
=
0.9995
):
spm_character_coverage
=
0.9995
):
manifest_paths
=
[
manifest_paths
]
if
isinstance
(
manifest_paths
,
str
)
else
manifest_paths
fout
=
open
(
vocab_path
,
'w'
,
encoding
=
'utf-8'
)
fout
=
open
(
vocab_path
,
'w'
,
encoding
=
'utf-8'
)
fout
.
write
(
BLANK
+
"
\n
"
)
# 0 will be used for "blank" in CTC
fout
.
write
(
BLANK
+
"
\n
"
)
# 0 will be used for "blank" in CTC
fout
.
write
(
UNK
+
'
\n
'
)
# <unk> must be 1
fout
.
write
(
UNK
+
'
\n
'
)
# <unk> must be 1
...
...
paddlespeech/dataset/s2t/format_data.py
浏览文件 @
225737d4
...
@@ -58,6 +58,7 @@ def format_data(
...
@@ -58,6 +58,7 @@ def format_data(
unit_type
=
"char"
,
unit_type
=
"char"
,
vocab_path
=
"examples/librispeech/data/vocab.txt"
,
vocab_path
=
"examples/librispeech/data/vocab.txt"
,
spm_model_prefix
=
""
):
spm_model_prefix
=
""
):
manifest_paths
=
[
manifest_paths
]
if
isinstance
(
manifest_paths
,
str
)
else
manifest_paths
fout
=
open
(
output_path
,
'w'
,
encoding
=
'utf-8'
)
fout
=
open
(
output_path
,
'w'
,
encoding
=
'utf-8'
)
...
...
paddlespeech/s2t/exps/u2/bin/alignment.py
浏览文件 @
225737d4
...
@@ -12,10 +12,10 @@
...
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""Alignment for U2 model."""
"""Alignment for U2 model."""
from
yacs.config
import
CfgNode
from
paddlespeech.s2t.exps.u2.model
import
U2Tester
as
Tester
from
paddlespeech.s2t.exps.u2.model
import
U2Tester
as
Tester
from
paddlespeech.s2t.training.cli
import
config_from_args
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
maybe_dump_config
from
paddlespeech.utils.argparse
import
print_arguments
from
paddlespeech.utils.argparse
import
print_arguments
...
@@ -32,26 +32,10 @@ def main(config, args):
...
@@ -32,26 +32,10 @@ def main(config, args):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
default_argument_parser
()
parser
=
default_argument_parser
()
# save asr result to
parser
.
add_argument
(
"--result_file"
,
type
=
str
,
help
=
"path of save the asr result"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
print_arguments
(
args
,
globals
())
print_arguments
(
args
,
globals
())
# https://yaml.org/type/float.html
config
=
config_from_args
(
args
)
config
=
CfgNode
(
new_allowed
=
True
)
if
args
.
config
:
config
.
merge_from_file
(
args
.
config
)
if
args
.
decode_cfg
:
decode_confs
=
CfgNode
(
new_allowed
=
True
)
decode_confs
.
merge_from_file
(
args
.
decode_cfg
)
config
.
decode
=
decode_confs
if
args
.
opts
:
config
.
merge_from_list
(
args
.
opts
)
config
.
freeze
()
print
(
config
)
print
(
config
)
if
args
.
dump_config
:
maybe_dump_config
(
args
.
dump_config
,
config
)
with
open
(
args
.
dump_config
,
'w'
)
as
f
:
print
(
config
,
file
=
f
)
main
(
config
,
args
)
main
(
config
,
args
)
paddlespeech/s2t/exps/u2/bin/export.py
浏览文件 @
225737d4
...
@@ -12,10 +12,10 @@
...
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
"""Export for U2 model."""
"""Export for U2 model."""
from
yacs.config
import
CfgNode
from
paddlespeech.s2t.exps.u2.model
import
U2Tester
as
Tester
from
paddlespeech.s2t.exps.u2.model
import
U2Tester
as
Tester
from
paddlespeech.s2t.training.cli
import
config_from_args
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
maybe_dump_config
from
paddlespeech.utils.argparse
import
print_arguments
from
paddlespeech.utils.argparse
import
print_arguments
...
@@ -32,22 +32,10 @@ def main(config, args):
...
@@ -32,22 +32,10 @@ def main(config, args):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
default_argument_parser
()
parser
=
default_argument_parser
()
# save jit model to
parser
.
add_argument
(
"--export_path"
,
type
=
str
,
help
=
"path of the jit model to save"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
print_arguments
(
args
,
globals
())
print_arguments
(
args
,
globals
())
# https://yaml.org/type/float.html
config
=
config_from_args
(
args
)
config
=
CfgNode
(
new_allowed
=
True
)
if
args
.
config
:
config
.
merge_from_file
(
args
.
config
)
if
args
.
opts
:
config
.
merge_from_list
(
args
.
opts
)
config
.
freeze
()
print
(
config
)
print
(
config
)
if
args
.
dump_config
:
maybe_dump_config
(
args
.
dump_config
,
config
)
with
open
(
args
.
dump_config
,
'w'
)
as
f
:
print
(
config
,
file
=
f
)
main
(
config
,
args
)
main
(
config
,
args
)
paddlespeech/s2t/exps/u2/bin/quant.py
浏览文件 @
225737d4
...
@@ -15,14 +15,15 @@
...
@@ -15,14 +15,15 @@
import
paddle
import
paddle
from
kaldiio
import
ReadHelper
from
kaldiio
import
ReadHelper
from
paddleslim
import
PTQ
from
paddleslim
import
PTQ
from
yacs.config
import
CfgNode
from
paddlespeech.audio.transform.transformation
import
Transformation
from
paddlespeech.audio.transform.transformation
import
Transformation
from
paddlespeech.s2t.frontend.featurizer.text_featurizer
import
TextFeaturizer
from
paddlespeech.s2t.frontend.featurizer.text_featurizer
import
TextFeaturizer
from
paddlespeech.s2t.models.u2
import
U2Model
from
paddlespeech.s2t.models.u2
import
U2Model
from
paddlespeech.s2t.training.cli
import
config_from_args
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.utils.log
import
Log
from
paddlespeech.s2t.utils.log
import
Log
from
paddlespeech.s2t.utils.utility
import
UpdateConfig
from
paddlespeech.s2t.utils.utility
import
UpdateConfig
logger
=
Log
(
__name__
).
getlog
()
logger
=
Log
(
__name__
).
getlog
()
...
@@ -173,32 +174,7 @@ def main(config, args):
...
@@ -173,32 +174,7 @@ def main(config, args):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
default_argument_parser
()
parser
=
default_argument_parser
()
# save asr result to
parser
.
add_argument
(
"--result_file"
,
type
=
str
,
help
=
"path of save the asr result"
)
parser
.
add_argument
(
"--audio_scp"
,
type
=
str
,
help
=
"path of the input audio file"
)
parser
.
add_argument
(
"--num_utts"
,
type
=
int
,
default
=
200
,
help
=
"num utts for quant calibrition."
)
parser
.
add_argument
(
"--export_path"
,
type
=
str
,
default
=
'export.jit.quant'
,
help
=
"path of the input audio file"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
config
=
CfgNode
(
new_allowed
=
True
)
config
=
config_from_args
(
args
)
if
args
.
config
:
config
.
merge_from_file
(
args
.
config
)
if
args
.
decode_cfg
:
decode_confs
=
CfgNode
(
new_allowed
=
True
)
decode_confs
.
merge_from_file
(
args
.
decode_cfg
)
config
.
decode
=
decode_confs
if
args
.
opts
:
config
.
merge_from_list
(
args
.
opts
)
config
.
freeze
()
main
(
config
,
args
)
main
(
config
,
args
)
paddlespeech/s2t/exps/u2/bin/test.py
浏览文件 @
225737d4
...
@@ -14,10 +14,10 @@
...
@@ -14,10 +14,10 @@
"""Evaluation for U2 model."""
"""Evaluation for U2 model."""
import
cProfile
import
cProfile
from
yacs.config
import
CfgNode
from
paddlespeech.s2t.exps.u2.model
import
U2Tester
as
Tester
from
paddlespeech.s2t.exps.u2.model
import
U2Tester
as
Tester
from
paddlespeech.s2t.training.cli
import
config_from_args
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
maybe_dump_config
from
paddlespeech.utils.argparse
import
print_arguments
from
paddlespeech.utils.argparse
import
print_arguments
...
@@ -34,27 +34,12 @@ def main(config, args):
...
@@ -34,27 +34,12 @@ def main(config, args):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
default_argument_parser
()
parser
=
default_argument_parser
()
# save asr result to
parser
.
add_argument
(
"--result_file"
,
type
=
str
,
help
=
"path of save the asr result"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
print_arguments
(
args
,
globals
())
print_arguments
(
args
,
globals
())
# https://yaml.org/type/float.html
config
=
config_from_args
(
args
)
config
=
CfgNode
(
new_allowed
=
True
)
if
args
.
config
:
config
.
merge_from_file
(
args
.
config
)
if
args
.
decode_cfg
:
decode_confs
=
CfgNode
(
new_allowed
=
True
)
decode_confs
.
merge_from_file
(
args
.
decode_cfg
)
config
.
decode
=
decode_confs
if
args
.
opts
:
config
.
merge_from_list
(
args
.
opts
)
config
.
freeze
()
print
(
config
)
print
(
config
)
if
args
.
dump_config
:
maybe_dump_config
(
args
.
dump_config
,
config
)
with
open
(
args
.
dump_config
,
'w'
)
as
f
:
print
(
config
,
file
=
f
)
# Setting for profiling
# Setting for profiling
pr
=
cProfile
.
Profile
()
pr
=
cProfile
.
Profile
()
...
...
paddlespeech/s2t/exps/u2/bin/test_wav.py
浏览文件 @
225737d4
...
@@ -16,15 +16,14 @@ import os
...
@@ -16,15 +16,14 @@ import os
import
sys
import
sys
from
pathlib
import
Path
from
pathlib
import
Path
import
distutils
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
import
soundfile
import
soundfile
from
yacs.config
import
CfgNode
from
paddlespeech.audio.transform.transformation
import
Transformation
from
paddlespeech.audio.transform.transformation
import
Transformation
from
paddlespeech.s2t.frontend.featurizer.text_featurizer
import
TextFeaturizer
from
paddlespeech.s2t.frontend.featurizer.text_featurizer
import
TextFeaturizer
from
paddlespeech.s2t.models.u2
import
U2Model
from
paddlespeech.s2t.models.u2
import
U2Model
from
paddlespeech.s2t.training.cli
import
config_from_args
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.utils.log
import
Log
from
paddlespeech.s2t.utils.log
import
Log
from
paddlespeech.s2t.utils.utility
import
UpdateConfig
from
paddlespeech.s2t.utils.utility
import
UpdateConfig
...
@@ -125,27 +124,7 @@ def main(config, args):
...
@@ -125,27 +124,7 @@ def main(config, args):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
default_argument_parser
()
parser
=
default_argument_parser
()
# save asr result to
parser
.
add_argument
(
"--result_file"
,
type
=
str
,
help
=
"path of save the asr result"
)
parser
.
add_argument
(
"--audio_file"
,
type
=
str
,
help
=
"path of the input audio file"
)
parser
.
add_argument
(
"--debug"
,
type
=
distutils
.
util
.
strtobool
,
default
=
False
,
help
=
"for debug."
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
config
=
CfgNode
(
new_allowed
=
True
)
config
=
config_from_args
(
args
)
if
args
.
config
:
config
.
merge_from_file
(
args
.
config
)
if
args
.
decode_cfg
:
decode_confs
=
CfgNode
(
new_allowed
=
True
)
decode_confs
.
merge_from_file
(
args
.
decode_cfg
)
config
.
decode
=
decode_confs
if
args
.
opts
:
config
.
merge_from_list
(
args
.
opts
)
config
.
freeze
()
main
(
config
,
args
)
main
(
config
,
args
)
paddlespeech/s2t/exps/u2/bin/train.py
浏览文件 @
225737d4
...
@@ -15,14 +15,12 @@
...
@@ -15,14 +15,12 @@
import
cProfile
import
cProfile
import
os
import
os
from
yacs.config
import
CfgNode
from
paddlespeech.s2t.exps.u2.model
import
U2Trainer
as
Trainer
from
paddlespeech.s2t.exps.u2.model
import
U2Trainer
as
Trainer
from
paddlespeech.s2t.training.cli
import
config_from_args
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
default_argument_parser
from
paddlespeech.s2t.training.cli
import
maybe_dump_config
from
paddlespeech.utils.argparse
import
print_arguments
from
paddlespeech.utils.argparse
import
print_arguments
# from paddlespeech.s2t.exps.u2.trainer import U2Trainer as Trainer
def
main_sp
(
config
,
args
):
def
main_sp
(
config
,
args
):
exp
=
Trainer
(
config
,
args
)
exp
=
Trainer
(
config
,
args
)
...
@@ -39,17 +37,9 @@ if __name__ == "__main__":
...
@@ -39,17 +37,9 @@ if __name__ == "__main__":
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
print_arguments
(
args
,
globals
())
print_arguments
(
args
,
globals
())
# https://yaml.org/type/float.html
config
=
config_from_args
(
args
)
config
=
CfgNode
(
new_allowed
=
True
)
if
args
.
config
:
config
.
merge_from_file
(
args
.
config
)
if
args
.
opts
:
config
.
merge_from_list
(
args
.
opts
)
config
.
freeze
()
print
(
config
)
print
(
config
)
if
args
.
dump_config
:
maybe_dump_config
(
args
.
dump_path
,
config
)
with
open
(
args
.
dump_config
,
'w'
)
as
f
:
print
(
config
,
file
=
f
)
# Setting for profiling
# Setting for profiling
pr
=
cProfile
.
Profile
()
pr
=
cProfile
.
Profile
()
...
...
paddlespeech/s2t/training/cli.py
浏览文件 @
225737d4
...
@@ -13,6 +13,9 @@
...
@@ -13,6 +13,9 @@
# limitations under the License.
# limitations under the License.
import
argparse
import
argparse
import
distutils
from
yacs.config
import
CfgNode
class
ExtendAction
(
argparse
.
Action
):
class
ExtendAction
(
argparse
.
Action
):
"""
"""
...
@@ -68,7 +71,15 @@ def default_argument_parser(parser=None):
...
@@ -68,7 +71,15 @@ def default_argument_parser(parser=None):
parser
.
register
(
'action'
,
'extend'
,
ExtendAction
)
parser
.
register
(
'action'
,
'extend'
,
ExtendAction
)
parser
.
add_argument
(
parser
.
add_argument
(
'--conf'
,
type
=
open
,
action
=
LoadFromFile
,
help
=
"config file."
)
'--conf'
,
type
=
open
,
action
=
LoadFromFile
,
help
=
"config file."
)
parser
.
add_argument
(
"--debug"
,
type
=
distutils
.
util
.
strtobool
,
default
=
False
,
help
=
"logging with debug mode."
)
parser
.
add_argument
(
"--dump_path"
,
type
=
str
,
default
=
None
,
help
=
"path to dump config file."
)
# train group
train_group
=
parser
.
add_argument_group
(
train_group
=
parser
.
add_argument_group
(
title
=
'Train Options'
,
description
=
None
)
title
=
'Train Options'
,
description
=
None
)
train_group
.
add_argument
(
train_group
.
add_argument
(
...
@@ -103,14 +114,35 @@ def default_argument_parser(parser=None):
...
@@ -103,14 +114,35 @@ def default_argument_parser(parser=None):
train_group
.
add_argument
(
train_group
.
add_argument
(
"--dump-config"
,
metavar
=
"FILE"
,
help
=
"dump config to `this` file."
)
"--dump-config"
,
metavar
=
"FILE"
,
help
=
"dump config to `this` file."
)
# test group
test_group
=
parser
.
add_argument_group
(
test_group
=
parser
.
add_argument_group
(
title
=
'Test Options'
,
description
=
None
)
title
=
'Test Options'
,
description
=
None
)
test_group
.
add_argument
(
test_group
.
add_argument
(
"--decode_cfg"
,
"--decode_cfg"
,
metavar
=
"DECODE_CONFIG_FILE"
,
metavar
=
"DECODE_CONFIG_FILE"
,
help
=
"decode config file."
)
help
=
"decode config file."
)
test_group
.
add_argument
(
"--result_file"
,
type
=
str
,
help
=
"path of save the asr result"
)
test_group
.
add_argument
(
"--audio_file"
,
type
=
str
,
help
=
"path of the input audio file"
)
# quant & export
quant_group
=
parser
.
add_argument_group
(
title
=
'Quant Options'
,
description
=
None
)
quant_group
.
add_argument
(
"--audio_scp"
,
type
=
str
,
help
=
"path of the input audio scp file"
)
quant_group
.
add_argument
(
"--num_utts"
,
type
=
int
,
default
=
200
,
help
=
"num utts for quant calibrition."
)
quant_group
.
add_argument
(
"--export_path"
,
type
=
str
,
default
=
'export.jit.quant'
,
help
=
"path of the jit model to save"
)
# profile group
profile_group
=
parser
.
add_argument_group
(
profile_group
=
parser
.
add_argument_group
(
title
=
'Benchmark Options'
,
description
=
None
)
title
=
'Benchmark Options'
,
description
=
None
)
profile_group
.
add_argument
(
profile_group
.
add_argument
(
...
@@ -131,3 +163,28 @@ def default_argument_parser(parser=None):
...
@@ -131,3 +163,28 @@ def default_argument_parser(parser=None):
help
=
'max iteration for benchmark.'
)
help
=
'max iteration for benchmark.'
)
return
parser
return
parser
def
config_from_args
(
args
):
# https://yaml.org/type/float.html
config
=
CfgNode
(
new_allowed
=
True
)
if
args
.
config
:
config
.
merge_from_file
(
args
.
config
)
if
args
.
decode_cfg
:
decode_confs
=
CfgNode
(
new_allowed
=
True
)
decode_confs
.
merge_from_file
(
args
.
decode_cfg
)
config
.
decode
=
decode_confs
if
args
.
opts
:
config
.
merge_from_list
(
args
.
opts
)
config
.
freeze
()
return
config
def
maybe_dump_config
(
dump_path
,
config
):
if
dump_path
:
with
open
(
dump_path
,
'w'
)
as
f
:
print
(
config
,
file
=
f
)
print
(
f
"save config to
{
dump_path
}
"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录