static void Main(string[] args) { try { Task.Run(async() => { // If you see an API key below, it's a trial key and will either expire soon or get invalidated. Please get your own key. // Get your own trial key to Bing Speech or the new Speech Service at https://azure.microsoft.com/try/cognitive-services // Create an Azure Cognitive Services Account: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account // DELETE THE NEXT THREE LINE ONCE YOU HAVE OBTAINED YOUR OWN SPEECH API KEY //Console.WriteLine("You forgot to initialize the sample with your own Speech API key. Visit https://azure.microsoft.com/try/cognitive-services to get started."); //Console.ReadLine(); //return; // END DELETE #if USENEWSPEECHSDK bool useClassicBingSpeechService = false; //string authenticationKey = @"INSERT-YOUR-NEW-SPEECH-API-KEY-HERE"; string authenticationKey = @"895664ef53e44b6fac574c3ecd6f3b75"; #else bool useClassicBingSpeechService = true; //string authenticationKey = @"INSERT-YOUR-BING-SPEECH-API-KEY-HERE"; string authenticationKey = @"4d5a1beefe364f8986d63a877ebd51d5"; #endif var recoServiceClient = new SpeechRecognitionClient(useClassicBingSpeechService); // Replace this with your own file. Add it to the project and mark it as "Content" and "Copy if newer". string audioFilePath = @"Thisisatest.wav"; // Make sure to match the region to the Azure region where you created the service. // Note the region is NOT used for the old Bing Speech service string region = "westus"; // Register an event to capture recognition events recoServiceClient.OnMessageReceived += RecoServiceClient_OnMessageReceived; await recoServiceClient.CreateSpeechRecognitionJob(audioFilePath, authenticationKey, region); }).Wait(); } catch (Exception ex) { Console.WriteLine("An exception occurred in the main program:" + Environment.NewLine + ex.Message); } }
private async void btnStart_Click(object sender, RoutedEventArgs e) { // If you see an API key below, it's a trial key and will either expire soon or get invalidated. Please get your own key. // Get your own trial key to Bing Speech or the new Speech Service at https://azure.microsoft.com/try/cognitive-services // Create an Azure Cognitive Services Account: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account // DELETE THE NEXT THREE LINE ONCE YOU HAVE OBTAINED YOUR OWN SPEECH API KEY //Console.WriteLine("You forgot to initialize the sample with your own Speech API key. Visit https://azure.microsoft.com/try/cognitive-services to get started."); //Console.ReadLine(); //return; // END DELETE //#if USENEWSPEECHSDK // bool useClassicBingSpeechService = false; // //string authenticationKey = @"INSERT-YOUR-NEW-SPEECH-API-KEY-HERE"; // string authenticationKey = @"f69d77d425e946e69a954c53db135f77"; //#else // bool useClassicBingSpeechService = true; // //string authenticationKey = @"INSERT-YOUR-BING-SPEECH-API-KEY-HERE"; // string authenticationKey = @"4d5a1beefe364f8986d63a877ebd51d5"; //#endif bool useClassicBingSpeechService = false; string authenticationKey = txtSubscriptionKey.Text; var recoServiceClient = new SpeechRecognitionClient(useClassicBingSpeechService); // Replace this with your own file. Add it to the project and mark it as "Content" and "Copy if newer". string audioFilePath = txtFilename.Text; // Make sure to match the region to the Azure region where you created the service. // Note the region is NOT used for the old Bing Speech service string region = txtRegion.Text; // Register an event to capture recognition events recoServiceClient.OnMessageReceived += RecoServiceClient_OnMessageReceived; recoServiceClient.CreateSpeechRecognitionJob(audioFilePath, authenticationKey, region); lblResult.Text = "Speech recognition job started... uploading audio file. Please wait for first result..."; }