Datasets:
mb23
/

Languages:
English
License:
File size: 1,737 Bytes
bee4911
 
ddc4c97
 
 
 
 
 
 
bee4911
ddc4c97
 
 
5371483
 
fbdac43
5371483
 
 
 
fbdac43
 
 
61dae2a
fbdac43
 
 
 
 
5371483
 
ddc4c97
5371483
 
 
 
ddc4c97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3091cbe
 
ddc4c97
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
license: cc-by-sa-4.0
language:
- en
tags:
- music
- spectrogram
size_categories:
- n<1K
---

## Google/MusicCapsをスペクトログラムにしたデータ。

### データの基本情報
<table>
  <thead>
    <td>画像</td>
    <td>caption</td>
    <td>data_idx</td>
    <td>number</td>
  </thead>
  <tbody>
    <tr>
      <td>1025px × 216px</td>
      <td>音楽の説明</td>
      <td>どのデータから生成されたデータか</td>
      <td>5秒ずつ区切ったデータのうち、何番目か</td>
    </tr>
  </tbody>
</table>

### データ作った方法

* コード:https://colab.research.google.com/drive/13m792FEoXszj72viZuBtusYRUL1z6Cu2?usp=sharing
* 参考にしたKaggle Notebook : https://www.kaggle.com/code/osanseviero/musiccaps-explorer

```python
from PIL import Image
import IPython.display
import cv2

# 1. wavファイルを解析
y, sr = librosa.load("wavファイルなど")

# 2. フーリエ変換を適用して周波数成分を取得
D = librosa.amplitude_to_db(np.abs(librosa.stft(y)), ref=np.max) # librosaを用いてデータを作る
image = Image.fromarray(np.uint8(D), mode='L')  # 'L'は1チャンネルのグレースケールモードを指定します
image.save('spectrogram_{}.png')
```

### ♪復元方法
```python
im = Image.open("pngファイル")
db_ud = np.uint8(np.array(im))
amp = librosa.db_to_amplitude(db_ud)
print(amp.shape)
# (1025, 861)は20秒のwavファイルをスペクトログラムにした場合
# (1025, 431)は10秒のwavファイルをスペクトログラムにした場合
# (1025, 216)は5秒のwavファイルをスペクトログラムにした場合

y_inv = librosa.griffinlim(amp*200)
display(IPython.display.Audio(y_inv, rate=sr))
```