-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvad_features_trial.py
More file actions
executable file
·54 lines (44 loc) · 1.29 KB
/
Copy pathvad_features_trial.py
File metadata and controls
executable file
·54 lines (44 loc) · 1.29 KB
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
#!/usr/bin/env python
from scipy.io import wavfile
import numpy as np
import matplotlib.pyplot as plt
import sys
import scipy.signal as sig
from util import *
if(len(sys.argv) < 2):
print "ARGUMENT ERROR!"
print sys.argv[0] + " [wav_file]"
exit()
sample_rate, data = wavfile.read(sys.argv[1])
sample_duration = 1./sample_rate
duration = float(len(data)) * sample_duration
time_arr = np.arange(0, duration, sample_duration)
print "Duration = " + str(duration)
features = feature_extraction(data, sample_rate, sample_rate*0.05, sample_rate*0.025)
print "features shape = " + str(np.shape(features))
plt.subplot(711)
plt.plot(data)
plt.xlabel('Original Signal')
plt.subplot(712)
plt.plot(features[0,])
plt.xlabel('ZCR')
plt.subplot(713)
plt.plot(features[1,])
plt.xlabel('Energy')
plt.subplot(714)
plt.plot(features[5,])
plt.xlabel('Spectral Entropy')
plt.subplot(715)
#auto correlation of energy and zcr
f_autocorr = sig.correlate(features[0,], features[1,], mode='full')
half_autocorr = f_autocorr[len(f_autocorr)/2:]
plt.plot(f_autocorr)
plt.xlabel('Autocorrelation Full')
plt.subplot(716)
plt.plot(half_autocorr)
plt.xlabel('Autocorrelation half')
#convolution of zcr and energy
f_convolution = sig.convolve(features[0,], features[1,], mode='full')
plt.subplot(717)
plt.plot(f_convolution)
plt.show()