-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
base: master
Are you sure you want to change the base?
Update audio_spec.py #339
Conversation
Fix the potential "nan" problem of the precrocess_model in BrowserFftSpec
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 What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already fixed this problem.
2d684f6
to
5d039b7
Compare
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.
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.