NateRickard / Xamarin.Cognitive.Speech

A client library that makes it easy to work with the Microsoft Cognitive Services Speech Services Speech to Text API on Xamarin.iOS, Xamarin.Android, UWP, and Xamarin.Forms/.NET Standard libraries used by those platforms
MIT License
59 stars 18 forks source link

Need support for query in Endpoint #23

Closed PCrispin closed 5 years ago

PCrispin commented 5 years ago

Fantastic library - thank you so much for creating it.

I created a custom speech deployment where the speech service API endpoint is of the form:

https://uksouth.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?cid=[deleted_private_identifier]

The Endpoint class does not support the query parameter for the UriBuilder in ToUriBuilder. It is not possible to add the query (ie the part after the ? in the url) in the Path parameter in UriBuilder. As such, I cannot create an Endpoint object that points at my endpoint.

This could be corrected by adding the parameter to the Endpoint class:

public string Query { get; private set; }

And then alter the UriBuilder within ToUriBuilder to:

      var uriBuilder = new UriBuilder
       {
           Scheme = this.Protocol,
           Port = this.Port,
           Path = this.Path,
           Query = this.Query,
       };
NateRickard commented 5 years ago

Added in d183dcc8a0e005db6e9a4e1ac53790e38a6ef667

NuGet v1.0.1 released

PCrispin commented 5 years ago

Really sorry for this late update but I just discovered this problem. To use the Query parameter, another line of code needs updating:-

In SpeechApiClient, with the start of the CreateRequest method needs to be changed from:

uriBuilder.Query = $"language ={RecognitionLanguage}&format={outputMode.ToString ().ToLower ()}&profanity={ProfanityMode.ToString ().ToLower ()}";

to

uriBuilder.Query += $"&language ={RecognitionLanguage}&format={outputMode.ToString ().ToLower ()}&profanity={ProfanityMode.ToString ().ToLower ()}";

NateRickard commented 5 years ago

My bad, figured once the uriBuilder had the correct query value it was smooth sailing... forgot I was actually setting the query for all that other stuff in the client.

NuGet 1.0.2 publishing now...