Search in sources :

Example 1 with SpeechModel

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

the class SpeechToTextIT method testGetModel.

/**
 * Test get model.
 */
@Test
public void testGetModel() {
    GetModelOptions getOptions = new GetModelOptions.Builder().modelId(EN_BROADBAND16K).build();
    SpeechModel model = service.getModel(getOptions).execute();
    assertNotNull(model);
    assertNotNull(model.getName());
    assertNotNull(model.getLanguage());
    assertNotNull(model.getRate());
    assertNotNull(model.getUrl());
    assertNotNull(model.getDescription());
    assertNotNull(model.getSessions());
    assertNotNull(model.getSupportedFeatures().isCustomLanguageModel());
    assertNotNull(model.getSupportedFeatures().isSpeakerLabels());
}
Also used : SpeechModel(com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel) GetModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 2 with SpeechModel

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

the class SpeechToTextTest method testGetModel.

/**
 * Test get model.
 *
 * @throws Exception the exception
 */
@Test
public void testGetModel() throws Exception {
    final MockResponse mockResponse = new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(speechModel));
    server.enqueue(mockResponse);
    GetModelOptions getOptionsString = new GetModelOptions.Builder().modelId("not-a-real-Model").build();
    SpeechModel model = service.getModel(getOptionsString).execute();
    RecordedRequest request = server.takeRequest();
    assertNotNull(model);
    assertEquals(model, speechModel);
    assertEquals(GET, request.getMethod());
    server.enqueue(mockResponse);
    GetModelOptions getOptionsGetter = new GetModelOptions.Builder().modelId("not-a-real-Model").build();
    model = service.getModel(getOptionsGetter).execute();
    request = server.takeRequest();
    assertNotNull(model);
    assertEquals(model, speechModel);
    assertEquals(GET, request.getMethod());
    TestUtils.assertNoExceptionsOnGetters(model);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) SpeechModel(com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel) GetModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 3 with SpeechModel

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

the class SpeechToText method getModel.

/**
 * Retrieves information about the model.
 *
 * Returns information about a single specified language model that is available for use with the service. The
 * information includes the name of the model and its minimum sampling rate in Hertz, among other things.
 *
 * @param getModelOptions the {@link GetModelOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link SpeechModel}
 */
public ServiceCall<SpeechModel> getModel(GetModelOptions getModelOptions) {
    Validator.notNull(getModelOptions, "getModelOptions cannot be null");
    String[] pathSegments = { "v1/models" };
    String[] pathParameters = { getModelOptions.modelId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(SpeechModel.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) SpeechModel(com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel)

Aggregations

SpeechModel (com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel)3 GetModelOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions)2 Test (org.junit.Test)2 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)1 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1