When using torchaudio.load on a 1.79 GB FLAC file, it throws RuntimeError: Trying to create tensor with negative dimension -225262592: [-225262592, 2].
import json
from pathlib import Path
import torchaudio
long_rec = Path("long_rec.flac")
print(long_rec.stat().st_size)
# 1921401859
print(json.dumps(vars(torchaudio.info(long_rec)), indent=2))
# {
# "sample_rate": 96000,
# "num_frames": 1922221056,
# "num_channels": 2,
# "bits_per_sample": 16,
# "encoding": "FLAC"
# }
ta_data, sr = torchaudio.load(long_rec)
# ... ~45s processing
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[52], line 1
----> 1 ta_data, sr = torchaudio.load(long_rec)
File ~/mambaforge/envs/whisper/lib/python3.10/site-packages/torchaudio/backend/sox_io_backend.py:251, in load(filepath, frame_offset, num_frames, normalize, channels_first, format)
241 return _fallback_load_fileobj(
242 filepath,
243 frame_offset,
(...)
248 buffer_size,
249 )
250 filepath = os.fspath(filepath)
--> 251 ret = torch.ops.torchaudio.sox_io_load_audio_file(
252 filepath, frame_offset, num_frames, normalize, channels_first, format
253 )
254 if ret is not None:
255 return ret
File ~/mambaforge/envs/whisper/lib/python3.10/site-packages/torch/_ops.py:502, in OpOverloadPacket.__call__(self, *args, **kwargs)
497 def __call__(self, *args, **kwargs):
498 # overloading __call__ to ensure torch.ops.foo.bar()
499 # is still callable from JIT
500 # We save the function ptr as the `op` attribute on
501 # OpOverloadPacket to access it here.
--> 502 return self._op(*args, **kwargs or {})
RuntimeError: Trying to create tensor with negative dimension -225262592: [-225262592, 2]
However, I am still able to load load the file into a numpy array via librosa and then convert it to a tensor.
🐛 Describe the bug
When using
torchaudio.load
on a 1.79 GB FLAC file, it throwsRuntimeError: Trying to create tensor with negative dimension -225262592: [-225262592, 2]
.However, I am still able to load load the file into a numpy array via librosa and then convert it to a tensor.
Versions