Skip to content

Update audio_spec.py #339

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shaoyijia
Copy link

@shaoyijia shaoyijia commented Aug 3, 2021

The preprocess_model used by BrowserFftSpec will produce "nan" results when the input tensors contain too many zero entries. Such inputs are common because there may be delays in the recording devices resulting in an empty stream at the beginning of the audio file. This PR fixes this potential "nan" problem by adding a small Gaussian noise to the inputs before they go through the preprocess_model.

Fix the potential "nan" problem of the precrocess_model in BrowserFftSpec
@google-ml-butler google-ml-butler bot added size:XS CL Change Size: Extra Small awaiting review labels Aug 3, 2021
@google-cla
Copy link

google-cla bot commented Aug 3, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no CLA has not been signed label Aug 3, 2021
@shaoyijia
Copy link
Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes CLA has been signed and removed cla: no CLA has not been signed labels Aug 3, 2021
@wangtz wangtz self-requested a review August 3, 2021 03:00
wangtz
wangtz previously approved these changes Aug 3, 2021
@@ -283,6 +283,8 @@ def _split(self, wav, label):
])
def _preprocess(self, x, label):
"""Preprocess the dataset to extract the spectrum."""
# Add small Gaussian noise to the input x to solve the potential "nan" problem of the preprocess_model
Copy link
Member

Choose a reason for hiding this comment

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

Please wrap this line. Python code is expected to have a max len = 80.

Copy link
Author

Choose a reason for hiding this comment

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

Already fixed this problem.

@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull labels Aug 3, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Aug 3, 2021
@shaoyijia shaoyijia force-pushed the EchoShao8899-fix-nan-problem branch from 2d684f6 to 5d039b7 Compare August 3, 2021 10:58
The preprocess_model will produce "nan" results when input tensors contain too many zero entries. Such inputs are common because there may be delays in recording devices resulting in an empty stream at the beginning of the audio file. This problem is fixed here by adding small Gaussian noise to the inputs before they go through the preprocess_model.
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull labels Aug 3, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review cla: yes CLA has been signed ready to pull size:XS CL Change Size: Extra Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants