我已经在TensorFlow中看到了像tf.image.decode_png这样的图像解码器,但是如何读取音频文件(WAV,Ogg,MP3等)呢?没有TFRecord是否可能?

例如。像this这样的东西:

filename_queue = tf.train.string_input_producer(['my-audio.ogg'])
reader = tf.WholeFileReader()
key, value = reader.read(filename_queue)
my_audio = tf.audio.decode_ogg(value)

最佳答案

是的,软件包tensorflow.contrib.ffmpeg中有特殊的解码器。要使用它,您需要先安装ffmpeg

例子:

audio_binary = tf.read_file('song.mp3')
waveform = tf.contrib.ffmpeg.decode_audio(audio_binary, file_format='mp3', samples_per_second=44100, channel_count=2)

关于tensorflow - 如何在TensorFlow图中读取Ogg或MP3音频文件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41109652/

10-12 00:18
查看更多