use of com.ibm.watson.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.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().getResult();
assertNotNull(voice);
assertNotNull(voice.getDescription());
assertNotNull(voice.getGender());
assertNotNull(voice.getLanguage());
assertNotNull(voice.getName());
assertNotNull(voice.getUrl());
}
use of com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testGetVoiceWOptions.
// Test the getVoice operation with a valid options model parameter
@Test
public void testGetVoiceWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"url\": \"url\", \"gender\": \"gender\", \"name\": \"name\", \"language\": \"language\", \"description\": \"description\", \"customizable\": true, \"supported_features\": {\"custom_pronunciation\": false, \"voice_transformation\": false}, \"customization\": {\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}], \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}}";
String getVoicePath = "/v1/voices/ar-AR_OmarVoice";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetVoiceOptions model
GetVoiceOptions getVoiceOptionsModel = new GetVoiceOptions.Builder().voice("ar-AR_OmarVoice").customizationId("testString").build();
// Invoke getVoice() with a valid options model and verify the result
Response<Voice> response = textToSpeechService.getVoice(getVoiceOptionsModel).execute();
assertNotNull(response);
Voice responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getVoicePath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("customization_id"), "testString");
}
use of com.ibm.watson.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.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());
}
Aggregations