Search in sources :

Example 41 with Words

use of com.ibm.watson.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.

the class SpeechToTextIT method testListWordsCustomizationId.

/**
 * Test list words with just a customization ID.
 */
@Test
@Ignore
public void testListWordsCustomizationId() {
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(customizationId).build();
    Words result = service.listWords(listOptions).execute().getResult();
    assertNotNull(result);
    assertTrue(!result.getWords().isEmpty());
}
Also used : Words(com.ibm.watson.speech_to_text.v1.model.Words) ListWordsOptions(com.ibm.watson.speech_to_text.v1.model.ListWordsOptions) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 42 with Words

use of com.ibm.watson.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.

the class TextToSpeechTest method testDeleteWordWOptions.

// Test the deleteWord operation with a valid options model parameter
@Test
public void testDeleteWordWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "";
    String deleteWordPath = "/v1/customizations/testString/words/testString";
    server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody));
    // Construct an instance of the DeleteWordOptions model
    DeleteWordOptions deleteWordOptionsModel = new DeleteWordOptions.Builder().customizationId("testString").word("testString").build();
    // Invoke deleteWord() with a valid options model and verify the result
    Response<Void> response = textToSpeechService.deleteWord(deleteWordOptionsModel).execute();
    assertNotNull(response);
    Void responseObj = response.getResult();
    assertNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "DELETE");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, deleteWordPath);
    // Verify that there is no query string
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteWordOptions(com.ibm.watson.text_to_speech.v1.model.DeleteWordOptions) Test(org.testng.annotations.Test)

Example 43 with Words

use of com.ibm.watson.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.

the class TextToSpeechTest method testListVoicesWOptions.

// Test the listVoices operation with a valid options model parameter
@Test
public void testListVoicesWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"voices\": [{\"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 listVoicesPath = "/v1/voices";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    // Construct an instance of the ListVoicesOptions model
    ListVoicesOptions listVoicesOptionsModel = new ListVoicesOptions();
    // Invoke listVoices() with a valid options model and verify the result
    Response<Voices> response = textToSpeechService.listVoices(listVoicesOptionsModel).execute();
    assertNotNull(response);
    Voices 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, listVoicesPath);
    // Verify that there is no query string
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) ListVoicesOptions(com.ibm.watson.text_to_speech.v1.model.ListVoicesOptions) Voices(com.ibm.watson.text_to_speech.v1.model.Voices) Test(org.testng.annotations.Test)

Example 44 with Words

use of com.ibm.watson.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.

the class TextToSpeechTest method testCreateCustomModelWOptions.

// Test the createCustomModel operation with a valid options model parameter
@Test
public void testCreateCustomModelWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"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 createCustomModelPath = "/v1/customizations";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
    // Construct an instance of the CreateCustomModelOptions model
    CreateCustomModelOptions createCustomModelOptionsModel = new CreateCustomModelOptions.Builder().name("testString").language("en-US").description("testString").build();
    // Invoke createCustomModel() with a valid options model and verify the result
    Response<CustomModel> response = textToSpeechService.createCustomModel(createCustomModelOptionsModel).execute();
    assertNotNull(response);
    CustomModel 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(), "POST");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, createCustomModelPath);
    // Verify that there is no query string
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) CreateCustomModelOptions(com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions) CustomModel(com.ibm.watson.text_to_speech.v1.model.CustomModel) Test(org.testng.annotations.Test)

Example 45 with Words

use of com.ibm.watson.text_to_speech.v1.model.Words in project java-sdk by watson-developer-cloud.

the class TextToSpeechTest method testUpdateCustomModelWOptions.

// Test the updateCustomModel operation with a valid options model parameter
@Test
public void testUpdateCustomModelWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "";
    String updateCustomModelPath = "/v1/customizations/testString";
    server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody));
    // Construct an instance of the Word model
    Word wordModel = new Word.Builder().word("testString").translation("testString").partOfSpeech("Dosi").build();
    // Construct an instance of the UpdateCustomModelOptions model
    UpdateCustomModelOptions updateCustomModelOptionsModel = new UpdateCustomModelOptions.Builder().customizationId("testString").name("testString").description("testString").words(new java.util.ArrayList<Word>(java.util.Arrays.asList(wordModel))).build();
    // Invoke updateCustomModel() with a valid options model and verify the result
    Response<Void> response = textToSpeechService.updateCustomModel(updateCustomModelOptionsModel).execute();
    assertNotNull(response);
    Void responseObj = response.getResult();
    assertNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "POST");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, updateCustomModelPath);
    // Verify that there is no query string
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Word(com.ibm.watson.text_to_speech.v1.model.Word) UpdateCustomModelOptions(com.ibm.watson.text_to_speech.v1.model.UpdateCustomModelOptions) Test(org.testng.annotations.Test)

Aggregations

Test (org.junit.Test)22 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)17 MockResponse (okhttp3.mockwebserver.MockResponse)16 Words (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words)12 Test (org.testng.annotations.Test)12 ListWordsOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions)11 Ignore (org.junit.Ignore)11 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)10 Words (com.ibm.watson.speech_to_text.v1.model.Words)9 ListWordsOptions (com.ibm.watson.speech_to_text.v1.model.ListWordsOptions)8 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)7 Words (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words)7 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)6 ListWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions)6 Word (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)6 File (java.io.File)6 JsonObject (com.google.gson.JsonObject)5 JsonParser (com.google.gson.JsonParser)5 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)4 CustomModel (com.ibm.watson.text_to_speech.v1.model.CustomModel)4