AttributeError: module 'librosa' has no attribute 'output'错误解决
librosa 0.8.0 版本将output的api屏蔽掉了,新的写出音频方法
PySoundFile提供可直接与numpy数组音频缓冲区一起使用的输出功能:
import numpy as np
import soundfile as sf
rate = 44100
data = np.random.uniform(-1, 1, size=(rate * 10, 2))
# Write out audio as 24bit PCM WAV
sf.write('stereo_file.wav', data, samplerate, subtype='PCM_24')
# Write out audio as 24bit Flac
sf.write('stereo_file.flac', data, samplerate, format='flac', subtype='PCM_24')
# Write out audio as 16bit OGG
sf.write('stereo_file.ogg', data, samplerate, format='ogg', subtype='vorbis')
列如,写出24位的WAV音频
sf.write('stereo_file.wav', data, samplerate=24000, subtype='PCM_24')