use of com.ibm.watson.speech_to_text.v1.model.LanguageModel in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testGetLanguageModelWOptions.
// Test the getLanguageModel operation with a valid options model parameter
@Test
public void testGetLanguageModelWOptions() 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 getLanguageModelPath = "/v1/customizations/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetLanguageModelOptions model
GetLanguageModelOptions getLanguageModelOptionsModel = new GetLanguageModelOptions.Builder().customizationId("testString").build();
// Invoke getLanguageModel() with a valid options model and verify the result
Response<LanguageModel> response = speechToTextService.getLanguageModel(getLanguageModelOptionsModel).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(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getLanguageModelPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.watson.speech_to_text.v1.model.LanguageModel 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);
}
use of com.ibm.watson.speech_to_text.v1.model.LanguageModel 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());
}
use of com.ibm.watson.speech_to_text.v1.model.LanguageModel in project java-sdk by watson-developer-cloud.
the class SpeechToTextIT method isCustomizationReady.
private boolean isCustomizationReady(String customizationId) {
GetLanguageModelOptions getLanguageModelOptions = new GetLanguageModelOptions.Builder().customizationId(customizationId).build();
LanguageModel model = service.getLanguageModel(getLanguageModelOptions).execute().getResult();
return model.getStatus().equals(LanguageModel.Status.READY) || model.getStatus().equals(LanguageModel.Status.AVAILABLE);
}
Aggregations