Search in sources :

Example 6 with GetWordOptions

use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetWordOptions in project java-sdk by watson-developer-cloud.

the class CustomizationsTest method testGetWord.

/**
 * Test get word.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testGetWord() throws InterruptedException {
    final Word expected = instantiateWords().get(0);
    server.enqueue(jsonResponse(ImmutableMap.of(TRANSLATION, expected.getTranslation())));
    GetWordOptions getOptions = new GetWordOptions.Builder().customizationId(CUSTOMIZATION_ID).word(expected.getWord()).build();
    final Translation result = service.getWord(getOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID) + "/" + expected.getWord(), request.getPath());
    assertEquals("GET", request.getMethod());
    assertEquals(expected.getTranslation(), result.getTranslation());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Translation(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation) Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word) GetWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 7 with GetWordOptions

use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetWordOptions in project java-sdk by watson-developer-cloud.

the class SpeechToText method getWord.

/**
 * Lists a custom word from a custom language model.
 *
 * Lists information about a custom word from a custom language model. You must use credentials for the instance of
 * the service that owns a model to query information about its words.
 *
 * @param getWordOptions the {@link GetWordOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Word}
 */
public ServiceCall<Word> getWord(GetWordOptions getWordOptions) {
    Validator.notNull(getWordOptions, "getWordOptions cannot be null");
    String[] pathSegments = { "v1/customizations", "words" };
    String[] pathParameters = { getWordOptions.customizationId(), getWordOptions.wordName() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Word.class));
}
Also used : Word(com.ibm.watson.developer_cloud.speech_to_text.v1.model.Word) RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder)

Aggregations

GetWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions)4 Translation (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation)4 Word (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)4 Test (org.junit.Test)4 Word (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Word)3 AddWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 GetWordOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetWordOptions)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 CustomWord (com.ibm.watson.developer_cloud.speech_to_text.v1.model.CustomWord)1 AddWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions)1 CreateVoiceModelOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions)1 DeleteVoiceModelOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteVoiceModelOptions)1 DeleteWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions)1 ListVoiceModelsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListVoiceModelsOptions)1 ListWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions)1