// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE.md file in the project root for full license information. // using System; using System.Threading.Tasks; using Microsoft.CognitiveServices.Speech; namespace helloworld { class Program { public static async Task RecognizeSpeechAsync() { var config = SpeechConfig.FromSubscription("867a58ff-79d9-4d7b-85ca-13b507359667", "centralindia"); using (var recognizer = new SpeechRecognizer(config)) { var result = await recognizer.RecognizeOnceAsync(); 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() { Console.WriteLine("Begin speaking...."); RecognizeSpeechAsync().Wait(); Console.WriteLine("Please press to continue."); Console.ReadLine(); } } }