【问题标题】:AttributeError: module 'librosa' has no attribute 'output'AttributeError:模块“librosa”没有属性“输出”
【发布时间】:2021-01-07 21:14:10
【问题描述】:

我在 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)

【问题讨论】:

    标签: python python-3.x audio ffmpeg librosa


    【解决方案1】:

    你可以改用这个

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

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

    【讨论】:

      【解决方案2】:

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

      对于现代 librosa,您应该改用 soundfile.write 来编写音频输出。

      【讨论】:

        猜你喜欢
        • 2018-04-14
        • 2019-02-18
        • 1970-01-01
        • 2020-01-01
        • 2019-07-20
        • 2021-11-05
        • 2021-11-04
        • 2021-02-23
        相关资源
        最近更新 更多