use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel in project java-sdk by watson-developer-cloud.
the class TextToSpeech method createVoiceModel.
/**
* Creates a new custom voice model.
*
* Creates a new empty custom voice model. The model is owned by the instance of the service whose credentials are
* used to create it. **Note:** This method is currently a beta release.
*
* @param createVoiceModelOptions the {@link CreateVoiceModelOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link VoiceModel}
*/
public ServiceCall<VoiceModel> createVoiceModel(CreateVoiceModelOptions createVoiceModelOptions) {
Validator.notNull(createVoiceModelOptions, "createVoiceModelOptions cannot be null");
String[] pathSegments = { "v1/customizations" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", createVoiceModelOptions.name());
if (createVoiceModelOptions.language() != null) {
contentJson.addProperty("language", createVoiceModelOptions.language());
}
if (createVoiceModelOptions.description() != null) {
contentJson.addProperty("description", createVoiceModelOptions.description());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModel.class));
}
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 testListModelsAfterCreate.
/**
* Test list models after create.
*/
@Test
public void testListModelsAfterCreate() {
model = createVoiceModel();
ListVoiceModelsOptions listOptions = new ListVoiceModelsOptions.Builder().language(model.getLanguage()).build();
final VoiceModels models = service.listVoiceModels(listOptions).execute();
VoiceModel model2 = null;
for (VoiceModel m : models.getCustomizations()) {
if (m.getCustomizationId().equals(model.getCustomizationId())) {
model2 = m;
break;
}
}
assertNotNull(model2);
assertModelsEqual(model, model2);
}
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 assertModelsEqual.
private void assertModelsEqual(VoiceModel a, VoiceModel b) {
assertEquals(a.getCustomizationId(), b.getCustomizationId());
GetVoiceModelOptions getOptionsA = new GetVoiceModelOptions.Builder().customizationId(a.getCustomizationId()).build();
assertEquals((service.getVoiceModel(getOptionsA).execute()).getName(), b.getName());
assertEquals((service.getVoiceModel(getOptionsA).execute()).getLanguage(), b.getLanguage());
}
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 testGetVoiceModelObject.
/**
* Test get voice model.
*/
@Test
public void testGetVoiceModelObject() {
model = createVoiceModel();
GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder().customizationId(model.getCustomizationId()).build();
final VoiceModel model2 = service.getVoiceModel(getOptions).execute();
assertNotNull(model2);
assertModelsEqual(model, model2);
assertNotNull(model2.getOwner());
assertNotNull(model2.getCreated());
assertNotNull(model2.getLastModified());
}
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 testGetVoiceModel.
/**
* Test get voice model.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testGetVoiceModel() throws InterruptedException {
// Test with customization ID
server.enqueue(jsonResponse(voiceModelWords));
GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder().customizationId(CUSTOMIZATION_ID).build();
VoiceModel result = service.getVoiceModel(getOptions).execute();
RecordedRequest request = server.takeRequest();
assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), request.getPath());
assertEquals("GET", request.getMethod());
assertEquals(voiceModelWords, result);
assertNotNull(voiceModelWords.getWords());
assertEquals(voiceModelWords.getWords(), result.getWords());
}
Aggregations