Skip to content

Saving stereo files causes fatal error if re-loading generated file #14

@dhpollack

Description

@dhpollack

Saving stereo files does not properly add the length info to the saved file. Thus you cannot reload these files with torchaudio, although they are playable in most audio programs. Below is a test case.

import torchaudio
sig, sr = torchaudio.load("test/steam-train-whistle-daniel_simon.mp3")
torchaudio.save("test/file.wav", sig, sr)
sig, sr = torchaudio.load("test/file.wav")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dhpollack/repos/audio/torchaudio/__init__.py", line 30, in load
    func(str(filepath).encode("utf-8"), out, sample_rate_p)
  File "/home/dhpollack/miniconda3/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 177, in safe_cal
l
    result = torch._C._safe_call(*args, **kwargs)
torch.FatalError: [read_audio] Unknown length at torchaudio/src/generic/th_sox.c:14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions