use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeech method getVoice.
/**
* Retrieves a specific voice available for speech synthesis.
*
* Lists information about the voice specified with the `voice` path parameter. Specify the `customization_id` query
* parameter to obtain information for that custom voice model of the specified voice. Use the `GET /v1/voices` method
* to see a list of all available voices.
*
* @param getVoiceOptions the {@link GetVoiceOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Voice}
*/
public ServiceCall<Voice> getVoice(GetVoiceOptions getVoiceOptions) {
Validator.notNull(getVoiceOptions, "getVoiceOptions cannot be null");
String[] pathSegments = { "v1/voices" };
String[] pathParameters = { getVoiceOptions.voice() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
if (getVoiceOptions.customizationId() != null) {
builder.query("customization_id", getVoiceOptions.customizationId());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voice.class));
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions in project java-sdk by watson-developer-cloud.
the class CustomizationsTest method testGetVoiceCustomization.
/**
* Test get voice with custom voice model.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testGetVoiceCustomization() throws InterruptedException {
server.enqueue(jsonResponse(voice));
GetVoiceOptions getOptions = new GetVoiceOptions.Builder().voice("en-US_TestMaleVoice").customizationId("cafebabe-1234-5678-9abc-def012345678").build();
final Voice result = service.getVoice(getOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(VOICES_PATH + "/en-US_TestMaleVoice?customization_id=" + CUSTOMIZATION_ID, request.getPath());
assertEquals("GET", request.getMethod());
assertEquals(voice, result);
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions in project java-sdk by watson-developer-cloud.
the class CustomizationsIT method testGetVoiceCustomization.
/**
* Test get voice with customization.
*/
@Test
public void testGetVoiceCustomization() {
model = createVoiceModel();
GetVoiceModelOptions getVoiceModelOptions = new GetVoiceModelOptions.Builder().customizationId(model.getCustomizationId()).build();
final VoiceModel model2 = service.getVoiceModel(getVoiceModelOptions).execute();
GetVoiceOptions getVoiceOptions = new GetVoiceOptions.Builder().customizationId(model.getCustomizationId()).voice(GetVoiceOptions.Voice.EN_US_ALLISONVOICE).build();
final Voice voice = service.getVoice(getVoiceOptions).execute();
assertNotNull(model);
assertNotNull(model2);
assertNotNull(voice);
assertEquals(model2.getCustomizationId(), voice.getCustomization().getCustomizationId());
assertEquals(model2.getName(), voice.getCustomization().getName());
assertEquals(model2.getDescription(), voice.getCustomization().getDescription());
assertEquals(model2.getLanguage(), voice.getCustomization().getLanguage());
assertEquals(model2.getOwner(), voice.getCustomization().getOwner());
assertEquals(model2.getCreated(), voice.getCustomization().getCreated());
assertEquals(model2.getLastModified(), voice.getCustomization().getLastModified());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeechIT method testGetVoice.
/**
* Test get voice.
*/
@Test
public void testGetVoice() {
GetVoiceOptions getOptions = new GetVoiceOptions.Builder().voice(voiceName).build();
Voice voice = service.getVoice(getOptions).execute();
assertNotNull(voice);
assertNotNull(voice.getDescription());
assertNotNull(voice.getGender());
assertNotNull(voice.getLanguage());
assertNotNull(voice.getName());
assertNotNull(voice.getUrl());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testGetVoice.
/**
* Test get voice.
*/
@Test
public void testGetVoice() {
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(getVoiceResponse)));
GetVoiceOptions getOptions = new GetVoiceOptions.Builder().voice("en-US_TestMaleVoice").build();
Voice result = service.getVoice(getOptions).execute();
assertNotNull(result);
assertEquals(result, getVoiceResponse);
try {
TestUtils.assertNoExceptionsOnGetters(result);
} catch (final Exception e) {
Assert.fail(e.getMessage());
}
}
Aggregations