TENSORFLOW 语音命令:解码 wav 时出现错误(尝试读取字符串时数据太短)

问题描述 投票:0回答:3

谢谢您的帮助。

我正在学习张量流上的教程(语音命令),在我下载代码和数据集后,我运行程序,经过几个步骤的训练,出现错误。

InvalidArgumentError (see above for traceback): Data too short when trying to read string
     [[Node: DecodeWav = DecodeWav[desired_channels=1, desired_samples=16000, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ReadFile)]]
     [[Node: DecodeWav/_21 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_4_DecodeWav", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

解码方法似乎有问题,但我无法找出问题所在。我从 github 下载后没有更改任何代码。 你能帮助我吗。谢谢。

tensorflow speech
3个回答
4
投票

问题解决了。 问题是数据集中的一个语音是空的(0 kb),并且程序使用随机来获取训练数据,如果随机到这个空的训练语音,则会出现问题中的错误。


1
投票

就我而言,我没有任何空文件。讨论底部的功能帮助了我:

https://github.com/mozilla/DeepSpeech/issues/2048

import os
import wave
import pandas
import sys

def compare_header_and_size(wav_filename):
    with wave.open(wav_filename, 'r') as fin:
        header_fsize = (fin.getnframes() * fin.getnchannels() * fin.getsampwidth()) + 44
    file_fsize = os.path.getsize(wav_filename)
    return header_fsize != file_fsize

df = pandas.read_csv(sys.argv[1])
invalid = df.apply(lambda x: compare_header_and_size(x['wav_filename']), axis=1)
print('The following files are corrupted:')
print(df[invalid].values)

在比较所提供的功能中的两种测量方法时,我发现我的音频文件长度不同。

原因是我在将 wav 文件保存在 Adobe Audition 中时向它们添加了元数据。那是一个错误


© www.soinside.com 2019 - 2024. All rights reserved.