Search in sources :

Example 6 with CreateLanguageModelOptions

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

the class SpeechToTextTest method testCreateLanguageModelWOptions.

// Test the createLanguageModel operation with a valid options model parameter
@Test
public void testCreateLanguageModelWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"dialect\": \"dialect\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"error\": \"error\", \"warnings\": \"warnings\"}";
    String createLanguageModelPath = "/v1/customizations";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
    // Construct an instance of the CreateLanguageModelOptions model
    CreateLanguageModelOptions createLanguageModelOptionsModel = new CreateLanguageModelOptions.Builder().name("testString").baseModelName("ar-MS_Telephony").dialect("testString").description("testString").build();
    // Invoke createLanguageModel() with a valid options model and verify the result
    Response<LanguageModel> response = speechToTextService.createLanguageModel(createLanguageModelOptionsModel).execute();
    assertNotNull(response);
    LanguageModel 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(), "POST");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, createLanguageModelPath);
    // Verify that there is no query string
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) CreateLanguageModelOptions(com.ibm.watson.speech_to_text.v1.model.CreateLanguageModelOptions) LanguageModel(com.ibm.watson.speech_to_text.v1.model.LanguageModel) Test(org.testng.annotations.Test)

Example 7 with CreateLanguageModelOptions

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

the class SpeechToTextTest method testCreateLanguageModel.

/**
 * Test create language model.
 *
 * @throws InterruptedException the interrupted exception
 * @throws FileNotFoundException the file not found exception
 */
@Test
public void testCreateLanguageModel() throws InterruptedException, FileNotFoundException {
    LanguageModel model = loadFixture("src/test/resources/speech_to_text/customization.json", LanguageModel.class);
    server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(model)));
    CreateLanguageModelOptions createOptions = new CreateLanguageModelOptions.Builder().name(model.getName()).baseModelName("en-GB_BroadbandModel").description(model.getDescription()).build();
    LanguageModel result = service.createLanguageModel(createOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals("POST", request.getMethod());
    assertEquals(PATH_CUSTOMIZATIONS, request.getPath());
    assertEquals(result.toString(), model.toString());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) CreateLanguageModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateLanguageModelOptions) LanguageModel(com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModel) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

LanguageModel (com.ibm.watson.speech_to_text.v1.model.LanguageModel)4 File (java.io.File)4 CreateLanguageModelOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateLanguageModelOptions)3 LanguageModel (com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModel)3 CreateLanguageModelOptions (com.ibm.watson.speech_to_text.v1.model.CreateLanguageModelOptions)3 Test (org.junit.Test)3 AddCorpusOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddCorpusOptions)2 AddWordOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordOptions)2 Corpora (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpora)2 DeleteLanguageModelOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteLanguageModelOptions)2 GetCorpusOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetCorpusOptions)2 ListCorporaOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListCorporaOptions)2 ListWordsOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions)2 Words (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words)2 AddCorpusOptions (com.ibm.watson.speech_to_text.v1.model.AddCorpusOptions)2 AddWordOptions (com.ibm.watson.speech_to_text.v1.model.AddWordOptions)2 Corpora (com.ibm.watson.speech_to_text.v1.model.Corpora)2 DeleteLanguageModelOptions (com.ibm.watson.speech_to_text.v1.model.DeleteLanguageModelOptions)2 GetCorpusOptions (com.ibm.watson.speech_to_text.v1.model.GetCorpusOptions)2 ListCorporaOptions (com.ibm.watson.speech_to_text.v1.model.ListCorporaOptions)2