wit-ai / wit

Natural Language Interface for apps and devices
https://wit.ai/
933 stars 91 forks source link

400: bad-request error when making requests to two bots at once #1196

Closed BenBergman closed 5 years ago

BenBergman commented 6 years ago

Do you want to request a feature, report a bug, or ask a question about wit? Report a bug, I think.

What is the current behavior? When I try to stream audio to the speech API using two Wit bots at once, most of the time one of the connections returns with a 400 "bad-request" error code.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Currently my code base is a bit messy but I can pull out the relevant section of code in a couple of days for external reproduction. The basic setup though is using node-record-lpcm16 to pipe and audio stream into two Wit.ai speech stream requests at the same time, each using a different API token. I am using node-witai-speech for creating the streams, but it is just a very thin wrapper around the requests library.

What is the expected behavior? I'm attempting to make a bilingual bot. In order to make the language selection process simpler I am attempting to stream my first interaction to both my English bot and my French bot and based on the confidence scores select the most likely language. When I run against only one bot at a time it works great. However, when I split my audio stream so that it is being piped into the English bot and the French bot I start seeing strange errors. Often one of the connections to Wit.ai will bounce back with a 400 “bad request” error code.

My application also has a text mode and that works fine making concurrent requests, but it is not sharing an input stream. I have split my audio stream to pipe to multiple files and those files come out sharing the same md5, so I think I'm using stream splitting correctly too.

What is the App ID where you are experiencing this issue (if applicable)? English app ID: 2085134588165849 French app ID: 2397194446972503

patapizza commented 5 years ago

Hi @BenBergman, 400s (bad requests) are usually client-side errors. We don't have enough bandwidth to prioritize client-side support. Maybe you can share the code so other developers can help too?

BenBergman commented 5 years ago

@patapizza I've done some further testing and I'm able to fully reproduce the issue by streaming content to just a single French Wit app at a time. For repeatable testing I have recorded some audio clips to stream in as input. My code and sample audio clips are here: https://github.com/BenBergman/wit-ai-french-error-demo

To reproduce, clone the repository and run npm install && node .

It seems like when you stream a word that it can't decipher in French it will respond with 400: bad-request. The default setup for that demo is to stream an audio clip speaking "hello" into a French Wit.ai bot. This always returns a 400 error. You will see in the source of the demo that I have commented out a French file and an English Wit.ai app to test alternate arrangements. Using the audio clip of "bonjour" always works just fine with the French Wit.ai app. The "hello" clip always works just fine with the English Wit.ai app.

Based on this, I believe that the 400 error is being caused by something on the back end.

patapizza commented 5 years ago

Thanks for the details and your patience @BenBergman! Fix upcoming.

BenBergman commented 5 years ago

That is great news! Does that mean you were able to find the issue? Or at least replicate it on your end?

patapizza commented 5 years ago

This should now be fixed.

BenBergman commented 5 years ago

Yay! Thanks for the quick fix!