public void CustomVoiceModels_Success() { var listVoiceModelsResult = ListVoiceModels(); var createVoiceModel = new CreateVoiceModel { Name = _voiceModelName, Description = _voiceModelDescription, Language = Model.CreateVoiceModel.LanguageEnum.EN_US }; var createVoiceModelResult = CreateVoiceModel(createVoiceModel); var customizationId = createVoiceModelResult.CustomizationId; var getVoiceModelResult = GetVoiceModel(customizationId); var updateVoiceModel = new UpdateVoiceModel { Name = _voiceModelUpdatedName, Description = _voiceModelUpdatedDescription, Words = new System.Collections.Generic.List <Word>() { new Word() { _Word = "hello", Translation = "hullo" }, new Word() { _Word = "goodbye", Translation = "gbye" }, new Word() { _Word = "hi", Translation = "ohioooo" } } }; var updateVoiceModelResult = UpdateVoiceModel(customizationId, updateVoiceModel); var deleteVoiceModelResult = DeleteVoiceModel(customizationId); Assert.IsNotNull(updateVoiceModel); Assert.IsTrue(updateVoiceModel.Name == _voiceModelUpdatedName); Assert.IsTrue(updateVoiceModel.Description == _voiceModelUpdatedDescription); Assert.IsTrue(updateVoiceModel.Words.Count == 3); Assert.IsNotNull(getVoiceModelResult); Assert.IsTrue(getVoiceModelResult.Name == _voiceModelName); Assert.IsTrue(getVoiceModelResult.Description == _voiceModelDescription); Assert.IsNotNull(createVoiceModelResult); Assert.IsNotNull(listVoiceModelsResult); Assert.IsNotNull(listVoiceModelsResult.Customizations); }
private BaseModel UpdateVoiceModel(string customizationId, UpdateVoiceModel updateVoiceModel, Dictionary <string, object> customData = null) { Console.WriteLine("\nAttempting to UpdateVoiceModel()"); var result = service.UpdateVoiceModel(customizationId: customizationId, updateVoiceModel: updateVoiceModel, customData: customData); if (result != null) { Console.WriteLine("UpdateVoiceModel() succeeded:\n{0}", JsonConvert.SerializeObject(result, Formatting.Indented)); } else { Console.WriteLine("Failed to UpdateVoiceModel()"); } return(result); }
/// <summary> /// Update a custom model. /// /// Updates information for the specified custom voice model. You can update metadata such as the name and /// description of the voice model. You can also update the words in the model and their translations. Adding a /// new translation for a word that already exists in a custom model overwrites the word's existing translation. /// A custom model can contain no more than 20,000 entries. You must use credentials for the instance of the /// service that owns a model to update it. /// /// **Note:** This method is currently a beta release. /// </summary> /// <param name="customizationId">The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model.</param> /// <param name="updateVoiceModel">An `UpdateVoiceModel` object that contains information that is to be updated /// for the custom voice model.</param> /// <param name="customData">Custom data object to pass data including custom request headers.</param> /// <returns><see cref="BaseModel" />BaseModel</returns> public BaseModel UpdateVoiceModel(string customizationId, UpdateVoiceModel updateVoiceModel, Dictionary <string, object> customData = null) { if (string.IsNullOrEmpty(customizationId)) { throw new ArgumentNullException(nameof(customizationId)); } if (updateVoiceModel == null) { throw new ArgumentNullException(nameof(updateVoiceModel)); } BaseModel result = null; try { IClient client; if (_tokenManager == null) { client = this.Client.WithAuthentication(this.UserName, this.Password); } else { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/customizations/{customizationId}"); restRequest.WithBody <UpdateVoiceModel>(updateVoiceModel); if (customData != null) { restRequest.WithCustomData(customData); } result = restRequest.As <BaseModel>().Result; if (result == null) { result = new BaseModel(); } result.CustomData = restRequest.CustomData; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }