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

Fix vad to return zero output for zero input #3685

Merged
merged 2 commits into from
Nov 9, 2023

Conversation

wasd96040501
Copy link
Contributor

fix #3668
Return empty result when not has_triggered.
Zeroed wav audio added to unit test.

@wasd96040501 wasd96040501 requested a review from a team as a code owner October 28, 2023 09:48
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 28, 2023

@facebook-github-bot
Copy link
Contributor

Hi @wasd96040501!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link
Collaborator

@mthrok mthrok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi

Thanks for the PR. (and sorry for not responding to the original issue)

I have a few comments;

  1. Please run pre-commit run -a to match the style of torchaudio.
  2. We prefer not to add test assets, especially for cases where it's easy to create a synthetic one. Can you replace the zero assets with torch.zeros?
  3. For zero audio, instead of performing sox compatibility check, I think we can directly check the correctness of the output value. Can we try that?
  4. Can we replace these assets with synthetic data that are created on the fly?
    We would like to remove these assets, thus

@wasd96040501
Copy link
Contributor Author

Hi @mthrok , I have implemented the changes, please take a look😊

Copy link
Collaborator

@mthrok mthrok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks. Will merge if tests pass.

@wasd96040501
Copy link
Contributor Author

wasd96040501 commented Nov 7, 2023

Hi, @mthrok It seems build conda failed. What can I do to fix this?

@mthrok mthrok changed the title fix: F.vad returned is not correct when input is zeroed audio Fix vad to return zero output for zero input Nov 8, 2023
The newly added tests no longer require `sox` CLI, thus it is better
located at transforms_test.
@mthrok mthrok enabled auto-merge (squash) November 8, 2023 15:03
@mthrok
Copy link
Collaborator

mthrok commented Nov 8, 2023

Hi, @mthrok It seems build conda failed. What can I do to fix this?

@wasd96040501 This PR has nothing to do with build, and build jobs often fail for external reasons, so we don't need to worry about it.

FYI: I edited the test you added a bit.

@mthrok mthrok merged commit df2a6bc into pytorch:main Nov 9, 2023
@trangham283
Copy link

trangham283 commented Mar 8, 2024

Hi, I think the current way to handle not has_triggered is wrong. It returns an empty tensor even if all the samples are non-zero. Here is a similar reproducible example to the one in #3668:

import torch
import torchaudio.functional as F
x = 10*torch.ones([16000])
y = F.vad(x, 16000)
print(f"input_size={x.size()}, ysize={y.size()}")

output:
input_size=torch.Size([16000]), ysize=torch.Size([0])

I realize this is not the best example, as there is no speech in that array of all ones. Here is a sample that didn't trigger the flag even though there is speech in it, which led me to discover this.

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

Successfully merging this pull request may close these issues.

F.vad on zero valued tensor returns nonempty tensor unexpectly.
4 participants