对音频信号的处理可以通过 librosa.ifgram 方法获取 stft 短时傅立叶变换的矩阵,对该矩阵进行修改搬移,再进行 istft 逆转换获得处理后的音频信号。
y, sr = librosa.load(path)
frequencies, D = librosa.ifgram(y, sr=sr)
'''
中间对D进行处理就行了
'''
y = librosa.istft(D)
D为stft变换的矩阵,x 轴为时间序列,y轴为频率序列坐标对应frequencies,值为幅度。
由于D类型为numpy.ndarray,所以我们很方便就可以通过numpy库对矩阵处理。
- 回音
D = np.repeat(D, 2, axis=1) - 间断
D[:,::2] = 0 - 音色
D = np.roll(D, 50, axis=0) - 压缩频率
def _pool(D, poolsize): x = D.shape[1] // poolsize restsize = D.shape[1] % poolsize if restsize > 0: x += 1 rightlist = np.zeros([ D.shape[0], poolsize-restsize]) D = np.c_[D, rightlist] D = D.reshape( (-1, poolsize) ) D = D.sum(axis=1).reshape(-1,x) return D def rewardshape(D, shape):

&spm=1001.2101.3001.5002&articleId=90289789&d=1&t=3&u=0d616790fe4a47b2aa686c51b02c1ad6)
9843

被折叠的 条评论
为什么被折叠?



