private void OnMicShortPhraseReceiveHandler(object sender, SpeechResponseEventArgs e) { MicClient.EndMicAndRecognition(); IsMicroUse = false; for (int i = 0; i < e.PhraseResponse.Results.Length; i++) { RecognizeText.Add(e.PhraseResponse.Results[i].DisplayText); } }
public void start() { IsMicroUse = true; MicClient = SpeechRecognitionServiceFactory.CreateMicrophoneClient(SpeechRecognitionMode.ShortPhrase, "fr-FR", PrimarySubscriptionKey, SecondarySubscriptionKey); MicClient.OnIntent += onIntentHandler; MicClient.OnResponseReceived += OnMicShortPhraseReceiveHandler; MicClient.OnPartialResponseReceived += OnPartialReponseReceiveHandler; MicClient.OnConversationError += OnConversationErrorHandler; MicClient.StartMicAndRecognition(); }
public static async Task <MicClient> CreateMicClient(string hostname, CancellationToken cancelToken) { HttpClientHandler httpHandler = new HttpClientHandler(); var proxyAddress = Environment.GetEnvironmentVariable("TELENOR_MIC_PROXY"); WebProxy webProxy = default; if (!string.IsNullOrWhiteSpace(proxyAddress)) { webProxy = new WebProxy(proxyAddress); httpHandler.Proxy = webProxy; httpHandler.UseProxy = true; } MicClient micClient = await MicClient.CreateFromHostname(hostname, httpHandler, cancelToken); if (!(webProxy is null)) { micClient.Config.ProxyHost = webProxy.Address.Host; micClient.Config.ProxyPort = webProxy.Address.Port; } return(micClient); }
private void onIntentHandler(object sender, SpeechIntentEventArgs e) { RecognizeText.Add(e.Payload); MicClient.EndMicAndRecognition(); }