Datasets:
mb23
/

Languages:
English
License:
mickylan2367 commited on
Commit
ddc4c97
·
1 Parent(s): b5bde36

Update README

Browse files
Files changed (1) hide show
  1. README.md +37 -0
README.md CHANGED
@@ -1,3 +1,40 @@
1
  ---
2
  license: cc-by-sa-4.0
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-sa-4.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - music
7
+ - spectrogram
8
+ size_categories:
9
+ - n<1K
10
  ---
11
+
12
+ ## Google/MusicCapsをスペクトログラムにしたデータ。
13
+
14
+ ### データ作った方法
15
+ ```python
16
+ from PIL import Image
17
+ import IPython.display
18
+ import cv2
19
+
20
+ # 1. wavファイルを解析
21
+ y, sr = librosa.load("wavファイルなど")
22
+
23
+ # 2. フーリエ変換を適用して周波数成分を取得
24
+ D = librosa.amplitude_to_db(np.abs(librosa.stft(y)), ref=np.max) # librosaを用いてデータを作る
25
+ image = Image.fromarray(np.uint8(D), mode='L') # 'L'は1チャンネルのグレースケールモードを指定します
26
+ image.save('spectrogram_{}.png')
27
+ ```
28
+
29
+ ### ♪復元方法
30
+ ```python
31
+ im = Image.open("pngファイル")
32
+ db_ud = np.uint8(np.array(im))
33
+ amp = librosa.db_to_amplitude(db_ud)
34
+ print(amp.shape)
35
+ # (1025, 861)は20秒のwavファイルをスペクトログラムにした場合
36
+ # (1025, 241)は5秒のwavファイルをスペクトログラムにした場合
37
+
38
+ y_inv = librosa.griffinlim(amp*200)
39
+ display(IPython.display.Audio(y_inv, rate=sr))
40
+ ```