Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio object is shorter than requested duration error could point to the particular sample causing the error #979

Open
Mgallimore88 opened this issue Apr 22, 2024 · 1 comment

Comments

@Mgallimore88
Copy link

Mgallimore88 commented Apr 22, 2024

Hello,
Thanks for the great work you're doing.

I'm encountering an issue when training models using opensoundscape: occasionally there will be a file in one of my datasets which causes the following error:

UserWarning: Audio object is shorter than requested duration: 2.8619727891156463 sec instead of 3.0 sec.

When these errors are present, the model doesn't learn at all during training, and progress stalls at chance rates. When I remove the files which generate the short audio objects, the model is able to improve during training.

My current workaround has been to edit the source code in the from_file() function of audio.py like so:

error_msg = ( f"Audio object is shorter than requested duration: " f"{len(samples)/sr} sec instead of {duration} sec. Path: {path}, start_time: {offset} sec, end_time {offset + duration} sec." )

This lets me find the audio clip which is causing the error and remove it from my dataset.

If this is an acceptable workaround, I can make a pull request with this change, but I'd like to check whether there's an existing way to deal with this?

Thanks,

Michael.

@sammlapp
Copy link
Collaborator

Hi @Mgallimore88 ,
it's surprising that some short audio samples would cause training progress to stall. Are you confident that there aren't any other differences in your training script that could cause the lack of learning? If so, we should examine why this happens on our end.

As for a workaround, I would recommend one of the following:

  • extend short clips to the expected duration:
m.preprocessor.insert_action(
            action_index="extend",
            action=Action(
                Audio.extend_to, is_augmentation=False, duration=self.sample_duration
            ),
            after_key='load_audio'
        )
  • ignore and suppress the warning by setting Audio.from_file's argument out_of_bounds_mode='ignore'. For instance: m.preprocessor.pipeline.load_audio.set(out_of_bounds_mode='ignore')
  • raise an error for shorter clips, causing them to be skipped during training (training will continue, just skipping these clips). For instance, m.preprocessor.pipeline.load_audio.set(out_of_bounds_mode='raise')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants