Datasets:
George
commited on
Commit
•
784aa77
1
Parent(s):
9b62df5
activate ci
Browse files- README.md +2 -2
- piano_sound_quality.py +6 -7
README.md
CHANGED
@@ -24,7 +24,7 @@ librosa
|
|
24 |
```
|
25 |
from datasets import load_dataset
|
26 |
|
27 |
-
data = load_dataset("ccmusic-database/piano_sound_quality", split="
|
28 |
labels = data.features['label'].names
|
29 |
|
30 |
for item in data:
|
@@ -52,7 +52,7 @@ A score sheet (.xls format) of the piano sound quality rated by 29 people who pa
|
|
52 |
|
53 |
### Supported Tasks and Leaderboards
|
54 |
|
55 |
-
Piano Sound Classification
|
56 |
|
57 |
### Languages
|
58 |
|
|
|
24 |
```
|
25 |
from datasets import load_dataset
|
26 |
|
27 |
+
data = load_dataset("ccmusic-database/piano_sound_quality", split="train")
|
28 |
labels = data.features['label'].names
|
29 |
|
30 |
for item in data:
|
|
|
52 |
|
53 |
### Supported Tasks and Leaderboards
|
54 |
|
55 |
+
Piano Sound Classification, pitch detection
|
56 |
|
57 |
### Languages
|
58 |
|
piano_sound_quality.py
CHANGED
@@ -8,7 +8,7 @@ import requests
|
|
8 |
from datasets.tasks import AudioClassification
|
9 |
|
10 |
|
11 |
-
# Once upload a new piano brand, please register its name here
|
12 |
_NAMES = [
|
13 |
"1_PearlRiver",
|
14 |
"2_YoungChang",
|
@@ -45,8 +45,7 @@ Data was annotated by students from the China Conservatory of Music (CCMUSIC) in
|
|
45 |
and collected by George Chou.
|
46 |
"""
|
47 |
|
48 |
-
_URLS = {piano: _HOMEPAGE
|
49 |
-
piano + ".zip" for piano in _NAMES}
|
50 |
|
51 |
|
52 |
_PITCHES = {"009": "A2", "010": "A2#/B2b", "011": "B2", "100": "C1", "101": "C1#/D1b", "102": "D1", "103": "D1#/E1b",
|
@@ -90,19 +89,19 @@ class piano_sound_quality(datasets.GeneratorBasedBuilder):
|
|
90 |
],
|
91 |
)
|
92 |
|
93 |
-
def
|
94 |
with wave.open(io.BytesIO(file_bytes), 'r') as wav_file:
|
95 |
frames = wav_file.getnframes()
|
96 |
rate = wav_file.getframerate()
|
97 |
duration = frames / float(rate)
|
98 |
return round(duration, 3)
|
99 |
|
100 |
-
def
|
101 |
resp = requests.get(zip_url)
|
102 |
with zipfile.ZipFile(io.BytesIO(resp.content)) as zip_file:
|
103 |
with zip_file.open(wav_file_path) as file:
|
104 |
file_data = file.read()
|
105 |
-
return self.
|
106 |
|
107 |
def _split_generators(self, dl_manager):
|
108 |
data_files = dl_manager.download_and_extract(_URLS)
|
@@ -146,5 +145,5 @@ class piano_sound_quality(datasets.GeneratorBasedBuilder):
|
|
146 |
"audio": path,
|
147 |
"label": os.path.basename(os.path.dirname(path)),
|
148 |
"pitch": _PITCHES[file_name[1:4]],
|
149 |
-
"duration": self.
|
150 |
}
|
|
|
8 |
from datasets.tasks import AudioClassification
|
9 |
|
10 |
|
11 |
+
# Once upload a new piano brand zip, please register its name here
|
12 |
_NAMES = [
|
13 |
"1_PearlRiver",
|
14 |
"2_YoungChang",
|
|
|
45 |
and collected by George Chou.
|
46 |
"""
|
47 |
|
48 |
+
_URLS = {piano: f"{_HOMEPAGE}/resolve/main/data/{piano}.zip" for piano in _NAMES}
|
|
|
49 |
|
50 |
|
51 |
_PITCHES = {"009": "A2", "010": "A2#/B2b", "011": "B2", "100": "C1", "101": "C1#/D1b", "102": "D1", "103": "D1#/E1b",
|
|
|
89 |
],
|
90 |
)
|
91 |
|
92 |
+
def _get_wav_dur_from_byte(self, file_bytes):
|
93 |
with wave.open(io.BytesIO(file_bytes), 'r') as wav_file:
|
94 |
frames = wav_file.getnframes()
|
95 |
rate = wav_file.getframerate()
|
96 |
duration = frames / float(rate)
|
97 |
return round(duration, 3)
|
98 |
|
99 |
+
def _get_wav_dur_in_zip(self, zip_url, wav_file_path):
|
100 |
resp = requests.get(zip_url)
|
101 |
with zipfile.ZipFile(io.BytesIO(resp.content)) as zip_file:
|
102 |
with zip_file.open(wav_file_path) as file:
|
103 |
file_data = file.read()
|
104 |
+
return self._get_wav_dur_from_byte(file_data)
|
105 |
|
106 |
def _split_generators(self, dl_manager):
|
107 |
data_files = dl_manager.download_and_extract(_URLS)
|
|
|
145 |
"audio": path,
|
146 |
"label": os.path.basename(os.path.dirname(path)),
|
147 |
"pitch": _PITCHES[file_name[1:4]],
|
148 |
+
"duration": self._get_wav_dur_in_zip(path.split('::')[1], path.split('::')[0].split('//')[1]),
|
149 |
}
|