def noise_reduction(signal,params,winsize,window,ss,ntime): out=sp.zeros(len(signal),sp.float32) n_pow = compute_avgpowerspectrum(signal[0:winsize*int(params[2] /float(winsize)/(1000.0/ntime))],winsize,window)#maybe 300ms nf = len(signal)/(winsize/2) - 1 for no in xrange(nf): s = get_frame(signal, winsize, no) add_signal(out, ss.compute_by_noise_pow(s,n_pow), winsize, no) return out
def subtruction(ssignal,ksignal,window,winsize,method): nf = len(ssignal)/(winsize/2) - 1 out=sp.zeros(len(ssignal),sp.float32) for no in xrange(nf): s = get_frame(ssignal, winsize, no) k = get_frame(ksignal, winsize, no) add_signal(out, method.compute(s,k), winsize, no) return out
def noise_reduction(signal, params, winsize, window, ss, ntime): out = sp.zeros(len(signal), sp.float32) # maybe 300ms n_pow = compute_avgpowerspectrum(signal[0:winsize*int(params[2]/float(winsize)/(1000.0/ntime))], winsize, window) nf = int(len(signal)/(winsize/2)) - 1 for no in xrange(nf): s = get_frame(signal, winsize, no) add_signal(out, ss.compute_by_noise_pow(s, n_pow), winsize, no) return out
def vad(vas,signal,winsize,window): out=sp.zeros(len(signal),sp.float32) for va in vas: for i in range(va[0],va[1]): add_signal(out,get_frame(signal, winsize, i)*window,winsize,i) for va in vas: out[(va[0])*winsize/2:(va[0]+4)*winsize/2] = fin(winsize*2,out[(va[0])*winsize/2:(va[0]+4)*winsize/2]) out[(va[1]-4)*winsize/2:(va[1])*winsize/2] = fout(winsize*2,out[(va[1]-4)*winsize/2:(va[1])*winsize/2]) return out
def noise_reduction(signal,params,winsize,window,ss,ntime): out=sp.zeros(len(signal),sp.float32) ms = MinimumStatistics(winsize,window,params[2]) NP_lambda = compute_avgpowerspectrum(signal[0:winsize*int(params[2] /float(winsize)/(1000.0/ntime))],winsize,window)#maybe 300ms ms.init_noise_profile(NP_lambda) nf = int(len(signal)/(winsize/2)) - 1 for no in xrange(nf): frame = get_frame(signal, winsize, no) n_pow = ms.compute(frame,no) if int(params[2] /float(winsize)/3.0)*2>no: n_pow = NP_lambda res = ss.compute_by_noise_pow(frame,n_pow) add_signal(out, res, winsize, no) #ms.show_debug_result() return out
def vad(vas, signal, winsize, window): out = np.zeros(len(signal), np.float32) for va in vas: for i in range(va[0], va[1]+2): add_signal(out, get_frame(signal, winsize, i)*window, winsize, i) return out