Adi*_*mar 13 python audio ffmpeg python-3.x librosa
我在 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)
Run Code Online (Sandbox Code Playgroud)
小智 11
你可以用这个代替
import soundfile as sf
sf.write('stereo_file1.wav', reduced_noise, 48000, 'PCM_24')
Run Code Online (Sandbox Code Playgroud)
在此处查看更多信息https://pysoundfile.readthedocs.io/en/0.8.1/#soundfile.write
librosa.output在 librosa 版本 0.8.0 中被删除。这记录在他们的变更日志中。因此,您的问题最可能的原因是您使用的是这个新版本的 librosa(而不是 0.6.x 版)。您可以通过执行验证print(librosa.__version__)。
使用现代 librosa,您应该使用soundfile.write来写入音频输出。