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

Fixing HttpException when using Float url parameters with fractional values #178

Closed dhymik closed 10 months ago

dhymik commented 11 months ago

This fixes #177 ("Specifiying UtteranceSplit parameter with a fractional value causes HttpException")

When calling DeepgramClient.Transcription.Prerecorded.GetTranscriptionAsync(...) with a PrerecordedTranscriptionOptions parameter that contains a PrerecordedTranscriptionOptions.UtteranceSplit value which has a fractiuonal value (i.e. 1.2, 2.5) causes HttpException. Values like 2.0, 1.0 do not cause exception.

The issue is the way the float value is being serialized in Deepgram.Utilities.QueryParameterUtil.GetParameters(...)

A parameter value of 2.2 is serialized into this url parameter: utt_split=2%2c2

I added a "Float" type branch in Deepgram.Utilities.QueryParameterUtil.GetParameters(...) which does not url encode the float value and stringifies it with an invariant culture.

davidvonthenen commented 10 months ago

thanks for your contribution!