void Start() { LogSystem.InstallDefaultReactors(); _customCorpusFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/theJabberwocky-utf8.txt"; _customWordsFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/test-stt-words.json"; _acousticResourceMimeType = Utility.GetMimeType(Path.GetExtension(_acousticResourceUrl)); _oggResourceMimeType = Utility.GetMimeType(Path.GetExtension(_oggResourceUrl)); Runnable.Run(CreateService()); }
private IEnumerator Examples() { Runnable.Run(DownloadAcousticResource()); while (!_isAudioLoaded) { yield return(null); } Runnable.Run(DownloadOggResource()); while (!_isOggLoaded) { yield return(null); } // Recognize Log.Debug("ExampleSpeechToText.Examples()", "Attempting to recognize"); List <string> keywords = new List <string>(); keywords.Add("speech"); _service.KeywordsThreshold = 0.5f; _service.InactivityTimeout = 120; _service.StreamMultipart = false; _service.Keywords = keywords.ToArray(); _service.Recognize(HandleOnRecognize, OnFail, _acousticResourceData, _acousticResourceMimeType); while (!_recognizeTested) { yield return(null); } // Recognize ogg Log.Debug("ExampleSpeechToText", "Attempting to recognize ogg: mimeType: {0} | _speechTText.StreamMultipart: {1}", _oggResourceMimeType, _service.StreamMultipart); _service.Recognize(HandleOnRecognizeOgg, OnFail, _oggResourceData, _oggResourceMimeType + ";codecs=vorbis"); while (!_recognizeOggTested) { yield return(null); } // Get models Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get models"); _service.GetModels(HandleGetModels, OnFail); while (!_getModelsTested) { yield return(null); } // Get model Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get model {0}", _modelNameToGet); _service.GetModel(HandleGetModel, OnFail, _modelNameToGet); while (!_getModelTested) { yield return(null); } // Get customizations Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get customizations"); _service.GetCustomizations(HandleGetCustomizations, OnFail); while (!_getCustomizationsTested) { yield return(null); } // Create customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting create customization"); _service.CreateCustomization(HandleCreateCustomization, OnFail, "unity-test-customization", "en-US_BroadbandModel", "Testing customization unity"); while (!_createCustomizationsTested) { yield return(null); } // Get customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get customization {0}", _createdCustomizationID); _service.GetCustomization(HandleGetCustomization, OnFail, _createdCustomizationID); while (!_getCustomizationTested) { yield return(null); } // Get custom corpora Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get custom corpora for {0}", _createdCustomizationID); _service.GetCustomCorpora(HandleGetCustomCorpora, OnFail, _createdCustomizationID); while (!_getCustomCorporaTested) { yield return(null); } // Add custom corpus Log.Debug("ExampleSpeechToText.Examples()", "Attempting to add custom corpus {1} in customization {0}", _createdCustomizationID, _createdCorpusName); string corpusData = File.ReadAllText(_customCorpusFilePath); _service.AddCustomCorpus(HandleAddCustomCorpus, OnFail, _createdCustomizationID, _createdCorpusName, true, corpusData); while (!_addCustomCorpusTested) { yield return(null); } // Get custom corpus Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get custom corpus {1} in customization {0}", _createdCustomizationID, _createdCorpusName); _service.GetCustomCorpus(HandleGetCustomCorpus, OnFail, _createdCustomizationID, _createdCorpusName); while (!_getCustomCorpusTested) { yield return(null); } // Wait for customization Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Get custom words Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get custom words."); _service.GetCustomWords(HandleGetCustomWords, OnFail, _createdCustomizationID); while (!_getCustomWordsTested) { yield return(null); } // Add custom words from path Log.Debug("ExampleSpeechToText.Examples()", "Attempting to add custom words in customization {0} using Words json path {1}", _createdCustomizationID, _customWordsFilePath); string customWords = File.ReadAllText(_customWordsFilePath); _service.AddCustomWords(HandleAddCustomWordsFromPath, OnFail, _createdCustomizationID, customWords); while (!_addCustomWordsFromPathTested) { yield return(null); } // Wait for customization _isCustomizationReady = false; Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Add custom words from object Words words = new Words(); Word w0 = new Word(); List <Word> wordList = new List <Word>(); w0.word = "mikey"; w0.sounds_like = new string[1]; w0.sounds_like[0] = "my key"; w0.display_as = "Mikey"; wordList.Add(w0); Word w1 = new Word(); w1.word = "charlie"; w1.sounds_like = new string[1]; w1.sounds_like[0] = "char lee"; w1.display_as = "Charlie"; wordList.Add(w1); Word w2 = new Word(); w2.word = "bijou"; w2.sounds_like = new string[1]; w2.sounds_like[0] = "be joo"; w2.display_as = "Bijou"; wordList.Add(w2); words.words = wordList.ToArray(); Log.Debug("ExampleSpeechToText.Examples()", "Attempting to add custom words in customization {0} using Words object", _createdCustomizationID); _service.AddCustomWords(HandleAddCustomWordsFromObject, OnFail, _createdCustomizationID, words); while (!_addCustomWordsFromObjectTested) { yield return(null); } // Wait for customization _isCustomizationReady = false; Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Get custom word Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get custom word {1} in customization {0}", _createdCustomizationID, words.words[0].word); _service.GetCustomWord(HandleGetCustomWord, OnFail, _createdCustomizationID, words.words[0].word); while (!_getCustomWordTested) { yield return(null); } // Train customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting to train customization {0}", _createdCustomizationID); _service.TrainCustomization(HandleTrainCustomization, OnFail, _createdCustomizationID); while (!_trainCustomizationTested) { yield return(null); } // Wait for customization _isCustomizationReady = false; Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Upgrade customization - not currently implemented in service //Log.Debug("ExampleSpeechToText.Examples()", "Attempting to upgrade customization {0}", _createdCustomizationID); //_speechToText.UpgradeCustomization(HandleUpgradeCustomization, _createdCustomizationID); //while (!_upgradeCustomizationTested) // yield return null; // Delete custom word Log.Debug("ExampleSpeechToText.Examples()", "Attempting to delete custom word {1} in customization {0}", _createdCustomizationID, words.words[2].word); _service.DeleteCustomWord(HandleDeleteCustomWord, OnFail, _createdCustomizationID, words.words[2].word); while (!_deleteCustomWordTested) { yield return(null); } // Delay Log.Debug("ExampleSpeechToText.Examples()", string.Format("Delaying delete environment for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } _readyToContinue = false; // Delete custom corpus Log.Debug("ExampleSpeechToText.Examples()", "Attempting to delete custom corpus {1} in customization {0}", _createdCustomizationID, _createdCorpusName); _service.DeleteCustomCorpus(HandleDeleteCustomCorpus, OnFail, _createdCustomizationID, _createdCorpusName); while (!_deleteCustomCorpusTested) { yield return(null); } // Delay Log.Debug("ExampleSpeechToText.Examples()", string.Format("Delaying delete environment for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } _readyToContinue = false; // Reset customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting to reset customization {0}", _createdCustomizationID); _service.ResetCustomization(HandleResetCustomization, OnFail, _createdCustomizationID); while (!_resetCustomizationTested) { yield return(null); } // Delay Log.Debug("ExampleSpeechToText.Examples()", string.Format("Delaying delete environment for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } _readyToContinue = false; // Delete customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting to delete customization {0}", _createdCustomizationID); _service.DeleteCustomization(HandleDeleteCustomization, OnFail, _createdCustomizationID); while (!_deleteCustomizationsTested) { yield return(null); } // List acoustic customizations Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get acoustic customizations"); _service.GetCustomAcousticModels(HandleGetCustomAcousticModels, OnFail); while (!_getAcousticCustomizationsTested) { yield return(null); } // Create acoustic customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting to create acoustic customization"); _service.CreateAcousticCustomization(HandleCreateAcousticCustomization, OnFail, _createdAcousticModelName); while (!_createAcousticCustomizationsTested) { yield return(null); } // Get acoustic customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get acoustic customization {0}", _createdAcousticModelId); _service.GetCustomAcousticModel(HandleGetCustomAcousticModel, OnFail, _createdAcousticModelId); while (!_getAcousticCustomizationTested) { yield return(null); } while (!_isAudioLoaded) { yield return(null); } // Create acoustic resource Log.Debug("ExampleSpeechToText.Examples()", "Attempting to create audio resource {1} on {0}", _createdAcousticModelId, _acousticResourceName); string mimeType = Utility.GetMimeType(Path.GetExtension(_acousticResourceUrl)); _service.AddAcousticResource(HandleAddAcousticResource, OnFail, _createdAcousticModelId, _acousticResourceName, mimeType, mimeType, true, _acousticResourceData); while (!_addAcousticResourcesTested) { yield return(null); } // Wait for customization _isAcousticCustomizationReady = false; Runnable.Run(CheckAcousticCustomizationStatus(_createdAcousticModelId)); while (!_isAcousticCustomizationReady) { yield return(null); } // List acoustic resources Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get audio resources {0}", _createdAcousticModelId); _service.GetCustomAcousticResources(HandleGetCustomAcousticResources, OnFail, _createdAcousticModelId); while (!_getAcousticResourcesTested) { yield return(null); } // Train acoustic customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting to train acoustic customization {0}", _createdAcousticModelId); _service.TrainAcousticCustomization(HandleTrainAcousticCustomization, OnFail, _createdAcousticModelId, null, true); while (!_trainAcousticCustomizationsTested) { yield return(null); } // Get acoustic resource Log.Debug("ExampleSpeechToText.Examples()", "Attempting to get audio resource {1} from {0}", _createdAcousticModelId, _acousticResourceName); _service.GetCustomAcousticResource(HandleGetCustomAcousticResource, OnFail, _createdAcousticModelId, _acousticResourceName); while (!_getAcousticResourceTested) { yield return(null); } // Wait for customization _isAcousticCustomizationReady = false; Runnable.Run(CheckAcousticCustomizationStatus(_createdAcousticModelId)); while (!_isAcousticCustomizationReady) { yield return(null); } // Delay Log.Debug("ExampleSpeechToText.Examples()", string.Format("Delaying delete acoustic resource for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } // Delete acoustic resource DeleteAcousticResource(); while (!_deleteAcousticResource) { yield return(null); } // Reset acoustic customization Log.Debug("ExampleSpeechToText.Examples()", "Attempting to reset acoustic customization {0}", _createdAcousticModelId); _service.ResetAcousticCustomization(HandleResetAcousticCustomization, OnFail, _createdAcousticModelId); while (!_resetAcousticCustomizationsTested) { yield return(null); } // Delay Log.Debug("ExampleSpeechToText.Examples()", string.Format("Delaying delete acoustic customization for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } // Delete acoustic customization DeleteAcousticCustomization(); while (!_deleteAcousticCustomizationsTested) { yield return(null); } // Delay Log.Debug("ExampleSpeechToText.Examples()", string.Format("Delaying complete for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } Log.Debug("ExampleSpeechToText.Examples()", "Speech to Text examples complete."); }
public override IEnumerator RunTest() { LogSystem.InstallDefaultReactors(); VcapCredentials vcapCredentials = new VcapCredentials(); fsData data = null; string result = null; string credentialsFilepath = "../sdk-credentials/credentials.json"; // Load credentials file if it exists. If it doesn't exist, don't run the tests. if (File.Exists(credentialsFilepath)) { result = File.ReadAllText(credentialsFilepath); } else { yield break; } // Add in a parent object because Unity does not like to deserialize root level collection types. result = Utility.AddTopLevelObjectToJson(result, "VCAP_SERVICES"); // Convert json to fsResult fsResult r = fsJsonParser.Parse(result, out data); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Convert fsResult to VcapCredentials object obj = vcapCredentials; r = _serializer.TryDeserialize(data, obj.GetType(), ref obj); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Set credentials from imported credntials Credential credential = vcapCredentials.GetCredentialByname("speech-to-text-sdk")[0].Credentials; // Create credential and instantiate service TokenOptions tokenOptions = new TokenOptions() { IamApiKey = credential.IamApikey, }; // Create credential and instantiate service Credentials credentials = new Credentials(tokenOptions, credential.Url); // Wait for tokendata while (!credentials.HasIamTokenData()) { yield return(null); } _speechToText = new SpeechToText(credentials); _customCorpusFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/theJabberwocky-utf8.txt"; _customWordsFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/test-stt-words.json"; _grammarFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/confirm.abnf"; _acousticResourceMimeType = Utility.GetMimeType(Path.GetExtension(_acousticResourceUrl)); Runnable.Run(DownloadAcousticResource()); while (!_isAudioLoaded) { yield return(null); } // Recognize Log.Debug("TestSpeechToText.Examples()", "Attempting to recognize"); List <string> keywords = new List <string>(); keywords.Add("speech"); _speechToText.KeywordsThreshold = 0.5f; _speechToText.InactivityTimeout = 120; _speechToText.StreamMultipart = false; _speechToText.Keywords = keywords.ToArray(); _speechToText.Recognize(HandleOnRecognize, OnFail, _acousticResourceData, _acousticResourceMimeType); while (!_recognizeTested) { yield return(null); } // Get models Log.Debug("TestSpeechToText.Examples()", "Attempting to get models"); _speechToText.GetModels(HandleGetModels, OnFail); while (!_getModelsTested) { yield return(null); } // Get model Log.Debug("TestSpeechToText.Examples()", "Attempting to get model {0}", _modelNameToGet); _speechToText.GetModel(HandleGetModel, OnFail, _modelNameToGet); while (!_getModelTested) { yield return(null); } // Get customizations Log.Debug("TestSpeechToText.Examples()", "Attempting to get customizations"); _speechToText.GetCustomizations(HandleGetCustomizations, OnFail); while (!_getCustomizationsTested) { yield return(null); } // Create customization Log.Debug("TestSpeechToText.Examples()", "Attempting create customization"); _speechToText.CreateCustomization(HandleCreateCustomization, OnFail, "unity-test-customization", "en-US_BroadbandModel", "Testing customization unity"); while (!_createCustomizationsTested) { yield return(null); } // Get customization Log.Debug("TestSpeechToText.Examples()", "Attempting to get customization {0}", _createdCustomizationID); _speechToText.GetCustomization(HandleGetCustomization, OnFail, _createdCustomizationID); while (!_getCustomizationTested) { yield return(null); } // Get custom corpora Log.Debug("TestSpeechToText.Examples()", "Attempting to get custom corpora for {0}", _createdCustomizationID); _speechToText.GetCustomCorpora(HandleGetCustomCorpora, OnFail, _createdCustomizationID); while (!_getCustomCorporaTested) { yield return(null); } // Add custom corpus Log.Debug("TestSpeechToText.Examples()", "Attempting to add custom corpus {1} in customization {0}", _createdCustomizationID, _createdCorpusName); string corpusData = File.ReadAllText(_customCorpusFilePath); _speechToText.AddCustomCorpus(HandleAddCustomCorpus, OnFail, _createdCustomizationID, _createdCorpusName, true, corpusData); while (!_addCustomCorpusTested) { yield return(null); } // Get custom corpus Log.Debug("TestSpeechToText.Examples()", "Attempting to get custom corpus {1} in customization {0}", _createdCustomizationID, _createdCorpusName); _speechToText.GetCustomCorpus(HandleGetCustomCorpus, OnFail, _createdCustomizationID, _createdCorpusName); while (!_getCustomCorpusTested) { yield return(null); } // Wait for customization Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Get custom words Log.Debug("TestSpeechToText.Examples()", "Attempting to get custom words."); _speechToText.GetCustomWords(HandleGetCustomWords, OnFail, _createdCustomizationID); while (!_getCustomWordsTested) { yield return(null); } // Add custom words from path Log.Debug("TestSpeechToText.Examples()", "Attempting to add custom words in customization {0} using Words json path {1}", _createdCustomizationID, _customWordsFilePath); string customWords = File.ReadAllText(_customWordsFilePath); _speechToText.AddCustomWords(HandleAddCustomWordsFromPath, OnFail, _createdCustomizationID, customWords); while (!_addCustomWordsFromPathTested) { yield return(null); } // Wait for customization _isCustomizationReady = false; Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Add custom words from object Words words = new Words(); Word w0 = new Word(); List <Word> wordList = new List <Word>(); w0.word = "mikey"; w0.sounds_like = new string[1]; w0.sounds_like[0] = "my key"; w0.display_as = "Mikey"; wordList.Add(w0); Word w1 = new Word(); w1.word = "charlie"; w1.sounds_like = new string[1]; w1.sounds_like[0] = "char lee"; w1.display_as = "Charlie"; wordList.Add(w1); Word w2 = new Word(); w2.word = "bijou"; w2.sounds_like = new string[1]; w2.sounds_like[0] = "be joo"; w2.display_as = "Bijou"; wordList.Add(w2); words.words = wordList.ToArray(); Log.Debug("TestSpeechToText.Examples()", "Attempting to add custom words in customization {0} using Words object", _createdCustomizationID); _speechToText.AddCustomWords(HandleAddCustomWordsFromObject, OnFail, _createdCustomizationID, words); while (!_addCustomWordsFromObjectTested) { yield return(null); } // Wait for customization _isCustomizationReady = false; Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Get custom word Log.Debug("TestSpeechToText.Examples()", "Attempting to get custom word {1} in customization {0}", _createdCustomizationID, words.words[0].word); _speechToText.GetCustomWord(HandleGetCustomWord, OnFail, _createdCustomizationID, words.words[0].word); while (!_getCustomWordTested) { yield return(null); } // Train customization Log.Debug("TestSpeechToText.Examples()", "Attempting to train customization {0}", _createdCustomizationID); _speechToText.TrainCustomization(HandleTrainCustomization, OnFail, _createdCustomizationID); while (!_trainCustomizationTested) { yield return(null); } // Wait for customization _isCustomizationReady = false; Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Delete custom word Log.Debug("TestSpeechToText.Examples()", "Attempting to delete custom word {1} in customization {0}", _createdCustomizationID, words.words[2].word); _speechToText.DeleteCustomWord(HandleDeleteCustomWord, OnFail, _createdCustomizationID, words.words[2].word); while (!_deleteCustomWordTested) { yield return(null); } // Delay Log.Debug("TestSpeechToText.Examples()", string.Format("Delaying delete environment for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } _readyToContinue = false; // Delete custom corpus Log.Debug("TestSpeechToText.Examples()", "Attempting to delete custom corpus {1} in customization {0}", _createdCustomizationID, _createdCorpusName); _speechToText.DeleteCustomCorpus(HandleDeleteCustomCorpus, OnFail, _createdCustomizationID, _createdCorpusName); while (!_deleteCustomCorpusTested) { yield return(null); } // Delay Log.Debug("TestSpeechToText.Examples()", string.Format("Delaying delete environment for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } _readyToContinue = false; // Reset customization Log.Debug("TestSpeechToText.Examples()", "Attempting to reset customization {0}", _createdCustomizationID); _speechToText.ResetCustomization(HandleResetCustomization, OnFail, _createdCustomizationID); while (!_resetCustomizationTested) { yield return(null); } // Delay Log.Debug("TestSpeechToText.Examples()", string.Format("Delaying delete environment for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } // List Grammars Log.Debug("TestSpeechToText.Examples()", "Attempting to list grammars {0}", _createdCustomizationID); _speechToText.ListGrammars(OnListGrammars, OnFail, _createdCustomizationID); while (!_listGrammarsTested) { yield return(null); } // Add Grammar Log.Debug("TestSpeechToText.Examples()", "Attempting to add grammar {0}", _createdCustomizationID); string grammarFile = File.ReadAllText(_grammarFilePath); _speechToText.AddGrammar(OnAddGrammar, OnFail, _createdCustomizationID, _grammarName, grammarFile, _grammarFileContentType); while (!_addGrammarTested) { yield return(null); } // Get Grammar Log.Debug("TestSpeechToText.Examples()", "Attempting to get grammar {0}", _createdCustomizationID); _speechToText.GetGrammar(OnGetGrammar, OnFail, _createdCustomizationID, _grammarName); while (!_getGrammarTested) { yield return(null); } // Wait for customization _isCustomizationReady = false; Runnable.Run(CheckCustomizationStatus(_createdCustomizationID)); while (!_isCustomizationReady) { yield return(null); } // Delete Grammar Log.Debug("TestSpeechToText.Examples()", "Attempting to delete grammar {0}", _createdCustomizationID); _speechToText.DeleteGrammar(OnDeleteGrammar, OnFail, _createdCustomizationID, _grammarName); while (!_deleteGrammarTested) { yield return(null); } _readyToContinue = false; // Delete customization Log.Debug("TestSpeechToText.Examples()", "Attempting to delete customization {0}", _createdCustomizationID); _speechToText.DeleteCustomization(HandleDeleteCustomization, OnFail, _createdCustomizationID); while (!_deleteCustomizationsTested) { yield return(null); } // List acoustic customizations Log.Debug("TestSpeechToText.Examples()", "Attempting to get acoustic customizations"); _speechToText.GetCustomAcousticModels(HandleGetCustomAcousticModels, OnFail); while (!_getAcousticCustomizationsTested) { yield return(null); } // Create acoustic customization Log.Debug("TestSpeechToText.Examples()", "Attempting to create acoustic customization"); _speechToText.CreateAcousticCustomization(HandleCreateAcousticCustomization, OnFail, _createdAcousticModelName); while (!_createAcousticCustomizationsTested) { yield return(null); } // Get acoustic customization Log.Debug("TestSpeechToText.Examples()", "Attempting to get acoustic customization {0}", _createdAcousticModelId); _speechToText.GetCustomAcousticModel(HandleGetCustomAcousticModel, OnFail, _createdAcousticModelId); while (!_getAcousticCustomizationTested) { yield return(null); } while (!_isAudioLoaded) { yield return(null); } // Create acoustic resource Log.Debug("TestSpeechToText.Examples()", "Attempting to create audio resource {1} on {0}", _createdAcousticModelId, _acousticResourceName); string mimeType = Utility.GetMimeType(Path.GetExtension(_acousticResourceUrl)); _speechToText.AddAcousticResource(HandleAddAcousticResource, OnFail, _createdAcousticModelId, _acousticResourceName, mimeType, mimeType, true, _acousticResourceData); while (!_addAcousticResourcesTested) { yield return(null); } // Wait for customization _isAcousticCustomizationReady = false; Runnable.Run(CheckAcousticCustomizationStatus(_createdAcousticModelId)); while (!_isAcousticCustomizationReady) { yield return(null); } // List acoustic resources Log.Debug("TestSpeechToText.Examples()", "Attempting to get audio resources {0}", _createdAcousticModelId); _speechToText.GetCustomAcousticResources(HandleGetCustomAcousticResources, OnFail, _createdAcousticModelId); while (!_getAcousticResourcesTested) { yield return(null); } // Train acoustic customization Log.Debug("TestSpeechToText.Examples()", "Attempting to train acoustic customization {0}", _createdAcousticModelId); _speechToText.TrainAcousticCustomization(HandleTrainAcousticCustomization, OnFail, _createdAcousticModelId, null, true); while (!_trainAcousticCustomizationsTested) { yield return(null); } // Get acoustic resource Log.Debug("TestSpeechToText.Examples()", "Attempting to get audio resource {1} from {0}", _createdAcousticModelId, _acousticResourceName); _speechToText.GetCustomAcousticResource(HandleGetCustomAcousticResource, OnFail, _createdAcousticModelId, _acousticResourceName); while (!_getAcousticResourceTested) { yield return(null); } // Wait for customization _isAcousticCustomizationReady = false; Runnable.Run(CheckAcousticCustomizationStatus(_createdAcousticModelId)); while (!_isAcousticCustomizationReady) { yield return(null); } // Delete acoustic resource DeleteAcousticResource(); while (!_deleteAcousticResource) { yield return(null); } // Delay Log.Debug("TestSpeechToText.Examples()", string.Format("Delaying delete acoustic resource for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } // Reset acoustic customization Log.Debug("TestSpeechToText.Examples()", "Attempting to reset acoustic customization {0}", _createdAcousticModelId); _speechToText.ResetAcousticCustomization(HandleResetAcousticCustomization, OnFail, _createdAcousticModelId); while (!_resetAcousticCustomizationsTested) { yield return(null); } // Delay Log.Debug("TestSpeechToText.Examples()", string.Format("Delaying delete acoustic customization for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } // Delete acoustic customization DeleteAcousticCustomization(); while (!_deleteAcousticCustomizationsTested) { yield return(null); } // Delay Log.Debug("TestSpeechToText.Examples()", string.Format("Delaying complete for {0} sec", _delayTimeInSeconds)); Runnable.Run(Delay(_delayTimeInSeconds)); while (!_readyToContinue) { yield return(null); } Log.Debug("TestSpeechToText.RunTest()", "Speech to Text examples complete."); yield break; }