Search in sources :

Example 11 with VoiceModel

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel in project java-sdk by watson-developer-cloud.

the class CustomizationsIT method testUpdateVoiceModelWords.

/**
 * Test update voice model with new name and new custom translations.
 */
@Test
public void testUpdateVoiceModelWords() {
    final String newName = "new test";
    model = createVoiceModel();
    GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder().customizationId(model.getCustomizationId()).build();
    model = service.getVoiceModel(getOptions).execute();
    UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder().customizationId(model.getCustomizationId()).name(newName).words(instantiateWords()).build();
    service.updateVoiceModel(updateOptions).execute();
    final VoiceModel model2 = service.getVoiceModel(getOptions).execute();
    assertModelsEqual(model, model2);
    assertNotEquals(model.getWords(), model2.getWords());
}
Also used : GetVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions) VoiceModel(com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel) UpdateVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.UpdateVoiceModelOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 12 with VoiceModel

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel in project java-sdk by watson-developer-cloud.

the class CustomizationsTest method testUpdateVoiceModelWords.

/**
 * Test update voice model with new words.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testUpdateVoiceModelWords() throws InterruptedException {
    // Create the custom voice model.
    server.enqueue(jsonResponse(voiceModelWords));
    CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder().name(MODEL_NAME).language(MODEL_LANGUAGE).description(MODEL_DESCRIPTION).build();
    final VoiceModel result = service.createVoiceModel(createOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(CUSTOMIZATION_ID, result.getCustomizationId());
    // Update the custom voice model with new words.
    server.enqueue(new MockResponse().setResponseCode(201));
    UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder().customizationId(CUSTOMIZATION_ID).name(MODEL_NAME).description(MODEL_DESCRIPTION).words(instantiateWords()).build();
    service.updateVoiceModel(updateOptions).execute();
    final RecordedRequest updateRequest = server.takeRequest();
    assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), updateRequest.getPath());
    assertEquals("POST", request.getMethod());
    // Compare expected with actual results.
    server.enqueue(jsonResponse(voiceModelWords));
    GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build();
    final VoiceModel getResult = service.getVoiceModel(getOptions).execute();
    final RecordedRequest getRequest = server.takeRequest();
    assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath());
    assertEquals("GET", getRequest.getMethod());
    assertEquals(voiceModelWords, getResult);
    assertNotNull(voiceModelWords.getWords());
    assertEquals(voiceModelWords.getWords(), getResult.getWords());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) VoiceModel(com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel) MockResponse(okhttp3.mockwebserver.MockResponse) GetVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions) UpdateVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.UpdateVoiceModelOptions) CreateVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 13 with VoiceModel

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel in project java-sdk by watson-developer-cloud.

the class CustomizationsTest method testCreateVoiceModel.

/**
 * Test create voice model.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testCreateVoiceModel() throws InterruptedException {
    // Create the custom voice model.
    server.enqueue(jsonResponse(voiceModel));
    CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder().name(MODEL_NAME).language(MODEL_LANGUAGE).description(MODEL_DESCRIPTION).build();
    final VoiceModel result = service.createVoiceModel(createOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(VOICE_MODELS_PATH, request.getPath());
    assertEquals("POST", request.getMethod());
    assertEquals(CUSTOMIZATION_ID, result.getCustomizationId());
    // Compare expected with actual results.
    server.enqueue(jsonResponse(voiceModel));
    GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build();
    final VoiceModel getResult = service.getVoiceModel(getOptions).execute();
    final RecordedRequest getRequest = server.takeRequest();
    assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath());
    assertEquals("GET", getRequest.getMethod());
    assertEquals(voiceModel, getResult);
    assertNull(voiceModel.getWords());
    assertEquals(voiceModel.getWords(), getResult.getWords());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) VoiceModel(com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel) GetVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions) CreateVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 14 with VoiceModel

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel in project java-sdk by watson-developer-cloud.

the class CustomizationsTest method testUpdateVoiceModel.

/**
 * Test update voice model.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testUpdateVoiceModel() throws InterruptedException {
    // Create the custom voice model.
    server.enqueue(jsonResponse(voiceModel));
    CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder().name(MODEL_NAME).language(MODEL_LANGUAGE).description(MODEL_DESCRIPTION).build();
    final VoiceModel result = service.createVoiceModel(createOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(CUSTOMIZATION_ID, result.getCustomizationId());
    // Update the custom voice model.
    server.enqueue(new MockResponse().setResponseCode(201));
    UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder().customizationId(CUSTOMIZATION_ID).name(MODEL_NAME).description(MODEL_DESCRIPTION).build();
    service.updateVoiceModel(updateOptions).execute();
    final RecordedRequest updateRequest = server.takeRequest();
    assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), updateRequest.getPath());
    assertEquals("POST", request.getMethod());
    // Compare expected with actual results.
    server.enqueue(jsonResponse(voiceModel));
    GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build();
    final VoiceModel getResult = service.getVoiceModel(getOptions).execute();
    final RecordedRequest getRequest = server.takeRequest();
    assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath());
    assertEquals("GET", getRequest.getMethod());
    assertEquals(voiceModel, getResult);
    assertNull(voiceModel.getWords());
    assertEquals(voiceModel.getWords(), getResult.getWords());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) VoiceModel(com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel) MockResponse(okhttp3.mockwebserver.MockResponse) GetVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions) UpdateVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.UpdateVoiceModelOptions) CreateVoiceModelOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

VoiceModel (com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel)13 GetVoiceModelOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions)10 Test (org.junit.Test)10 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)6 UpdateVoiceModelOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.UpdateVoiceModelOptions)5 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)4 CreateVoiceModelOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions)4 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)4 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)2 ListVoiceModelsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListVoiceModelsOptions)2 VoiceModels (com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModels)2 MockResponse (okhttp3.mockwebserver.MockResponse)2 JsonObject (com.google.gson.JsonObject)1 AddWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions)1 AddWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions)1 DeleteVoiceModelOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteVoiceModelOptions)1 DeleteWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions)1 GetVoiceOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions)1 GetWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions)1 ListWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions)1