Need help upgrading Websocket #99
-
Okay so I'm not sure if the issue I'm seeing is due to an error in the audio conversion or if I made a mistake in the request url, but I'm getting an HTTP/1.1 400 Bad request file sent back from the Websocket instead of JSON. I initially took the microphone input as PCM and converted it to NSData but that gave me a 1011 error, so now I'm converting to wav instead and still getting an error. It will successfully connect but then receive a bad request. Have tried a lot of different urls in the header. I've looked everywhere but can't find many Deepgram discussions in Swift. Any help is seriously appreciated. Here are my recording and conversion functions:
This is how I'm connecting to the Websocket:
And this is how I'm sending the data to the Websocket:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @UgoEkwe!
I take this to mean the connection never makes the upgrade to websockets? Two things to check are:
I hope that gives us some direction here! I will also point out that if streaming containerized audio, the header should only be sent once at the beginning of the stream, rather than effectively creating a new WAV file each time (I can't quite tell if your code is doing that, but just in case!). Ideally one of the suggestions above will work out and you can stream the raw data as you originally intended! |
Beta Was this translation helpful? Give feedback.
Hi @UgoEkwe!
I am pretty unfamiliar with Swift, but I do want to check on a couple of things:
I take this to mean the connection never makes the upgrade to websockets? Two things to check are:
options.setAdditionalHeaders([("Authorization", apiKey)])
Perhaps Swift does something I don't know about, but we do require the header to be"Authorization: Token $apiKey"
(the word "Token" must appear as well).url
path looks good, but I don't see where the full URL with the path is passed in? In the connection code there ishost: NWEndpoint.Host(url.host!)
, but …