George
commited on
Commit
•
1e4c870
1
Parent(s):
15e6d89
norm code
Browse files- chest_falsetto.py +22 -22
chest_falsetto.py
CHANGED
@@ -3,13 +3,13 @@ import random
|
|
3 |
import datasets
|
4 |
from datasets.tasks import AudioClassification
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
_HOMEPAGE = f"https://huggingface.co/datasets/ccmusic-database/{
|
13 |
|
14 |
_CITATION = """\
|
15 |
@dataset{zhaorui_liu_2021_5676893,
|
@@ -41,9 +41,9 @@ class chest_falsetto(datasets.GeneratorBasedBuilder):
|
|
41 |
{
|
42 |
"audio": datasets.Audio(sampling_rate=44_100),
|
43 |
"image": datasets.Image(),
|
44 |
-
"label": datasets.features.ClassLabel(names=_NAMES),
|
45 |
-
"gender": datasets.features.ClassLabel(names=
|
46 |
-
"singing_method": datasets.features.ClassLabel(names=
|
47 |
}
|
48 |
),
|
49 |
supervised_keys=("audio", "label"),
|
@@ -66,18 +66,8 @@ class chest_falsetto(datasets.GeneratorBasedBuilder):
|
|
66 |
dataset = []
|
67 |
|
68 |
for path in files:
|
69 |
-
|
70 |
-
|
71 |
-
sex = file_name.split('_')[1]
|
72 |
-
gender = 'male' if sex == 'm' else 'female'
|
73 |
-
method = file_name.split('_')[2][:-4]
|
74 |
-
dataset.append({
|
75 |
-
"audio": path,
|
76 |
-
"image": path.replace('.wav', '.jpg').replace('/audio/', '/image/').replace('\\audio\\', '\\image\\'),
|
77 |
-
"label": f'{sex}_{method}',
|
78 |
-
"gender": gender,
|
79 |
-
"singing_method": method,
|
80 |
-
})
|
81 |
|
82 |
random.shuffle(dataset)
|
83 |
data_count = len(dataset)
|
@@ -107,4 +97,14 @@ class chest_falsetto(datasets.GeneratorBasedBuilder):
|
|
107 |
|
108 |
def _generate_examples(self, files):
|
109 |
for i, path in enumerate(files):
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import datasets
|
4 |
from datasets.tasks import AudioClassification
|
5 |
|
6 |
+
_NAMES = {
|
7 |
+
'all': ['m_chest', 'f_chest', 'm_falsetto', 'f_falsetto'],
|
8 |
+
'gender': ['female', 'male'],
|
9 |
+
'method': ['falsetto', 'chest']
|
10 |
+
}
|
11 |
|
12 |
+
_HOMEPAGE = f"https://huggingface.co/datasets/ccmusic-database/{os.path.basename(__file__).split('.')[0]}"
|
13 |
|
14 |
_CITATION = """\
|
15 |
@dataset{zhaorui_liu_2021_5676893,
|
|
|
41 |
{
|
42 |
"audio": datasets.Audio(sampling_rate=44_100),
|
43 |
"image": datasets.Image(),
|
44 |
+
"label": datasets.features.ClassLabel(names=_NAMES['all']),
|
45 |
+
"gender": datasets.features.ClassLabel(names=_NAMES['gender']),
|
46 |
+
"singing_method": datasets.features.ClassLabel(names=_NAMES['method']),
|
47 |
}
|
48 |
),
|
49 |
supervised_keys=("audio", "label"),
|
|
|
66 |
dataset = []
|
67 |
|
68 |
for path in files:
|
69 |
+
if path.endswith(".wav"):
|
70 |
+
dataset.append(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
random.shuffle(dataset)
|
73 |
data_count = len(dataset)
|
|
|
97 |
|
98 |
def _generate_examples(self, files):
|
99 |
for i, path in enumerate(files):
|
100 |
+
file_name = os.path.basename(path)
|
101 |
+
sex = file_name.split('_')[1]
|
102 |
+
gender = 'male' if sex == 'm' else 'female'
|
103 |
+
method = file_name.split('_')[2][:-4]
|
104 |
+
yield i, {
|
105 |
+
"audio": path,
|
106 |
+
"image": path.replace('.wav', '.jpg').replace('/audio/', '/image/').replace('\\audio\\', '\\image\\'),
|
107 |
+
"label": f'{sex}_{method}',
|
108 |
+
"gender": gender,
|
109 |
+
"singing_method": method,
|
110 |
+
}
|