MuGeminorum commited on
Commit
0242b42
1 Parent(s): 1fdf9fe

upd script

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. bel_canto.py +28 -28
README.md CHANGED
@@ -43,7 +43,7 @@ Chinese, English
43
  m_bel, f_bel, m_folk, f_folk
44
 
45
  ### Data Splits
46
- train, validation, test
47
 
48
  ## Dataset Creation
49
  ### Curation Rationale
 
43
  m_bel, f_bel, m_folk, f_folk
44
 
45
  ### Data Splits
46
+ train(4314), validation(539), test(540)
47
 
48
  ## Dataset Creation
49
  ### Curation Rationale
bel_canto.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import socket
3
  import random
4
  import datasets
5
- from datasets.tasks import AudioClassification
6
 
7
 
8
  _NAMES = {
@@ -29,9 +29,7 @@ _CITATION = """\
29
  """
30
 
31
  _DESCRIPTION = """\
32
- This database contains hundreds of acapella singing clips that are sung in two styles,
33
- Bel Conto and Chinese national singing style by professional vocalists.
34
- All of them are sung by professional vocalists and were recorded in professional commercial recording studios.
35
  """
36
 
37
 
@@ -42,32 +40,33 @@ class bel_canto(datasets.GeneratorBasedBuilder):
42
  {
43
  "mel": datasets.Image(),
44
  "cqt": datasets.Image(),
 
45
  "label": datasets.features.ClassLabel(names=_NAMES['all']),
46
  "gender": datasets.features.ClassLabel(names=_NAMES['gender']),
47
- "singing_method": datasets.features.ClassLabel(names=_NAMES['singing_method']),
48
  }
49
  ),
50
- supervised_keys=("audio", "label"),
51
  homepage=_HOMEPAGE,
52
  license="mit",
53
  citation=_CITATION,
54
  description=_DESCRIPTION,
55
  task_templates=[
56
- AudioClassification(
57
- task="audio-classification",
58
- audio_column="audio",
59
- label_column="label",
60
  )
61
- ],
62
  )
63
 
64
  def _cdn_url(self, ip='127.0.0.1', port=80):
65
  try:
66
  # easy for local test
67
  with socket.create_connection((ip, port), timeout=5):
68
- return f'http://{ip}/{_NAME}/data/data.zip'
69
  except (socket.timeout, socket.error):
70
- return f"{_HOMEPAGE}/resolve/main/data/data.zip"
71
 
72
  def _split_generators(self, dl_manager):
73
  data_files = dl_manager.download_and_extract(self._cdn_url())
@@ -87,32 +86,33 @@ class bel_canto(datasets.GeneratorBasedBuilder):
87
  datasets.SplitGenerator(
88
  name=datasets.Split.TRAIN,
89
  gen_kwargs={
90
- "files": dataset[:p80],
91
- },
92
  ),
93
  datasets.SplitGenerator(
94
  name=datasets.Split.VALIDATION,
95
  gen_kwargs={
96
- "files": dataset[p80:p90],
97
- },
98
  ),
99
  datasets.SplitGenerator(
100
  name=datasets.Split.TEST,
101
  gen_kwargs={
102
- "files": dataset[p90:],
103
- },
104
- ),
105
  ]
106
 
107
  def _generate_examples(self, files):
108
- for i, path in enumerate(files):
109
- file_name = os.path.basename(path)
110
- sex = file_name.split('_')[2].split(' (')[0]
111
- method = file_name.split('_')[1].lower()
112
  yield i, {
113
- "mel": path,
114
- "cqt": path.replace('/mel/', '/cqt/').replace('\\mel\\', '\\cqt\\'),
115
- "label": f'{sex}_{method}',
 
116
  "gender": 'male' if sex == 'm' else 'female',
117
- "singing_method": 'Bel_Canto' if method == 'bel' else 'Folk_Singing',
118
  }
 
2
  import socket
3
  import random
4
  import datasets
5
+ from datasets.tasks import ImageClassification
6
 
7
 
8
  _NAMES = {
 
29
  """
30
 
31
  _DESCRIPTION = """\
32
+ This database contains hundreds of acapella singing clips that are sung in two styles, Bel Conto and Chinese national singing style by professional vocalists. All of them are sung by professional vocalists and were recorded in professional commercial recording studios.
 
 
33
  """
34
 
35
 
 
40
  {
41
  "mel": datasets.Image(),
42
  "cqt": datasets.Image(),
43
+ "chroma": 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['singing_method'])
47
  }
48
  ),
49
+ supervised_keys=("mel", "label"),
50
  homepage=_HOMEPAGE,
51
  license="mit",
52
  citation=_CITATION,
53
  description=_DESCRIPTION,
54
  task_templates=[
55
+ ImageClassification(
56
+ task="image-classification",
57
+ image_column="mel",
58
+ label_column="label"
59
  )
60
+ ]
61
  )
62
 
63
  def _cdn_url(self, ip='127.0.0.1', port=80):
64
  try:
65
  # easy for local test
66
  with socket.create_connection((ip, port), timeout=5):
67
+ return f'http://{ip}/{_NAME}/data/belcanto_data.zip'
68
  except (socket.timeout, socket.error):
69
+ return f"{_HOMEPAGE}/resolve/main/data/belcanto_data.zip"
70
 
71
  def _split_generators(self, dl_manager):
72
  data_files = dl_manager.download_and_extract(self._cdn_url())
 
86
  datasets.SplitGenerator(
87
  name=datasets.Split.TRAIN,
88
  gen_kwargs={
89
+ "files": dataset[:p80]
90
+ }
91
  ),
92
  datasets.SplitGenerator(
93
  name=datasets.Split.VALIDATION,
94
  gen_kwargs={
95
+ "files": dataset[p80:p90]
96
+ }
97
  ),
98
  datasets.SplitGenerator(
99
  name=datasets.Split.TEST,
100
  gen_kwargs={
101
+ "files": dataset[p90:]
102
+ }
103
+ )
104
  ]
105
 
106
  def _generate_examples(self, files):
107
+ for i, fpath in enumerate(files):
108
+ dirname = os.path.basename(os.path.dirname(fpath))
109
+ sex = dirname.split('_')[0]
110
+ method = dirname.split('_')[1]
111
  yield i, {
112
+ "mel": fpath,
113
+ "cqt": fpath.replace('mel', 'cqt'),
114
+ "chroma": fpath.replace('mel', 'chroma'),
115
+ "label": dirname,
116
  "gender": 'male' if sex == 'm' else 'female',
117
+ "singing_method": 'Bel_Canto' if method == 'bel' else 'Folk_Singing'
118
  }