deepgram / deepgram-dotnet-sdk

.NET SDK for Deepgram's automated speech recognition APIs.
https://developers.deepgram.com
MIT License
30 stars 31 forks source link

LiveAudio KeepAlive #239

Closed GuerrillaCoder closed 7 months ago

GuerrillaCoder commented 7 months ago

I notice the JS SDK's has KeepAlive implemented but it's not added yet to .net SDK.

I am cutting audio to deepgram while my agent speaks and on longer sentences (I think around 10s) the websocket closes.

I couldn't see in the docs what logic the deepgram API is expecting. If I fork the repo and add a background task to send a message with type="KeepAlive" every 5 seconds would that be a good approach?

Any extra info on your API behaviour would be greatly appreciated.

dvonthenen commented 7 months ago

Hi @GuerrillaCoder

There is a KeepAlive function implemented in the current v3 release which will send the message out for you, but you will need to start a thread to send that message every 5 seconds: https://github.com/deepgram/deepgram-dotnet-sdk/blob/release-v3/Deepgram/Clients/LiveTranscriptionClient.cs#L174

There are plans in the upcoming v4 to go one step further so that when the start()\connect() on the Client are called, the class will automatically start a thread for you provided a flag is set in the configuration.

In the meantime for v3, you can either: 1) extended the LiveClient class then implement the thread function 2) create a thread function that will manage the Client itself

GuerrillaCoder commented 7 months ago

Oh, I was using wrong branch! Many thanks for the quick response.

dvonthenen commented 7 months ago

Oh, I was using wrong branch! Many thanks for the quick response.

No worries at all. Glad to help out!