use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.
the class CustomizationsIT method testAddWords.
/**
* Test add words and list words.
*/
@Test
public void testAddWords() {
model = createVoiceModel();
final List<Word> expected = instantiateWords();
AddWordsOptions addOptions = new AddWordsOptions.Builder().customizationId(model.getCustomizationId()).words(expected).build();
service.addWords(addOptions).execute();
ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build();
final Words words = service.listWords(listOptions).execute();
assertEquals(expected.size(), words.getWords().size());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words 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());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.
the class CustomizationsIT method testGetWordJapanese.
/**
* Test get word for Japanese.
*/
@Test
public void testGetWordJapanese() {
model = createVoiceModelJapanese();
final List<Word> expected = instantiateWordsJapanese();
AddWordsOptions addOptions = new AddWordsOptions.Builder().customizationId(model.getCustomizationId()).words(expected).build();
service.addWords(addOptions).execute();
GetWordOptions getOptions = new GetWordOptions.Builder().customizationId(model.getCustomizationId()).word(expected.get(0).getWord()).build();
final Translation translation = service.getWord(getOptions).execute();
assertEquals(expected.get(0).getTranslation(), translation.getTranslation());
assertEquals(expected.get(0).getPartOfSpeech(), translation.getPartOfSpeech());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words 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());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.
the class CustomizationsTest method testAddWords.
/**
* Test add words.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testAddWords() throws InterruptedException {
final List<Word> expected = instantiateWords();
server.enqueue(new MockResponse().setResponseCode(201));
AddWordsOptions addOptions = new AddWordsOptions.Builder().customizationId(CUSTOMIZATION_ID).words(expected).build();
service.addWords(addOptions).execute();
RecordedRequest request = server.takeRequest();
assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID), request.getPath());
assertEquals("POST", request.getMethod());
}
Aggregations