Ejemplo n.º 1
0
        public void SetSpeechRegion(SpeechRegion speechRegion)
        {
            SpeechRegion = speechRegion;

            // clear any cached auth token since we need to reauth with the proper set region
            AuthClient.SpeechRegion = speechRegion;
            ClearAuthToken();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Xamarin.Cognitive.Speech.AuthenticationClient"/> class.
        /// </summary>
        /// <param name="authEndpoint">The auth endpoint to get an auth token from.</param>
        /// <param name="subscriptionKey">Subscription identifier.</param>
        /// <param name="speechRegion">The <see cref="SpeechRegion"/> where your speech service is deployed.</param>
        public AuthenticationClient(Endpoint authEndpoint, string subscriptionKey, SpeechRegion speechRegion)
        {
            this.authEndpoint    = authEndpoint;
            this.subscriptionKey = subscriptionKey;
            this.SpeechRegion    = speechRegion;

            client = new HttpClient();
            client.DefaultRequestHeaders.Add(Constants.Keys.SubscriptionKey, this.subscriptionKey);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Xamarin.Cognitive.Speech.SpeechApiClient"/> class.
        /// </summary>
        /// <param name="subscriptionKey">A valid subscription key for the Speech API.</param>
        /// <param name="speechRegion">The <see cref="SpeechRegion"/> where your speech service is deployed.</param>
        /// <param name="authEndpoint">The endpoint used to get the authentication token for the Speech API. Defaults to <see cref="Endpoint.Authentication"/>. To use a custom auth endpoint, set this to an <see cref="Endpoint"/> with your endpoint details.</param>
        /// <param name="speechEndpoint">The endpoint used to talk to the Speech API. Defaults to <see cref="Endpoint.SpeechServiceApi"/>. To use a CRIS/Custom Speech Service endpoint, set this to an <see cref="Endpoint"/> with the details for your CRIS service.</param>
        public SpeechApiClient(string subscriptionKey, SpeechRegion speechRegion, Endpoint authEndpoint = null, Endpoint speechEndpoint = null)
        {
            this.subscriptionKey = subscriptionKey;
            this.authEndpoint    = authEndpoint ?? Endpoints.Authentication;
            this.speechEndpoint  = speechEndpoint ?? Endpoints.SpeechServiceApi;
            this.SpeechRegion    = speechRegion;
            client = new HttpClient();

            AuthClient = new AuthenticationClient(this.authEndpoint, this.subscriptionKey, this.SpeechRegion);
        }
Ejemplo n.º 4
0
        public UriBuilder ToUriBuilder(SpeechRegion speechRegion)
        {
            var uriBuilder = new UriBuilder
            {
                Scheme = this.Protocol,
                Port   = this.Port,
                Path   = this.Path
            };

            if (PrefixWithRegion)
            {
                uriBuilder.Host = $"{speechRegion.ToString ().ToLower ()}.{this.Host}";
            }
            else
            {
                uriBuilder.Host = this.Host;
            }

            return(uriBuilder);
        }