Greetings to all, I ask you for courtesy if you can help me, I just started using C #, I'm exploring the voice recognition so for study and curiosity, The program listens my voice and write result in the cmd Windows prompt , I have to get that if the voice result is the word open Browser NaMe is done starting the browserprocess .
read the cmd result and if result corresponds for example MyBrowser.exe program start Browser Mybrowser.exe.
thank you so much for your help .
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Threading.Tasks;
- using Microsoft.CognitiveServices.Speech;
- namespace helloworld
- {
- class Program
- {
- public static async Task RecognizeSpeechAsync()
- {
- // Creates an instance of a speech config with specified subscription key and service region.
- // Replace with your own subscription key and service region (e.g., "westus").
- var config = SpeechConfig.FromSubscription("mykey", "westus");
- // Creates a speech recognizer.
- using (var recognizer = new SpeechRecognizer(config))
- {
- Console.WriteLine("Say something...");
- // Performs recognition. RecognizeOnceAsync() returns when the first utterance has been recognized,
- // so it is suitable only for single shot recognition like command or query. For long-running
- // recognition, use StartContinuousRecognitionAsync() instead.
- var result = await recognizer.RecognizeOnceAsync();
- // Checks result.
- if (result.Reason == ResultReason.RecognizedSpeech)
- {
- Console.WriteLine($"We recognized: {result.Text}");
- }
- else if (result.Reason == ResultReason.NoMatch)
- {
- Console.WriteLine($"NOMATCH: Speech could not be recognized.");
- }
- else if (result.Reason == ResultReason.Canceled)
- {
- var cancellation = CancellationDetails.FromResult(result);
- Console.WriteLine($"CANCELED: Reason={cancellation.Reason}");
- if (cancellation.Reason == CancellationReason.Error)
- {
- Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}");
- Console.WriteLine($"CANCELED: ErrorDetails={cancellation.ErrorDetails}");
- Console.WriteLine($"CANCELED: Did you update the subscription info?");
- }
- }
- }
- }
- static void Main()
- {
- RecognizeSpeechAsync().Wait();
- Console.WriteLine("Please press a key to continue.");
- Console.ReadLine();
- }
- }
- }
Logesh PalaniPosted Jan 7, 2019, 7:56 PM