question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug(?) when batching wav files that are too short

See original GitHub issue

Hello,

I’m running into issues when using upstream models on audio files that are too short. The model I’m using is audio_albert and the process is killed when the batch includes short waveforms but is processed ok individually.

For example, for a batch with wav with lengths [torch.Size([98399]), torch.Size([311360]), torch.Size([70561]), torch.Size([16801]), torch.Size([5280]), torch.Size([30240]), torch.Size([15040]), torch.Size([1280])], the program is killed without further error messages when I run model(wavs), but I am able to run model(wavs[0]), model(wavs[7]) etc without issue.

I think at least a more informative error message or some sort of warning when input waveforms are too short would help.

Thanks for doing all this, great codebase!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
andi611commented, Feb 22, 2021

Hi!

Sure, here it is:

import torch
import random
random.seed(0)

model = torch.hub.load("s3prl/s3prl", "audio_albert")
lengths = [3898720, 98399, 311360, 70561, 16801, 5280, 30240, 15040, 1280]
wavs = []

for i in lengths:
    wavs.append(torch.rand(i))

for wav in wavs:
    f = model([wav])
    print(f[0].shape)

feats = model(wavs)
print([x.shape for x in feats])

Hi,

I think the problem is you are doing this on CPU instead of GPU. You can simply add .to('cuda') after model and every input to load them to your GPU. An example of doing extraction on GPU is given here. Let us know if you still encounter this problem after moving to GPU, thanks!

Andy

0reactions
trangham283commented, Feb 22, 2021

Hi @andi611

Moving everything on GPU resulted in a more informative error message (OOM). So the issue with the process being “killed” seems to be that CPU doesn’t have enough memory either, but doesn’t give an informative error message?

Thanks for looking into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] Spleeter adding small padding to output audio files #437
During the entire experiment, I've used only lossless(wav) files to avoid issues with padding that some lossy files would cause.
Read more >
Batch combine two files in Unix - Super User
Does anyone know how to batch prepend one audio file to another audio file and create a separate output for each. E.g.. Files:...
Read more >
Python script to batch-rename .WAV files in a directory, based ...
Unindent os.rename() (and replace it with os.replace() in case some other program has opened the file). – jfs.
Read more >
warbleR: Import sound files and select signals
To convert mp3 to wav, we can use the warbleR function mp32wav , which relies on a underlying function from the tuneR package....
Read more >
sox [global-options] [format-options] infile1
translates an audio file in Sun AU format to a Microsoft WAV file, whilst ... For all files, SoX will exit with an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found