deepgram / deepgram-dotnet-sdk

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

Would be nice if IListenWebSocketClient Send method allowed passing in buffer length #333

Closed sgodin closed 2 months ago

sgodin commented 2 months ago

Proposed changes

Send API currently looks like: void Send(byte[] data);

Since it eventually copies this buffer to the websocket message, it would be ideal if the API had an optional buffer size/length parameter, ie: something like: void Send(byte[] data, int dataLen=0);
If 0 is passed in then data.Length is used.

Context

The code I used to read from the stream (ie: stream.ReadAsync) requires a buffer to be created first and returns the number of bytes read. In order to pass this buffer to Deepgram C# API, I need to copy it to another array that is sized as the number of bytes actually read, not the size of the passed in buffer. If the API had this option I could avoid a copy and it would be more efficient.

davidvonthenen commented 2 months ago

Hi @sgodin

That's a good idea. Will get that incorporated in the next release.

davidvonthenen commented 2 months ago

PR https://github.com/deepgram/deepgram-dotnet-sdk/pull/334 merged. Will be available in the 4.3.4 release.

sgodin commented 2 months ago

Awesome - thanks!