-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualise.py
31 lines (25 loc) · 882 Bytes
/
visualise.py
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
import librosa
import numpy as np
import IPython.display as ipd
import matplotlib.pyplot as plt
import librosa.display
filename = 'CSIT_DS_Mini-Challenge\Task_2\T2_audio_b.wav'
y, sr = librosa.load(filename, sr=11025)
fig, ax = plt.subplots(nrows=3, sharex=True)
X = librosa.stft(y)
Xdb = librosa.amplitude_to_db(abs(X))
mfccs = librosa.feature.mfcc(y=y, sr=sr)
librosa.display.specshow(Xdb, sr=sr, x_axis='time', y_axis='hz')
plt.figure(figsize=(12, 5))
librosa.display.waveshow(y, sr=sr, ax=ax[1], color="blue")
ipd.Audio(y, rate=sr)
ax[0].set(title='Envelope view, mono')
ax[0].label_outer()
n0 = 7000
n1 = 7025
plt.figure(figsize=(14, 5))
plt.plot(y[n0:n1])
#chroma features
chromagram = librosa.feature.chroma_stft(y, sr=sr, hop_length=512)
plt.figure(figsize=(15, 5))
librosa.display.specshow(chromagram, x_axis='time', y_axis='chroma', hop_length=512, cmap='coolwarm')