use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.TrainAcousticModelOptions in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testTrainAcousticModelWOptions.
// Test the trainAcousticModel operation with a valid options model parameter
@Test
public void testTrainAcousticModelWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"warnings\": [{\"code\": \"invalid_audio_files\", \"message\": \"message\"}]}";
String trainAcousticModelPath = "/v1/acoustic_customizations/testString/train";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the TrainAcousticModelOptions model
TrainAcousticModelOptions trainAcousticModelOptionsModel = new TrainAcousticModelOptions.Builder().customizationId("testString").customLanguageModelId("testString").build();
// Invoke trainAcousticModel() with a valid options model and verify the result
Response<TrainingResponse> response = speechToTextService.trainAcousticModel(trainAcousticModelOptionsModel).execute();
assertNotNull(response);
TrainingResponse 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, trainAcousticModelPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("custom_language_model_id"), "testString");
}
use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.TrainAcousticModelOptions in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testTrainAcousticModel.
/**
* Test train acoustic model.
*
* @throws InterruptedException the interrupted exception
* @throws FileNotFoundException the file not found exception
*/
@Test
public void testTrainAcousticModel() throws InterruptedException, FileNotFoundException {
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
String id = "foo";
String languageModelId = "bar";
TrainAcousticModelOptions trainOptions = new TrainAcousticModelOptions.Builder().customizationId(id).customLanguageModelId(languageModelId).build();
service.trainAcousticModel(trainOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals("POST", request.getMethod());
assertEquals(String.format(PATH_ACOUSTIC_TRAIN, id) + "?custom_language_model_id=bar", request.getPath());
}
Aggregations