【发布时间】:2021-06-25 11:11:35
【问题描述】:
我正在尝试读取一些音频 wav 文件,但在我添加更多音频文件之前,一切都很完美,但我遇到了错误。使用以下代码读取音频文件并将其重新采样到 16KHz
def speech_file_to_array_fn(batch):
start = 0
stop = 20
srate = 16_000
speech_array, sampling_rate = sf.read(batch["file"], start = start * srate , stop = stop * srate)
batch["speech"] = librosa.resample(np.asarray(speech_array), sampling_rate, srate)
batch["sampling_rate"] = srate
batch["parent"] = batch["label"]
return batch
我收到此错误:
ValueError: Input signal length=2 is too small to resample from 44100->16000
我在阅读后尝试转置音频文件,但没有成功
谢谢
【问题讨论】:
-
python 不是我的语言,但
srate = 16_000似乎很奇怪......下划线在那里做什么? -
我删除了它仍然面临同样的错误
-
数字中的下划线在python中很好,即
16_000 == 16000 >>> True
标签: python python-3.x audio sampling librosa