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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations