-
Notifications
You must be signed in to change notification settings - Fork 75
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
"Invalid 'audio_in': audio frame length is too long" on Raspberry Pi Zero #48
Comments
Update: I just stumbled onto this - the frame length here is the size of the block being sent to google and, as it turns out, 64k bytes is too many. My poor Raspberry Pi Zero is too slow. If I throw out the large chunks it works. I'll poke around with chopping up the requests into bite-sized chunks for google but if it's obvious to anyone how to do that I'm happy to help test on my end. |
I ran into the same issue when I first started working with the audio stuff and noticed they were fussy about the audio not being sent in real time. I'm guessing you're right about the Zero being too slow :( I'll keep this open if you want, but it seems like you may have to do some digging to get it sorted out. |
I'd imagine it could happen if there's any number of things that hitch the thread and that it could happen on any number of devices. I'll fix it up and submit a PR. |
PR here: #51 |
I just experimented to figure out what the correct value for MAX_FRAME_LENGTH should be. I'm not super-familiar with gRPCs so maybe someone knows how to look it up to make sure the value there is indeed the exact right value. 32 * 1024 was too big. |
I made a converter to convert and downsample browser microphone audio to the right format for gRPC, I found that a buffer size of 4096 sample-frames is perfect or good enough. |
I remember reading somewhere that google specifically recommends not altering the raw audio. You raise an interesting point, though. My PR assumes that the error is concerned with the number of bytes sent as audio_in as opposed to the number of frames. It'd be worth testing the change with a higher sampling rate before merging just to be sure that assumption is correct. I'll do that when I get some time. |
@albertreed fyi, I also commented in your PR regarding this issue, I'm not use we should do any processing within the library itself, and if we do we should separate it into another class or (make it optional) than forced on since it might break other applications. |
Looking at the PR, I don't see anything that would break current functionality, but I'm surprised that locking the thread with 2 loops doesn't produce the same problem. I think you're right in that in the other end of Google sees too much data come in it freaks out. I'm going to do a few more tests to see if I can break it with the or not. Fwiw this fix is the same sort of thing a game engine would do to accommodate slower machines for example and it shouldn't bust anything that a fast machine can do. |
If you're testing it I'd suggest throwing some different sampling rates at it. ...and adding proper automated testing is probably a good idea if you're going to be accepting changes from yahoos on the internet like myself. :-) |
have you guys found a solution to this? |
Thanks so much for the great library. I'm running into a problem getting it working on a Raspberry Pi Zero W.
When running the mic-speaker example I'm seeing this error after it runs for a short moment. Nothing else is logged.
(With verbose:true passed into the record call)
The error implies that the recroding rate isn't correct but aside from the threshold:0, my test app records exactly the same way and the file is reported with a correct frame length. I'm assuming google's "audio frame length" is referring to the same value as "Rate" within aplay.
I'm on 0.5.1
The text was updated successfully, but these errors were encountered: