use of com.ibm.watson.text_to_speech.v1.model.ListWordsOptions in project java-sdk by watson-developer-cloud.
the class CustomizationsTest method testListWords.
/**
* Test list words.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testListWords() throws InterruptedException {
final List<Word> expected = instantiateWords();
server.enqueue(jsonResponse(ImmutableMap.of(WORDS, expected)));
ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(CUSTOMIZATION_ID).build();
final Words result = service.listWords(listOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID), request.getPath());
assertEquals("GET", request.getMethod());
assertEquals(expected, result.getWords());
}
use of com.ibm.watson.text_to_speech.v1.model.ListWordsOptions in project java-sdk by watson-developer-cloud.
the class SpeechToTextIT method testListWordsCustomizationId.
/**
* Test list words with just a customization ID.
*/
@Test
@Ignore
public void testListWordsCustomizationId() {
ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(customizationId).build();
Words result = service.listWords(listOptions).execute().getResult();
assertNotNull(result);
assertTrue(!result.getWords().isEmpty());
}
use of com.ibm.watson.text_to_speech.v1.model.ListWordsOptions in project java-sdk by watson-developer-cloud.
the class TextToSpeech method listWords.
/**
* List custom words.
*
* <p>Lists all of the words and their translations for the specified custom model. The output
* shows the translations as they are defined in the model. You must use credentials for the
* instance of the service that owns a model to list its words.
*
* <p>**See also:** [Querying all words from a custom
* model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryModel).
*
* @param listWordsOptions the {@link ListWordsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Words}
*/
public ServiceCall<Words> listWords(ListWordsOptions listWordsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listWordsOptions, "listWordsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("customization_id", listWordsOptions.customizationId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listWords");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Words> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Words>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations