8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png
librosa 0.8.0 写出音频文件
aiyun 2020-9-2

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')
最新回复 (0)
    • Ai云
      2
        立即登录 立即注册
返回