Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
0cc81a52
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看板
提交
0cc81a52
编写于
11月 29, 2021
作者:
J
Junkun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update format
上级
3c8e8734
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
22 addition
and
24 deletion
+22
-24
utils/addjson.py
utils/addjson.py
+12
-15
utils/scp2json.py
utils/scp2json.py
+10
-9
未找到文件。
utils/addjson.py
浏览文件 @
0cc81a52
#!/usr/bin/env python3
#!/usr/bin/env python3
# encoding: utf-8
# encoding: utf-8
# Copyright 2018 Nagoya University (Tomoki Hayashi)
# Copyright 2018 Nagoya University (Tomoki Hayashi)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
from
__future__
import
print_function
from
__future__
import
print_function
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
...
@@ -12,7 +10,6 @@ import codecs
...
@@ -12,7 +10,6 @@ import codecs
import
json
import
json
import
logging
import
logging
import
sys
import
sys
from
distutils.util
import
strtobool
from
distutils.util
import
strtobool
from
espnet.utils.cli_utils
import
get_commandline_args
from
espnet.utils.cli_utils
import
get_commandline_args
...
@@ -23,17 +20,16 @@ is_python2 = sys.version_info[0] == 2
...
@@ -23,17 +20,16 @@ is_python2 = sys.version_info[0] == 2
def
get_parser
():
def
get_parser
():
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
description
=
"add multiple json values to an input or output value"
,
description
=
"add multiple json values to an input or output value"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
)
)
parser
.
add_argument
(
"jsons"
,
type
=
str
,
nargs
=
"+"
,
help
=
"json files"
)
parser
.
add_argument
(
"jsons"
,
type
=
str
,
nargs
=
"+"
,
help
=
"json files"
)
parser
.
add_argument
(
parser
.
add_argument
(
"-i"
,
"-i"
,
"--is-input"
,
"--is-input"
,
default
=
True
,
default
=
True
,
type
=
strtobool
,
type
=
strtobool
,
help
=
"If true, add to input. If false, add to output"
,
help
=
"If true, add to input. If false, add to output"
,
)
)
parser
.
add_argument
(
parser
.
add_argument
(
"--verbose"
,
"-V"
,
default
=
0
,
type
=
int
,
help
=
"Verbose option"
)
"--verbose"
,
"-V"
,
default
=
0
,
type
=
int
,
help
=
"Verbose option"
)
return
parser
return
parser
...
@@ -121,7 +117,8 @@ if __name__ == "__main__":
...
@@ -121,7 +117,8 @@ if __name__ == "__main__":
out_add_dic
=
{}
out_add_dic
=
{}
# add shape
# add shape
if
"odim"
in
adddic
and
"olen"
in
adddic
:
if
"odim"
in
adddic
and
"olen"
in
adddic
:
out_add_dic
[
"shape"
]
=
[
int
(
adddic
[
"olen"
]),
int
(
adddic
[
"odim"
])]
out_add_dic
[
"shape"
]
=
[
int
(
adddic
[
"olen"
]),
int
(
adddic
[
"odim"
])]
elif
"odim"
in
adddic
:
elif
"odim"
in
adddic
:
out_add_dic
[
"shape"
]
=
[
int
(
adddic
[
"odim"
])]
out_add_dic
[
"shape"
]
=
[
int
(
adddic
[
"odim"
])]
# add all other key value
# add all other key value
...
@@ -143,13 +140,13 @@ if __name__ == "__main__":
...
@@ -143,13 +140,13 @@ if __name__ == "__main__":
# ensure "ensure_ascii=False", which is a bug
# ensure "ensure_ascii=False", which is a bug
jsonstring
=
json
.
dumps
(
jsonstring
=
json
.
dumps
(
{
"utts"
:
new_dic
},
{
"utts"
:
new_dic
},
indent
=
4
,
indent
=
4
,
ensure_ascii
=
False
,
ensure_ascii
=
False
,
sort_keys
=
True
,
sort_keys
=
True
,
separators
=
(
","
,
": "
),
separators
=
(
","
,
": "
),
)
)
sys
.
stdout
=
codecs
.
getwriter
(
"utf-8"
)(
sys
.
stdout
sys
.
stdout
=
codecs
.
getwriter
(
"utf-8"
)(
if
is_python2
else
sys
.
stdout
.
buffer
)
sys
.
stdout
if
is_python2
else
sys
.
stdout
.
buffer
)
print
(
jsonstring
)
print
(
jsonstring
)
utils/scp2json.py
浏览文件 @
0cc81a52
#!/usr/bin/env python3
#!/usr/bin/env python3
# encoding: utf-8
# encoding: utf-8
# Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
from
__future__
import
print_function
from
__future__
import
print_function
...
@@ -17,8 +16,7 @@ is_python2 = sys.version_info[0] == 2
...
@@ -17,8 +16,7 @@ is_python2 = sys.version_info[0] == 2
def
get_parser
():
def
get_parser
():
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
description
=
"convert scp to json"
,
description
=
"convert scp to json"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
)
)
parser
.
add_argument
(
"--key"
,
"-k"
,
type
=
str
,
help
=
"key"
)
parser
.
add_argument
(
"--key"
,
"-k"
,
type
=
str
,
help
=
"key"
)
return
parser
return
parser
...
@@ -28,10 +26,10 @@ if __name__ == "__main__":
...
@@ -28,10 +26,10 @@ if __name__ == "__main__":
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
new_line
=
{}
new_line
=
{}
sys
.
stdin
=
codecs
.
getreader
(
"utf-8"
)(
sys
.
stdin
if
is_python2
else
sys
.
stdin
.
buffer
)
sys
.
stdin
=
codecs
.
getreader
(
"utf-8"
)(
sys
.
stdin
sys
.
stdout
=
codecs
.
getwriter
(
"utf-8"
)(
if
is_python2
else
sys
.
stdin
.
buffer
)
sys
.
stdout
if
is_python2
else
sys
.
stdout
.
buffer
sys
.
stdout
=
codecs
.
getwriter
(
"utf-8"
)(
sys
.
stdout
)
if
is_python2
else
sys
.
stdout
.
buffer
)
line
=
sys
.
stdin
.
readline
()
line
=
sys
.
stdin
.
readline
()
while
line
:
while
line
:
x
=
line
.
rstrip
().
split
()
x
=
line
.
rstrip
().
split
()
...
@@ -43,6 +41,9 @@ if __name__ == "__main__":
...
@@ -43,6 +41,9 @@ if __name__ == "__main__":
# ensure "ensure_ascii=False", which is a bug
# ensure "ensure_ascii=False", which is a bug
jsonstring
=
json
.
dumps
(
jsonstring
=
json
.
dumps
(
all_l
,
indent
=
4
,
ensure_ascii
=
False
,
sort_keys
=
True
,
separators
=
(
","
,
": "
)
all_l
,
)
indent
=
4
,
ensure_ascii
=
False
,
sort_keys
=
True
,
separators
=
(
","
,
": "
))
print
(
jsonstring
)
print
(
jsonstring
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录