-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis.py
108 lines (90 loc) · 4.42 KB
/
analysis.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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from librosa import load, power_to_db
from librosa.feature import melspectrogram
from librosa.display import specshow
import os
import matplotlib.pyplot as plt
import numpy as np
from get_features import data_dir
y, sr = load('/media/ycy/86A4D88BA4D87F5D/DataSet/SPEECH DATA/MALE/MIC/M01/mic_M01_sa1.wav', sr=None, offset=2.5, duration=3)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.figure(figsize=(12, 4.5))
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('Normal speech signal')
plt.show()
# example of vocal fry spectrogram
y, sr = load(os.path.join(data_dir, 'TA_SF_43_Vox18-01.wav'), sr=None, offset=3.2, duration=2.4)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.figure(figsize=(12, 9))
plt.subplot(2, 1, 1)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('Vocal Fry, TA_SF_43_Vox18-01, 3.2~5.6s')
y, sr = load(os.path.join(data_dir, 'T_HA_20_LeadVoxHi-05.wav'), sr=None)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.subplot(2, 1, 2)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('False Chord, T_HA_20_LeadVoxHi-05')
plt.tight_layout()
plt.show()
y, sr = load(os.path.join(data_dir, 'DR_POM_28_LeadVox1-12.wav'), sr=None, offset=2.6, duration=3.2)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.figure(figsize=(12, 9))
plt.subplot(2, 1, 1)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('Vocal Fry, DR_POM_28_LeadVox1-12, 2.6~5.8s')
y, sr = load(os.path.join(data_dir, 'T_HA_21_LeadVoxLo-01.wav'), sr=None)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.subplot(2, 1, 2)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('False Chord, T_HA_21_LeadVoxLo-01')
plt.tight_layout()
plt.show()
y, sr = load(os.path.join(data_dir, 'CAT_B_40_LeadVox-06.wav'), sr=None)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.figure(figsize=(12, 9))
plt.subplot(2, 1, 1)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('Vocal Fry Dominated, CAT_B_40_LeadVox-06')
y, sr = load(os.path.join(data_dir, 'CAT_B_42_BackingVox1-06.wav'), sr=None)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.subplot(2, 1, 2)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('False Chord Dominated, CAT_B_42_BackingVox1-06')
plt.tight_layout()
plt.show()
y, sr = load(os.path.join(data_dir, 'SOP_OIAHF_27_LeadVox1-04.wav'), sr=None)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.figure(figsize=(12, 9))
plt.subplot(2, 1, 1)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('Vocal Fry Dominated, SOP_OIAHF_27_LeadVox1-04')
y, sr = load(os.path.join(data_dir, 'HG_LB_15_LeadVox1-01.wav'), sr=None)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.subplot(2, 1, 2)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('False Chord Dominated, HG_LB_15_LeadVox1-01')
plt.tight_layout()
plt.show()
y, sr = load(os.path.join(data_dir, 'LL_WWIH_30_LeadVox2-17.wav'), sr=None)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.figure(figsize=(12, 9))
plt.subplot(2, 1, 1)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('Low Pitch False Chord Dominated, LL_WWIH_30_LeadVox2-17')
y, sr = load(os.path.join(data_dir, 'LL_WWIH_30_LeadVox2-12.wav'), sr=None)
spec = melspectrogram(y=y, sr=sr, n_fft=4096, hop_length=256, n_mels=256)
plt.subplot(2, 1, 2)
specshow(power_to_db(spec, ref=np.max), sr=sr, hop_length=256, y_axis='mel', x_axis='time')
plt.colorbar(format='%+2.0f dB')
plt.title('High Pitch False Chord Dominated, LL_WWIH_30_LeadVox2-12')
plt.tight_layout()
plt.show()