use of com.ibm.watson.text_to_speech.v1.model.GetSpeakerModelOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeechIT method testGetSpeakerModel.
/**
* Test getSpeakerModel.
*/
@Test
public void testGetSpeakerModel() {
try {
CreateSpeakerModelOptions createSpeakerModelOptions = new CreateSpeakerModelOptions.Builder().speakerName("speakerName").audio(new File(RESOURCE + "numbers.wav")).build();
SpeakerModel speakerModel = service.createSpeakerModel(createSpeakerModelOptions).execute().getResult();
speakerId = speakerModel.getSpeakerId();
assertNotNull(speakerModel.getSpeakerId());
GetSpeakerModelOptions getSpeakerModelOptions = new GetSpeakerModelOptions.Builder().speakerId(speakerId).build();
SpeakerCustomModels speakerCustomModels = service.getSpeakerModel(getSpeakerModelOptions).execute().getResult();
assertNotNull(speakerCustomModels.getCustomizations());
} catch (Exception e) {
e.printStackTrace();
} finally {
DeleteSpeakerModelOptions deleteSpeakerModelOptions = new DeleteSpeakerModelOptions.Builder().speakerId(speakerId).build();
service.deleteSpeakerModel(deleteSpeakerModelOptions).execute().getResult();
}
}
use of com.ibm.watson.text_to_speech.v1.model.GetSpeakerModelOptions 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.GetSpeakerModelOptions 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