Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fil[i] = ratio
return fil*signal
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
if __name__ == "__main__":
kl = KaraokeFileLoader(WINSIZE*2)
ssignal,ksignal,params = kl.load_file(songfile,karaokefile)
ssignal_l,ssignal_r = separate_channels(ssignal)
ksignal_l,ksignal_r = separate_channels(ksignal)
print "Alignment is done"
window = sp.hanning(WINSIZE)
sig_out_l = subtruction(ssignal_l,ksignal_l,window,WINSIZE)
sig_out_r = subtruction(ssignal_r,ksignal_r,window,WINSIZE)
print "Spectral Subtraction is Done"
sig_out_l[sp.isnan(sig_out_l)+sp.isinf(sig_out_l)]=0.0
sig_out_r[sp.isnan(sig_out_r)+sp.isinf(sig_out_r)]=0.0
#import matplotlib.pyplot as plt