-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vibration.py
70 lines (50 loc) · 1.55 KB
/
Vibration.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 11 22:40:16 2019
@author: Yazid, Kein, Sari
"""
#https://stackoverflow.com/questions/20023131/cannot-install-pyaudio-gcc-error
#https://www.instructables.com/id/ESP32-With-ESP-Now-Protocol/
#use i2C ESP32
from scipy.io import wavfile
from matplotlib import pyplot as plt
import numpy as np
import test
from fuzzywuzzy import fuzz
import acoustid
import chromaprint
def plot_wav(filename):
rate,data = wavfile.read(filename)
times = np.arange(len(data))/float(rate)
# You can tweak the figsize (width, height) in inches
plt.figure(figsize=(30, 4))
plt.fill_between(times, data[:,0], data[:,1], color='k')
plt.xlim(times[0], times[-1])
plt.xlabel('time (s)')
plt.ylabel('amplitude')
# You can set the format by changing the extension
# like .pdf, .svg, .eps
plt.savefig(filename+'.png', dpi=100)
plt.show()
def FingerPrintAudio(filename):
duration, fp_encoded = acoustid.fingerprint_file(filename)
fingerprint, version = chromaprint.decode_fingerprint(fp_encoded)
#print(fingerprint)
return fingerprint
def Correlation():
i=1
def AudioSimilarity(sample_fingerprint, fingerprint):
similarity = fuzz.ratio(sample_fingerprint, fingerprint)
#print(similarity)
return similarity
FP1 = FingerPrintAudio("yazi1.wav")
FP2 = FingerPrintAudio("yazi2.wav")
simlarity = AudioSimilarity(FP1, FP2)
if simlarity >= 95:
test
print ('Doore Opening')
else:
print ('Fuck off')
#plot_wav("yazi1.wav")
#plot_wav("yazi2.wav")