-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.py
More file actions
51 lines (37 loc) · 1.33 KB
/
testing.py
File metadata and controls
51 lines (37 loc) · 1.33 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
import audio
import database as db
import defaults
import fingerprints as fp
import librosa
import matplotlib.pyplot as plot
import matplotlib.mlab as mlab
import numpy as np
import matching
from scipy.ndimage.morphology import generate_binary_structure
from scipy.ndimage.morphology import iterate_structure
'''
audio.mp3_input("/Users/aaronyang/Desktop/BWSI/Week1/mp3s/Rickroll.mp3", "Never Gonna Give You Up", "Rick Astley")
audio.mp3_input("/Users/aaronyang/Desktop/BWSI/Week1/mp3s/CallMeMaybe.mp3", "Call Me Maybe", "Carly Rae Jepsen")
db.saveFingerprints()
db.saveSongIDs()
'''
db.fingerprints = db.loadFingerprints()
db.songID = db.loadSongIDs()
audio.mp3_input("/Users/aaronyang/Desktop/BWSI/Week1/mp3s/CakeByTheOcean.mp3", "Cake by the Ocean", "DNCE")
matching.matching(10)
'''
samples, sampling_rate = librosa.load("/Users/aaronyang/Desktop/BWSI/Week1/mp3s/Rickroll.mp3", sr=44100, mono=True)
print("len(samples): ")
print(len(samples))
print("sampling rate: ")
print(sampling_rate)
spectrogram, cutoff = fp.samples_to_spectogram(samples, sampling_rate)
print("spectrogram shape: ")
print(spectrogram.shape)
print("cutoff: ")
print(cutoff)
base_structure = generate_binary_structure(2,1)
neighborhood = iterate_structure(base_structure, 20)
L_peaks = fp.local_peak_locations(spectrogram, neighborhood, cutoff)
print(L_peaks[:100])
'''