Search in sources :

Example 1 with GetVoiceOptions

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Voice(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice) GetVoiceOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 2 with GetVoiceOptions

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());
}
Also used : Voice(com.ibm.watson.text_to_speech.v1.model.Voice) GetVoiceOptions(com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 3 with GetVoiceOptions

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");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Voice(com.ibm.watson.text_to_speech.v1.model.Voice) GetVoiceOptions(com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions) Test(org.testng.annotations.Test)

Example 4 with GetVoiceOptions

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());
}
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) Voice(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice) GetVoiceOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 5 with GetVoiceOptions

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());
}
Also used : Voice(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice) GetVoiceOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Aggregations

Test (org.junit.Test)5 GetVoiceOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions)4 Voice (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice)4 Voice (com.ibm.watson.text_to_speech.v1.model.Voice)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 GetVoiceOptions (com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions)2 MockResponse (okhttp3.mockwebserver.MockResponse)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)1 GetVoiceModelOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions)1 VoiceModel (com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)1 Test (org.testng.annotations.Test)1