try: #don't want user warnings while True: data, fs = record() out = reduce_noise(data, noise) ns = fil.bandpass_filter(data, bandpass) try: p, freq, b = hmn.psddetectionresults(data) except IndexError: pass b = False b = True if b: # fs = 44100#force 44100 sample rate to prediction why? #mfcc, chroma, mel, spect, tonnetz = fex.extract_feature(data,fs)#ns changed to raw data mfcc, chroma, mel, spect, tonnetz = fex.extract_feature(ns, fs) #a,e,k = lpg.lpc(ns,10) mfcc_test = par.get_parsed_mfccdata(mfcc, chroma, mel, spect, tonnetz) #lpc_test = par.get_parsed_lpcdata(a,k,freq) if test: x1 = random.randint(0, 3) x1 = xx[i] else: x1 = clf.predict(mfcc_test) #x02 = clm.predict(mfcc_test) #x1 = ((x01[0]+x01[0])/2) #x2 = clf1.predict(lpc_test) print("Drone at %s, %s" % (dist_prediction_label(int(x1)), x1)) log.insertdf(int(x1), str(datetime.datetime.now())[:-7])
try: #don't want useless user warnings while True: data, fs = record() #out = reduce_noise(data,noise) #ns = fil.bandpass_filter(data,bandpass) try: p, freq, b = hmn.psddetectionresults(data) except IndexError: pass b = False b = True if b: fs = 44100 #force 44100 sample rate to prediction #mfcc, chroma, mel, spect, tonnetz = fex.extract_feature(ns,fs)#ns changed to raw data mfcc, chroma, mel, spect, tonnetz = fex.extract_feature( data, fs) #ns changed to raw data #a,e,k = lpg.lpc(ns,10) mfcc_test = par.get_parsed_mfccdata(mfcc, chroma, mel, spect, tonnetz) #lpc_test = par.get_parsed_lpcdata(a,k,freq) x1 = clf.predict(mfcc_test) #x02 = clm.predict(mfcc_test) #x1 = ((x01[0]+x01[0])/2) #x2 = clf1.predict(lpc_test) print("Drone at %s" % dist_prediction_label(int(x1))) log.insertdf(int(x1), str(datetime.datetime.now())[:-7]) print(x1) output = log.get_result() '''-----------uncomment if you want to save logs-----------------''' #log.logdf(sys.argv[1],x01[0],x02[0],str(datetime.datetime.now())[:-7]) '''---------------------------------------------------------------'''
bandpass = [600,10000]#filter unwanted frequencies prev_time= tm.time()#initiate time reccount = 0 recdata = np.array([],dtype="float32") basename = "drone" labels=[] """save server recodings in assets folder""" for root, dirs, files in os.walk("assets"): for file in files: if file.endswith(".wav"): data, fs = librosa.load(os.path.join(root, file)) tests = np.split(data, 10) for test in tests: fs = 44100 ns = fil.bandpass_filter(test,bandpass) mfcc, chroma, mel, spect, tonnetz = fex.extract_feature(ns,fs) mfcc1, chroma1, mel1, spect1, tonnetz1 = fex.extract_feature(test,fs) #a,e,k = lpg.lpc(ns,10) mfcc_test = par.get_parsed_mfccdata(mfcc, chroma,mel,spect,tonnetz) mfcc_test1 = par.get_parsed_mfccdata(mfcc1, chroma1,mel1,spect1,tonnetz1) #lpc_test = par.get_parsed_lpcdata(a,k,freq) x1 = clf.predict(mfcc_test) x11 = clf.predict(mfcc_test1) label = dist_prediction_label(int(x1)) label1 = dist_prediction_label(int(x11)) labels.append([i,file,label,label1]) i+=1 import pandas as pd df = pd.DataFrame(labels) df.columns=['idx','filename','labelwithfilter','labelwithrawdata']