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

speech-command playRawAudio plays blank audio #4736

Closed
adotnusiyan opened this issue Feb 24, 2021 · 8 comments
Closed

speech-command playRawAudio plays blank audio #4736

adotnusiyan opened this issue Feb 24, 2021 · 8 comments
Assignees
Labels
comp:models type:bug Something isn't working

Comments

@adotnusiyan
Copy link

adotnusiyan commented Feb 24, 2021

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): No
  • OS Platform and Distribution: Windows10
  • TensorFlow.js installed from: npm
  • TensorFlow.js version: 3.2.0
  • speech-command version: 0.5.2
  • Browser version: Version 88.0.4324.192 (Official Build) (x86_64)

Describe the current behavior
I'm trying to use playRawAudio method by providing RawAudioData object. Float32Array as data and sampleRateHz:44100.

There's an audio playing with the same duration of data, but the audio is blank (no audio)

I provided Float32Array array from SpeechCommandRecognizerResult.spectrogram.data in listen function, then concatenated the array using concatenateFloat32Arrays util function

Describe the expected behavior
Expected to play the correct audio, not a blank audio.

Standalone code to reproduce the issue
Example in Codesandbox

@adotnusiyan adotnusiyan added the type:bug Something isn't working label Feb 24, 2021
@zipweight
Copy link

@adotnusiyan
did you find a solution?
i also need this and got same issue

@adotnusiyan
Copy link
Author

Not yet.
Hopefully waiting @lina128

@lina128
Copy link
Collaborator

lina128 commented Mar 17, 2021

Hi @adotnusiyan and @zipweight , I'm investigating this, I'm seeing a sampleRate mismatch error in my browser, not sure if it is related, just fyi: tensorflow/tfjs-models#612

@lina128
Copy link
Collaborator

lina128 commented Mar 18, 2021

Hi @adotnusiyan, I looked at the code you provided, it seems you provide the spectrum data to the playRawAudio function. You need to provide raw audio sound, not the spectrum data.

@adotnusiyan
Copy link
Author

@lina128

How to play the spectrum data as audio?

Or how can I get raw audio data from listen function?

Thanks

@lina128
Copy link
Collaborator

lina128 commented Mar 18, 2021

If you have a transferRecognizer with collectExample({includeRawAudio = true}). And then get the rawAudio from tranferRecognizer.getExamples()[0].example.rawAudio.

If you just want a generic solution, you need to implement your own.

@lina128 lina128 closed this as completed Mar 22, 2021
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@adotnusiyan
Copy link
Author

@lina128 I tried your suggestion with basic code from the example in README and the audio doesn't sound right. You can hear some distortion/glitching in the audio

You can try it yourself in this example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:models type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants