use of com.ibm.watson.text_to_speech.v1.model.Prompts in project java-sdk by watson-developer-cloud.
the class TextToSpeechIT method testListCustomPrompts.
/**
* Test listCustomPrompts.
*/
@Test
public void testListCustomPrompts() {
CreateCustomModelOptions createCustomModelOptions = new CreateCustomModelOptions.Builder().description("testdescription").name("testname").language(CreateCustomModelOptions.Language.EN_US).build();
CustomModel customModel = service.createCustomModel(createCustomModelOptions).execute().getResult();
customizationId = customModel.getCustomizationId();
ListCustomPromptsOptions listCustomPromptsOptions = new ListCustomPromptsOptions.Builder().customizationId(customizationId).build();
Prompts prompts = service.listCustomPrompts(listCustomPromptsOptions).execute().getResult();
assertNotNull(prompts.getPrompts());
DeleteCustomModelOptions deleteCustomModelOptions = new DeleteCustomModelOptions.Builder().customizationId(customizationId).build();
service.deleteCustomModel(deleteCustomModelOptions).execute().getResult();
}
use of com.ibm.watson.text_to_speech.v1.model.Prompts 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.Prompts in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testListCustomModelsWOptions.
// Test the listCustomModels operation with a valid options model parameter
@Test
public void testListCustomModelsWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"customizations\": [{\"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 listCustomModelsPath = "/v1/customizations";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListCustomModelsOptions model
ListCustomModelsOptions listCustomModelsOptionsModel = new ListCustomModelsOptions.Builder().language("ar-MS").build();
// Invoke listCustomModels() with a valid options model and verify the result
Response<CustomModels> response = textToSpeechService.listCustomModels(listCustomModelsOptionsModel).execute();
assertNotNull(response);
CustomModels 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, listCustomModelsPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("language"), "ar-MS");
}
use of com.ibm.watson.text_to_speech.v1.model.Prompts in project java-sdk by watson-developer-cloud.
the class TextToSpeech method listSpeakerModels.
/**
* List speaker models.
*
* <p>Lists information about all speaker models that are defined for a service instance. The
* information includes the speaker ID and speaker name of each defined speaker. You must use
* credentials for the instance of a service to list its speakers. Speaker models and the custom
* prompts with which they are used are supported only for use with US English custom models and
* voices.
*
* <p>**See also:** [Listing speaker
* models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-speaker-models#tbe-speaker-models-list).
*
* @param listSpeakerModelsOptions the {@link ListSpeakerModelsOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link Speakers}
*/
public ServiceCall<Speakers> listSpeakerModels(ListSpeakerModelsOptions listSpeakerModelsOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/speakers"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listSpeakerModels");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Speakers> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Speakers>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.text_to_speech.v1.model.Prompts in project java-sdk by watson-developer-cloud.
the class TextToSpeech method listCustomPrompts.
/**
* List custom prompts.
*
* <p>Lists information about all custom prompts that are defined for a custom model. The
* information includes the prompt ID, prompt text, status, and optional speaker ID for each
* prompt of the custom model. You must use credentials for the instance of the service that owns
* the custom model. The same information about all of the prompts for a custom model is also
* provided by the [Get a custom model](#getcustommodel) method. That method provides complete
* details about a specified custom model, including its language, owner, custom words, and more.
* Custom prompts are supported only for use with US English custom models and voices.
*
* <p>**See also:** [Listing custom
* prompts](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-custom-prompts#tbe-custom-prompts-list).
*
* @param listCustomPromptsOptions the {@link ListCustomPromptsOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a result of type {@link Prompts}
*/
public ServiceCall<Prompts> listCustomPrompts(ListCustomPromptsOptions listCustomPromptsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listCustomPromptsOptions, "listCustomPromptsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("customization_id", listCustomPromptsOptions.customizationId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations/{customization_id}/prompts", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listCustomPrompts");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Prompts> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Prompts>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations