[英]How does tf.audio.decode_wav get its contents?
I'm trying to pull some audio files into Tensorflow by using tf.audio.decode_wav
.我正在尝试使用 tf.audio.decode_wav 将一些音频文件拉入tf.audio.decode_wav
。
I can see someone is looking into providing more info in the docs, but does anyone have any examples of how this should work?我可以看到有人正在考虑在文档中提供更多信息,但是有没有人有任何关于这应该如何工作的例子?
tf.audio.decode_wav(
contents,
desired_channels=-1,
desired_samples=-1,
name=None
)
Args:参数:
I'm guessing the contents is a tensor which has already been pulled from a file rather than a path?我猜内容是已经从文件而不是路径中提取的张量?
You're right, tf.audio.decode_wav()
requires a tensor.你是对的, tf.audio.decode_wav()
需要一个张量。 You can provide one with tf.io.read_file()
which reads wav file into tensor of type string.您可以提供一个tf.io.read_file()
,它将 wav 文件读入字符串类型的张量。
raw_audio = tf.io.read_file(filename)
waveform = tf.audio.decode_wav(raw_audio)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.