use of com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeechTest method testGetVoice.
/**
* Test get voice.
*/
@Test
public void testGetVoice() {
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(getVoiceResponse)));
GetVoiceOptions getOptions = new GetVoiceOptions.Builder().voice("en-US_TestMaleVoice").build();
Voice result = service.getVoice(getOptions).execute();
assertNotNull(result);
assertEquals(result, getVoiceResponse);
try {
TestUtils.assertNoExceptionsOnGetters(result);
} catch (final Exception e) {
Assert.fail(e.getMessage());
}
}
use of com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeech method getVoice.
/**
* Get a voice.
*
* <p>Gets information about the specified voice. The information includes the name, language,
* gender, and other details about the voice. Specify a customization ID to obtain information for
* a custom model that is defined for the language of the specified voice. To list information
* about all available voices, use the [List voices](#listvoices) method.
*
* <p>**See also:** [Listing a specific
* voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoice).
*
* <p>**Note:** The Arabic, Chinese, Czech, Dutch (Belgian and Netherlands), Australian English,
* Korean, and Swedish languages and voices are supported only for IBM Cloud; they are deprecated
* for IBM Cloud Pak for Data. Also, the `ar-AR_OmarVoice` voice is deprecated; use the
* `ar-MS_OmarVoice` voice instead.
*
* @param getVoiceOptions the {@link GetVoiceOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Voice}
*/
public ServiceCall<Voice> getVoice(GetVoiceOptions getVoiceOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getVoiceOptions, "getVoiceOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("voice", getVoiceOptions.voice());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/voices/{voice}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoice");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getVoiceOptions.customizationId() != null) {
builder.query("customization_id", String.valueOf(getVoiceOptions.customizationId()));
}
ResponseConverter<Voice> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Voice>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations