AttributeError:模块“librosa”没有属性“output”

2024-10-04 03:28:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我在anaconda中使用librosa 0.6,并且我也安装了ffmpeg,但是我仍然收到这个错误

代码是

a = np.exp(spectrum) - 1
    p = 2 * np.pi * np.random.random_sample(spectrum.shape) - np.pi
    for i in range(50):
        S = a * np.exp(1j * p)
        x = librosa.istft(S)
        p = np.angle(librosa.stft(x, N_FFT))
    librosa.output.write_wav(outfile, x, sr)


Tags: sample代码infor错误nppirange
2条回答

librosa.output在librosa版本0.8.0中被删除。这记录在their changelog中。 所以您的问题最可能的原因是您正在使用这个新版本的librosa(而不是版本0.6.x)。您可以通过执行print(librosa.__version__)进行验证

对于ModenLibrosa,您应该使用soundfile.write来编写音频输出

你可以用这个来代替

import soundfile as sf
sf.write('stereo_file1.wav', reduced_noise, 48000, 'PCM_24')

请在此处查看更多https://pysoundfile.readthedocs.io/en/0.8.1/#soundfile.write

相关问题 更多 >