【发布时间】:2021-07-22 15:21:17
【问题描述】:
我有一组想要生成频谱图的 wav 文件。但是当我使用 tf.audio.decode_wav 函数时,我得到以下错误:
InvalidArgumentError:WAV 的音频格式错误:预期为 1 (PCM),但 got7 [Op:DecodeWav]
如何规避此错误?还有其他方法可以使用 tensorflow 为 wav 文件生成 log mel 频谱图吗?
我知道 librosa 包,但我更喜欢 tensorflow。
代码是:
def decode_audio(audio_binary):
audio, _ = tf.audio.decode_wav(audio_binary)
return tf.squeeze(audio, axis=-1)
def get_waveform_and_label(file_path):
audio_binary = tf.io.read_file(file_path)
waveform = decode_audio(audio_binary)
return waveform
【问题讨论】:
-
请提供代码
-
您可以上传错误的文件吗?
-
编辑了问题
-
这能回答你的问题吗? read `wav` file with `tf.audio.decode_wav`
标签: tensorflow wav librosa audio-processing