def istft_mc(X,hop,dtype=np.float32,nsampl=None,flag_noDiv=0,window=None):
#assumes X is of shape F x nfram x nch, where F=Nwin/2+1
#returns xr of shape nch x nsampl
N=2*(X.shape[0]-1)
nch=X.shape[2]
for ich in range(0,nch):
X0=X[:,:,ich]
if flag_noDiv:
x0r=istft_noDiv(X0,hop_length=hop,center=False,window=window,dtype=dtype)
else:
x0r=librosa.core.istft(X0,hop_length=hop,center=False,window=window,dtype=dtype)
if ich==0:
xr=np.zeros((nch,len(x0r))).astype(dtype)
xr[0,:]=x0r
else:
xr[ich,:]=x0r
#trim off extra zeros
nfram=xr.shape[1]
xr=xr[:,0:(nfram-N)]
nfram=xr.shape[1]
xr=xr[:,N:]
if not nsampl is None:
xr=xr[:,0:nsampl]
return xr, N
评论列表
文章目录