【发布时间】:2019-12-03 11:17:30
【问题描述】:
我正在尝试从存储桶中的 tar 文件中读取 wav 文件。由于有很多文件,我不想先提取这些文件。
相反,我想从 tar 文件中读取数据并将其流式传输到 wavfile.read(来自 scipy.io)
with tf.gfile.Open(chunk_fp, mode='rb') as f:
with tarfile.open(fileobj=f, mode='r|*') as tar:
for member in ds_text.index.values:
bytes = BytesIO(tar.extractfile(member)) # Obviously not working
rate, wav_data = wavfile.read(bytes)
# Do stuff with data ..
但是,我无法让 wavfile.read 继续工作。
尝试不同的事情会得到不同的错误:
tar.extractfile(member).seek(0)
{AttributeError}'_Stream' object has no attribute 'seekable'
tar.extractfile(member).raw.read()
{StreamError}seeking backwards is not allowed
等等。
有什么想法可以实现这一点吗?
【问题讨论】:
标签: python tensorflow tarfile