Search in sources :

Example 1 with ListCustomPromptsOptions

use of com.ibm.watson.text_to_speech.v1.model.ListCustomPromptsOptions 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();
}
Also used : ListCustomPromptsOptions(com.ibm.watson.text_to_speech.v1.model.ListCustomPromptsOptions) CreateCustomModelOptions(com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions) Prompts(com.ibm.watson.text_to_speech.v1.model.Prompts) DeleteCustomModelOptions(com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions) CustomModel(com.ibm.watson.text_to_speech.v1.model.CustomModel) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 2 with ListCustomPromptsOptions

use of com.ibm.watson.text_to_speech.v1.model.ListCustomPromptsOptions 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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Prompts(com.ibm.watson.text_to_speech.v1.model.Prompts)

Example 3 with ListCustomPromptsOptions

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

the class TextToSpeechTest method testListCustomPromptsWOptions.

// Test the listCustomPrompts operation with a valid options model parameter
@Test
public void testListCustomPromptsWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\", \"speaker_id\": \"speakerId\"}]}";
    String listCustomPromptsPath = "/v1/customizations/testString/prompts";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    // Construct an instance of the ListCustomPromptsOptions model
    ListCustomPromptsOptions listCustomPromptsOptionsModel = new ListCustomPromptsOptions.Builder().customizationId("testString").build();
    // Invoke listCustomPrompts() with a valid options model and verify the result
    Response<Prompts> response = textToSpeechService.listCustomPrompts(listCustomPromptsOptionsModel).execute();
    assertNotNull(response);
    Prompts 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, listCustomPromptsPath);
    // 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) ListCustomPromptsOptions(com.ibm.watson.text_to_speech.v1.model.ListCustomPromptsOptions) Prompts(com.ibm.watson.text_to_speech.v1.model.Prompts) Test(org.testng.annotations.Test)

Aggregations

Prompts (com.ibm.watson.text_to_speech.v1.model.Prompts)3 ListCustomPromptsOptions (com.ibm.watson.text_to_speech.v1.model.ListCustomPromptsOptions)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)1 CreateCustomModelOptions (com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions)1 CustomModel (com.ibm.watson.text_to_speech.v1.model.CustomModel)1 DeleteCustomModelOptions (com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions)1 HashMap (java.util.HashMap)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1