use of com.ibm.watson.text_to_speech.v1.model.Speakers in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testListSpeakerModelsWOptions.
// Test the listSpeakerModels operation with a valid options model parameter
@Test
public void testListSpeakerModelsWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"speakers\": [{\"speaker_id\": \"speakerId\", \"name\": \"name\"}]}";
String listSpeakerModelsPath = "/v1/speakers";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListSpeakerModelsOptions model
ListSpeakerModelsOptions listSpeakerModelsOptionsModel = new ListSpeakerModelsOptions();
// Invoke listSpeakerModels() with a valid options model and verify the result
Response<Speakers> response = textToSpeechService.listSpeakerModels(listSpeakerModelsOptionsModel).execute();
assertNotNull(response);
Speakers 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, listSpeakerModelsPath);
// 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.Speakers 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.Speakers in project java-sdk by watson-developer-cloud.
the class TextToSpeech method getSpeakerModel.
/**
* Get a speaker model.
*
* <p>Gets information about all prompts that are defined by a specified speaker for all custom
* models that are owned by a service instance. The information is grouped by the customization
* IDs of the custom models. For each custom model, the information lists information about each
* prompt that is defined for that custom model by the speaker. You must use credentials for the
* instance of the service that owns a speaker model to list its prompts. 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 the custom prompts for a speaker
* model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-tbe-speaker-models#tbe-speaker-models-list-prompts).
*
* @param getSpeakerModelOptions the {@link GetSpeakerModelOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link SpeakerCustomModels}
*/
public ServiceCall<SpeakerCustomModels> getSpeakerModel(GetSpeakerModelOptions getSpeakerModelOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSpeakerModelOptions, "getSpeakerModelOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("speaker_id", getSpeakerModelOptions.speakerId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/speakers/{speaker_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getSpeakerModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<SpeakerCustomModels> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SpeakerCustomModels>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.text_to_speech.v1.model.Speakers in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testDeleteSpeakerModelWOptions.
// Test the deleteSpeakerModel operation with a valid options model parameter
@Test
public void testDeleteSpeakerModelWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "";
String deleteSpeakerModelPath = "/v1/speakers/testString";
server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody));
// Construct an instance of the DeleteSpeakerModelOptions model
DeleteSpeakerModelOptions deleteSpeakerModelOptionsModel = new DeleteSpeakerModelOptions.Builder().speakerId("testString").build();
// Invoke deleteSpeakerModel() with a valid options model and verify the result
Response<Void> response = textToSpeechService.deleteSpeakerModel(deleteSpeakerModelOptionsModel).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, deleteSpeakerModelPath);
// 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.Speakers in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testGetSpeakerModelWOptions.
// Test the getSpeakerModel operation with a valid options model parameter
@Test
public void testGetSpeakerModelWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"customizations\": [{\"customization_id\": \"customizationId\", \"prompts\": [{\"prompt\": \"prompt\", \"prompt_id\": \"promptId\", \"status\": \"status\", \"error\": \"error\"}]}]}";
String getSpeakerModelPath = "/v1/speakers/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetSpeakerModelOptions model
GetSpeakerModelOptions getSpeakerModelOptionsModel = new GetSpeakerModelOptions.Builder().speakerId("testString").build();
// Invoke getSpeakerModel() with a valid options model and verify the result
Response<SpeakerCustomModels> response = textToSpeechService.getSpeakerModel(getSpeakerModelOptionsModel).execute();
assertNotNull(response);
SpeakerCustomModels 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, getSpeakerModelPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
Aggregations