use of com.ibm.watson.text_to_speech.v1.model.ListVoicesOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeech method listVoices.
/**
* List voices.
*
* <p>Lists all voices available for use with the service. The information includes the name,
* language, gender, and other details about the voice. The ordering of the list of voices can
* change from call to call; do not rely on an alphabetized or static list of voices. To see
* information about a specific voice, use the [Get a voice](#getvoice).
*
* <p>**See also:** [Listing all available
* voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoices).
*
* @param listVoicesOptions the {@link ListVoicesOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Voices}
*/
public ServiceCall<Voices> listVoices(ListVoicesOptions listVoicesOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/voices"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoices");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Voices> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Voices>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.text_to_speech.v1.model.ListVoicesOptions 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);
}
Aggregations