In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import librosa
import librosa.display

In [2]:
oggfile = librosa.util.example_audio_file()

In [3]:
oggfile


Out[3]:
'/Users/koichiro.mori/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/librosa/util/example_data/Kevin_MacLeod_-_Vibe_Ace.ogg'

In [18]:
y, sr = librosa.load('../data/AudioData/JE/a01.wav')

In [19]:
plt.plot(y)


Out[19]:
[<matplotlib.lines.Line2D at 0x114ec5e80>]

In [20]:
sr


Out[20]:
22050

In [148]:
S = librosa.feature.melspectrogram(y, sr=22050, n_mels=128, n_fft=512, hop_length=384)
print(S.shape)


(128, 205)

In [150]:
librosa.display.specshow(librosa.power_to_db(S, ref=np.max),
                         y_axis='mel', x_axis='time')


Out[150]:
<matplotlib.axes._subplots.AxesSubplot at 0x12c451eb8>

In [152]:
np.min(S), np.max(S)


Out[152]:
(2.2254288234216282e-12, 476.71658941113083)

In [67]:
from scipy import signal

In [104]:
f, t, Sxx = signal.spectrogram(y, 22050)

In [106]:
plt.pcolormesh(t, f, Sxx)
plt.xlabel('time (s)')
plt.ylabel('frequency [hz]')
plt.show()



In [ ]: