Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
85094bce
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
85094bce
编写于
10月 26, 2022
作者:
Y
YangZhou
提交者:
GitHub
10月 26, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Cherry-pick][audio] fix tess split fold (#47350)
* fix tess split fold * format
上级
12e6dfcf
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
57 addition
and
43 deletion
+57
-43
python/paddle/audio/datasets/esc50.py
python/paddle/audio/datasets/esc50.py
+25
-17
python/paddle/audio/datasets/tess.py
python/paddle/audio/datasets/tess.py
+32
-26
未找到文件。
python/paddle/audio/datasets/esc50.py
浏览文件 @
85094bce
...
@@ -133,22 +133,27 @@ class ESC50(AudioClassificationDataset):
...
@@ -133,22 +133,27 @@ class ESC50(AudioClassificationDataset):
meta
=
os
.
path
.
join
(
'ESC-50-master'
,
'meta'
,
'esc50.csv'
)
meta
=
os
.
path
.
join
(
'ESC-50-master'
,
'meta'
,
'esc50.csv'
)
meta_info
=
collections
.
namedtuple
(
meta_info
=
collections
.
namedtuple
(
'META_INFO'
,
'META_INFO'
,
(
'filename'
,
'fold'
,
'target'
,
'category'
,
'esc10'
,
'src_file'
,
'take'
))
(
'filename'
,
'fold'
,
'target'
,
'category'
,
'esc10'
,
'src_file'
,
'take'
),
)
audio_path
=
os
.
path
.
join
(
'ESC-50-master'
,
'audio'
)
audio_path
=
os
.
path
.
join
(
'ESC-50-master'
,
'audio'
)
def
__init__
(
self
,
def
__init__
(
self
,
mode
:
str
=
'train'
,
mode
:
str
=
'train'
,
split
:
int
=
1
,
split
:
int
=
1
,
feat_type
:
str
=
'raw'
,
feat_type
:
str
=
'raw'
,
archive
=
None
,
archive
=
None
,
**
kwargs
):
**
kwargs
,
):
assert
split
in
range
(
1
,
6
),
f
'The selected split should be integer, and 1 <= split <= 5, but got
{
split
}
'
if
archive
is
not
None
:
if
archive
is
not
None
:
self
.
archive
=
archive
self
.
archive
=
archive
files
,
labels
=
self
.
_get_data
(
mode
,
split
)
files
,
labels
=
self
.
_get_data
(
mode
,
split
)
super
(
ESC50
,
self
).
__init__
(
files
=
files
,
super
(
ESC50
,
self
).
__init__
(
labels
=
labels
,
files
=
files
,
labels
=
labels
,
feat_type
=
feat_type
,
**
kwargs
feat_type
=
feat_type
,
)
**
kwargs
)
def
_get_meta_info
(
self
)
->
List
[
collections
.
namedtuple
]:
def
_get_meta_info
(
self
)
->
List
[
collections
.
namedtuple
]:
ret
=
[]
ret
=
[]
...
@@ -158,12 +163,15 @@ class ESC50(AudioClassificationDataset):
...
@@ -158,12 +163,15 @@ class ESC50(AudioClassificationDataset):
return
ret
return
ret
def
_get_data
(
self
,
mode
:
str
,
split
:
int
)
->
Tuple
[
List
[
str
],
List
[
int
]]:
def
_get_data
(
self
,
mode
:
str
,
split
:
int
)
->
Tuple
[
List
[
str
],
List
[
int
]]:
if
not
os
.
path
.
isdir
(
os
.
path
.
join
(
DATA_HOME
,
self
.
audio_path
))
or
\
if
not
os
.
path
.
isdir
(
not
os
.
path
.
isfile
(
os
.
path
.
join
(
DATA_HOME
,
self
.
meta
)):
os
.
path
.
join
(
DATA_HOME
,
self
.
audio_path
)
download
.
get_path_from_url
(
self
.
archive
[
'url'
],
)
or
not
os
.
path
.
isfile
(
os
.
path
.
join
(
DATA_HOME
,
self
.
meta
)):
download
.
get_path_from_url
(
self
.
archive
[
'url'
],
DATA_HOME
,
DATA_HOME
,
self
.
archive
[
'md5'
],
self
.
archive
[
'md5'
],
decompress
=
True
)
decompress
=
True
,
)
meta_info
=
self
.
_get_meta_info
()
meta_info
=
self
.
_get_meta_info
()
...
...
python/paddle/audio/datasets/tess.py
浏览文件 @
85094bce
...
@@ -71,8 +71,7 @@ class TESS(AudioClassificationDataset):
...
@@ -71,8 +71,7 @@ class TESS(AudioClassificationDataset):
"""
"""
archive
=
{
archive
=
{
'url'
:
'url'
:
'https://bj.bcebos.com/paddleaudio/datasets/TESS_Toronto_emotional_speech_set.zip'
,
'https://bj.bcebos.com/paddleaudio/datasets/TESS_Toronto_emotional_speech_set.zip'
,
'md5'
:
'1465311b24d1de704c4c63e4ccc470c7'
,
'md5'
:
'1465311b24d1de704c4c63e4ccc470c7'
,
}
}
...
@@ -85,28 +84,32 @@ class TESS(AudioClassificationDataset):
...
@@ -85,28 +84,32 @@ class TESS(AudioClassificationDataset):
'ps'
,
# pleasant surprise
'ps'
,
# pleasant surprise
'sad'
,
'sad'
,
]
]
meta_info
=
collections
.
namedtuple
(
'META_INFO'
,
meta_info
=
collections
.
namedtuple
(
(
'speaker'
,
'word'
,
'emotion'
))
'META_INFO'
,
(
'speaker'
,
'word'
,
'emotion'
)
)
audio_path
=
'TESS_Toronto_emotional_speech_set'
audio_path
=
'TESS_Toronto_emotional_speech_set'
def
__init__
(
self
,
def
__init__
(
mode
=
'train'
,
self
,
n_folds
=
5
,
mode
:
str
=
'train'
,
split
=
1
,
n_folds
:
int
=
5
,
feat_type
=
'raw'
,
split
:
int
=
1
,
feat_type
:
str
=
'raw'
,
archive
=
None
,
archive
=
None
,
**
kwargs
):
**
kwargs
,
"""
):
assert
isinstance
(
n_folds
,
int
)
and
(
"""
n_folds
>=
1
assert
split
<=
n_folds
,
f
'The selected split should not be larger than n_fold, but got
{
split
}
>
{
n_folds
}
'
),
f
'the n_folds should be integer and n_folds >= 1, but got
{
n_folds
}
'
assert
split
in
range
(
1
,
n_folds
+
1
),
f
'The selected split should be integer and should be 1 <= split <=
{
n_folds
}
, but got
{
split
}
'
if
archive
is
not
None
:
if
archive
is
not
None
:
self
.
archive
=
archive
self
.
archive
=
archive
files
,
labels
=
self
.
_get_data
(
mode
,
n_folds
,
split
)
files
,
labels
=
self
.
_get_data
(
mode
,
n_folds
,
split
)
super
(
TESS
,
self
).
__init__
(
files
=
files
,
super
(
TESS
,
self
).
__init__
(
labels
=
labels
,
files
=
files
,
labels
=
labels
,
feat_type
=
feat_type
,
**
kwargs
feat_type
=
feat_type
,
)
**
kwargs
)
def
_get_meta_info
(
self
,
files
)
->
List
[
collections
.
namedtuple
]:
def
_get_meta_info
(
self
,
files
)
->
List
[
collections
.
namedtuple
]:
ret
=
[]
ret
=
[]
...
@@ -115,12 +118,16 @@ class TESS(AudioClassificationDataset):
...
@@ -115,12 +118,16 @@ class TESS(AudioClassificationDataset):
ret
.
append
(
self
.
meta_info
(
*
basename_without_extend
.
split
(
'_'
)))
ret
.
append
(
self
.
meta_info
(
*
basename_without_extend
.
split
(
'_'
)))
return
ret
return
ret
def
_get_data
(
self
,
mode
,
n_folds
,
split
)
->
Tuple
[
List
[
str
],
List
[
int
]]:
def
_get_data
(
self
,
mode
:
str
,
n_folds
:
int
,
split
:
int
)
->
Tuple
[
List
[
str
],
List
[
int
]]:
if
not
os
.
path
.
isdir
(
os
.
path
.
join
(
DATA_HOME
,
self
.
audio_path
)):
if
not
os
.
path
.
isdir
(
os
.
path
.
join
(
DATA_HOME
,
self
.
audio_path
)):
download
.
get_path_from_url
(
self
.
archive
[
'url'
],
download
.
get_path_from_url
(
self
.
archive
[
'url'
],
DATA_HOME
,
DATA_HOME
,
self
.
archive
[
'md5'
],
self
.
archive
[
'md5'
],
decompress
=
True
)
decompress
=
True
,
)
wav_files
=
[]
wav_files
=
[]
for
root
,
_
,
files
in
os
.
walk
(
os
.
path
.
join
(
DATA_HOME
,
self
.
audio_path
)):
for
root
,
_
,
files
in
os
.
walk
(
os
.
path
.
join
(
DATA_HOME
,
self
.
audio_path
)):
...
@@ -132,11 +139,10 @@ class TESS(AudioClassificationDataset):
...
@@ -132,11 +139,10 @@ class TESS(AudioClassificationDataset):
files
=
[]
files
=
[]
labels
=
[]
labels
=
[]
n_samples_per_fold
=
len
(
meta_info
)
//
n_folds
for
idx
,
sample
in
enumerate
(
meta_info
):
for
idx
,
sample
in
enumerate
(
meta_info
):
_
,
_
,
emotion
=
sample
_
,
_
,
emotion
=
sample
target
=
self
.
label_list
.
index
(
emotion
)
target
=
self
.
label_list
.
index
(
emotion
)
fold
=
idx
//
n_samples_per_fold
+
1
fold
=
idx
%
n_folds
+
1
if
mode
==
'train'
and
int
(
fold
)
!=
split
:
if
mode
==
'train'
and
int
(
fold
)
!=
split
:
files
.
append
(
wav_files
[
idx
])
files
.
append
(
wav_files
[
idx
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录