Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
d395c2b8
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看板
提交
d395c2b8
编写于
11月 30, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
jsonlines reade manifest file
上级
7554b610
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
37 addition
and
87 deletion
+37
-87
paddlespeech/s2t/frontend/augmentor/impulse_response.py
paddlespeech/s2t/frontend/augmentor/impulse_response.py
+3
-2
paddlespeech/s2t/frontend/augmentor/noise_perturb.py
paddlespeech/s2t/frontend/augmentor/noise_perturb.py
+3
-2
paddlespeech/s2t/frontend/normalizer.py
paddlespeech/s2t/frontend/normalizer.py
+3
-23
paddlespeech/s2t/frontend/utility.py
paddlespeech/s2t/frontend/utility.py
+1
-20
paddlespeech/s2t/io/dataloader.py
paddlespeech/s2t/io/dataloader.py
+4
-2
paddlespeech/s2t/io/dataset.py
paddlespeech/s2t/io/dataset.py
+4
-3
paddlespeech/s2t/utils/socket_server.py
paddlespeech/s2t/utils/socket_server.py
+3
-3
utils/dump_manifest.py
utils/dump_manifest.py
+5
-3
utils/format_data.py
utils/format_data.py
+4
-2
utils/format_triplet_data.py
utils/format_triplet_data.py
+3
-2
utils/manifest_key_value.py
utils/manifest_key_value.py
+3
-2
utils/utility.py
utils/utility.py
+1
-23
未找到文件。
paddlespeech/s2t/frontend/augmentor/impulse_response.py
浏览文件 @
d395c2b8
...
...
@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Contains the impulse response augmentation model."""
import
jsonlines
from
paddlespeech.s2t.frontend.audio
import
AudioSegment
from
paddlespeech.s2t.frontend.augmentor.base
import
AugmentorBase
from
paddlespeech.s2t.frontend.utility
import
read_manifest
class
ImpulseResponseAugmentor
(
AugmentorBase
):
...
...
@@ -28,7 +28,8 @@ class ImpulseResponseAugmentor(AugmentorBase):
def
__init__
(
self
,
rng
,
impulse_manifest_path
):
self
.
_rng
=
rng
self
.
_impulse_manifest
=
read_manifest
(
impulse_manifest_path
)
with
jsonlines
.
open
(
impulse_manifest_path
,
'r'
)
as
reader
:
self
.
_impulse_manifest
=
list
(
reader
)
def
__call__
(
self
,
x
,
uttid
=
None
,
train
=
True
):
if
not
train
:
...
...
paddlespeech/s2t/frontend/augmentor/noise_perturb.py
浏览文件 @
d395c2b8
...
...
@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Contains the noise perturb augmentation model."""
import
jsonlines
from
paddlespeech.s2t.frontend.audio
import
AudioSegment
from
paddlespeech.s2t.frontend.augmentor.base
import
AugmentorBase
from
paddlespeech.s2t.frontend.utility
import
read_manifest
class
NoisePerturbAugmentor
(
AugmentorBase
):
...
...
@@ -34,7 +34,8 @@ class NoisePerturbAugmentor(AugmentorBase):
self
.
_min_snr_dB
=
min_snr_dB
self
.
_max_snr_dB
=
max_snr_dB
self
.
_rng
=
rng
self
.
_noise_manifest
=
read_manifest
(
manifest_path
=
noise_manifest_path
)
with
jsonlines
.
open
(
noise_manifest_path
,
'r'
)
as
reader
:
self
.
_noise_manifest
=
list
(
reader
)
def
__call__
(
self
,
x
,
uttid
=
None
,
train
=
True
):
if
not
train
:
...
...
paddlespeech/s2t/frontend/normalizer.py
浏览文件 @
d395c2b8
...
...
@@ -13,10 +13,9 @@
# limitations under the License.
"""Contains feature normalizers."""
import
json
import
jsonlines
import
numpy
as
np
import
paddle
import
jsonlines
from
paddle.io
import
DataLoader
from
paddle.io
import
Dataset
...
...
@@ -27,24 +26,6 @@ from paddlespeech.s2t.utils.log import Log
__all__
=
[
"FeatureNormalizer"
]
logger
=
Log
(
__name__
).
getlog
()
def
read_manifest
(
manifest_path
):
"""Load and parse manifest file.
Args:
manifest_path ([type]): Manifest file to load and parse.
Raises:
IOError: If failed to parse the manifest.
Returns:
List[dict]: Manifest parsing results.
"""
manifest
=
[]
with
jsonlines
.
open
(
manifest_path
,
'r'
)
as
reader
:
for
json_data
in
reader
:
manifest
.
append
(
json_data
)
return
manifest
# https://github.com/PaddlePaddle/Paddle/pull/31481
class
CollateFunc
(
object
):
...
...
@@ -78,10 +59,9 @@ class CollateFunc(object):
class
AudioDataset
(
Dataset
):
def
__init__
(
self
,
manifest_path
,
num_samples
=-
1
,
rng
=
None
,
random_seed
=
0
):
self
.
_rng
=
rng
if
rng
else
np
.
random
.
RandomState
(
random_seed
)
manifest
=
[]
with
jsonlines
.
open
(
manifest_path
,
'r'
)
as
reader
:
for
json_data
in
reader
:
manifest
.
append
(
json_data
)
manifest
=
list
(
reader
)
if
num_samples
==
-
1
:
sampled_manifest
=
manifest
...
...
paddlespeech/s2t/frontend/utility.py
浏览文件 @
d395c2b8
...
...
@@ -64,27 +64,8 @@ def load_dict(dict_path: Optional[Text], maskctc=False) -> Optional[List[Text]]:
char_list
.
append
(
MASKCTC
)
return
char_list
def
read_manifest
(
manifest_path
,):
"""Load and parse manifest file.
Args:
manifest_path ([type]): Manifest file to load and parse.
Raises:
IOError: If failed to parse the manifest.
Returns:
List[dict]: Manifest parsing results.
"""
manifest
=
[]
with
jsonlines
.
open
(
manifest_path
,
'r'
)
as
reader
:
for
json_data
in
reader
:
manifest
.
append
(
json_data
)
return
manifest
def
read_manifest
_filter
(
def
read_manifest
(
manifest_path
,
max_input_len
=
float
(
'inf'
),
min_input_len
=
0.0
,
...
...
paddlespeech/s2t/io/dataloader.py
浏览文件 @
d395c2b8
...
...
@@ -15,11 +15,11 @@ from typing import Any
from
typing
import
Dict
from
typing
import
List
from
typing
import
Text
import
jsonlines
import
numpy
as
np
from
paddle.io
import
DataLoader
from
paddlespeech.s2t.frontend.utility
import
read_manifest
from
paddlespeech.s2t.io.batchfy
import
make_batchset
from
paddlespeech.s2t.io.converter
import
CustomConverter
from
paddlespeech.s2t.io.dataset
import
TransformDataset
...
...
@@ -91,7 +91,9 @@ class BatchDataLoader():
self
.
n_iter_processes
=
n_iter_processes
# read json data
self
.
data_json
=
read_manifest
(
json_file
)
with
jsonlines
.
open
(
json_file
,
'r'
)
as
reader
:
self
.
data_json
=
list
(
reader
)
self
.
feat_dim
,
self
.
vocab_size
=
feat_dim_and_vocab_size
(
self
.
data_json
,
mode
=
'asr'
)
...
...
paddlespeech/s2t/io/dataset.py
浏览文件 @
d395c2b8
...
...
@@ -14,7 +14,7 @@
# Modified from espnet(https://github.com/espnet/espnet)
# Modified from wenet(https://github.com/wenet-e2e/wenet)
from
typing
import
Optional
import
jsonlines
from
paddle.io
import
Dataset
from
yacs.config
import
CfgNode
...
...
@@ -95,7 +95,7 @@ class ManifestDataset(Dataset):
super
().
__init__
()
# read manifest
self
.
_manifest
=
read_manifest
_filter
(
self
.
_manifest
=
read_manifest
(
manifest_path
=
manifest_path
,
max_input_len
=
max_input_len
,
min_input_len
=
min_input_len
,
...
...
@@ -184,7 +184,8 @@ class AudioDataset(Dataset):
"""
assert
batch_type
in
[
'static'
,
'dynamic'
]
# read manifest
data
=
read_manifest
(
data_file
)
with
jsonlines
.
open
(
data_file
,
'r'
)
as
reader
:
data
=
list
(
reader
)
if
sort
:
data
=
sorted
(
data
,
key
=
lambda
x
:
x
[
"feat_shape"
][
0
])
if
raw_wav
:
...
...
paddlespeech/s2t/utils/socket_server.py
浏览文件 @
d395c2b8
...
...
@@ -20,8 +20,7 @@ import time
import
wave
from
time
import
gmtime
from
time
import
strftime
from
paddlespeech.s2t.frontend.utility
import
read_manifest
import
jsonlines
__all__
=
[
"socket_send"
,
"warm_up_test"
,
"AsrTCPServer"
,
"AsrRequestHandler"
]
...
...
@@ -44,7 +43,8 @@ def warm_up_test(audio_process_handler,
num_test_cases
,
random_seed
=
0
):
"""Warming-up test."""
manifest
=
read_manifest
(
manifest_path
)
with
jsonlines
.
open
(
manifest_path
)
as
reader
:
manifest
=
list
(
reader
)
rng
=
random
.
Random
(
random_seed
)
samples
=
rng
.
sample
(
manifest
,
num_test_cases
)
for
idx
,
sample
in
enumerate
(
samples
):
...
...
utils/dump_manifest.py
浏览文件 @
d395c2b8
...
...
@@ -16,8 +16,7 @@
import
argparse
from
pathlib
import
Path
from
typing
import
Union
from
paddlespeech.s2t.frontend.utility
import
read_manifest
import
jsonlines
key_whitelist
=
set
([
'feat'
,
'text'
,
'syllable'
,
'phone'
])
filename
=
{
...
...
@@ -32,7 +31,10 @@ def dump_manifest(manifest_path, output_dir: Union[str, Path]):
output_dir
=
Path
(
output_dir
).
expanduser
()
manifest_path
=
Path
(
manifest_path
).
expanduser
()
manifest_jsons
=
read_manifest
(
manifest_path
)
with
jsonlines
.
open
(
str
(
manifest_path
),
'r'
)
as
reader
:
manifest_jsons
=
list
(
reader
)
first_line
=
manifest_jsons
[
0
]
file_map
=
{}
...
...
utils/format_data.py
浏览文件 @
d395c2b8
...
...
@@ -15,11 +15,11 @@
"""format manifest with more metadata."""
import
argparse
import
functools
import
jsonlines
import
json
from
paddlespeech.s2t.frontend.featurizer.text_featurizer
import
TextFeaturizer
from
paddlespeech.s2t.frontend.utility
import
load_cmvn
from
paddlespeech.s2t.frontend.utility
import
read_manifest
from
paddlespeech.s2t.io.utility
import
feat_type
from
paddlespeech.s2t.utils.utility
import
add_arguments
from
paddlespeech.s2t.utils.utility
import
print_arguments
...
...
@@ -71,7 +71,9 @@ def main():
# }
count
=
0
for
manifest_path
in
args
.
manifest_paths
:
manifest_jsons
=
read_manifest
(
manifest_path
)
with
jsonlines
.
open
(
str
(
manifest_path
),
'r'
)
as
reader
:
manifest_jsons
=
list
(
reader
)
for
line_json
in
manifest_jsons
:
output_json
=
{
"input"
:
[],
...
...
utils/format_triplet_data.py
浏览文件 @
d395c2b8
...
...
@@ -16,10 +16,10 @@
import
argparse
import
functools
import
json
import
jsonlines
from
paddlespeech.s2t.frontend.featurizer.text_featurizer
import
TextFeaturizer
from
paddlespeech.s2t.frontend.utility
import
load_cmvn
from
paddlespeech.s2t.frontend.utility
import
read_manifest
from
paddlespeech.s2t.io.utility
import
feat_type
from
paddlespeech.s2t.utils.utility
import
add_arguments
from
paddlespeech.s2t.utils.utility
import
print_arguments
...
...
@@ -63,7 +63,8 @@ def main():
count
=
0
for
manifest_path
in
args
.
manifest_paths
:
manifest_jsons
=
read_manifest
(
manifest_path
)
with
jsonlines
.
open
(
str
(
manifest_path
),
'r'
)
as
reader
:
manifest_jsons
=
list
(
reader
)
for
line_json
in
manifest_jsons
:
# text: translation text, text1: transcript text.
# Currently only support joint-vocab, will add separate vocabs setting.
...
...
utils/manifest_key_value.py
浏览文件 @
d395c2b8
...
...
@@ -3,10 +3,10 @@
import
argparse
import
functools
from
pathlib
import
Path
import
jsonlines
from
utils.utility
import
add_arguments
from
utils.utility
import
print_arguments
from
utils.utility
import
read_manifest
def
main
(
args
):
...
...
@@ -19,7 +19,8 @@ def main(args):
dur_scp
=
outdir
/
'duration'
text_scp
=
outdir
/
'text'
manifest_jsons
=
read_manifest
(
args
.
manifest_path
)
with
jsonlines
.
open
(
args
.
manifest_path
,
'r'
)
as
reader
:
manifest_jsons
=
list
(
reader
)
with
wav_scp
.
open
(
'w'
)
as
fwav
,
dur_scp
.
open
(
'w'
)
as
fdur
,
text_scp
.
open
(
'w'
)
as
ftxt
:
...
...
utils/utility.py
浏览文件 @
d395c2b8
...
...
@@ -22,32 +22,10 @@ from typing import Text
__all__
=
[
"check_md5sum"
,
"getfile_insensitive"
,
"download_multi"
,
"download"
,
"unpack"
,
"unzip"
,
"md5file"
,
"print_arguments"
,
"add_arguments"
,
"
read_manifest"
,
"
get_commandline_args"
"get_commandline_args"
]
def
read_manifest
(
manifest_path
):
"""Load and parse manifest file.
Args:
manifest_path ([type]): Manifest file to load and parse.
Raises:
IOError: If failed to parse the manifest.
Returns:
List[dict]: Manifest parsing results.
"""
manifest
=
[]
for
json_line
in
open
(
manifest_path
,
'r'
):
try
:
json_data
=
json
.
loads
(
json_line
)
manifest
.
append
(
json_data
)
except
Exception
as
e
:
raise
IOError
(
"Error reading manifest: %s"
%
str
(
e
))
return
manifest
def
get_commandline_args
():
extra_chars
=
[
" "
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录