use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioResources in project java-sdk by watson-developer-cloud.
the class SpeechToTextIT method testListAudio.
/**
* Test list audio.
*/
@Test
public void testListAudio() {
String name = "java-sdk-temporary";
String description = "Temporary custom model for testing the Java SDK";
CreateAcousticModelOptions createOptions = new CreateAcousticModelOptions.Builder().name(name).baseModelName(EN_BROADBAND16K).description(description).build();
AcousticModel myModel = service.createAcousticModel(createOptions).execute();
String id = myModel.getCustomizationId();
try {
ListAudioOptions listOptions = new ListAudioOptions.Builder().customizationId(id).build();
AudioResources resources = service.listAudio(listOptions).execute();
assertNotNull(resources);
} finally {
DeleteAcousticModelOptions deleteAcousticModelOptions = new DeleteAcousticModelOptions.Builder().customizationId(id).build();
service.deleteAcousticModel(deleteAcousticModelOptions).execute();
}
}
use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioResources in project java-sdk by watson-developer-cloud.
the class SpeechToText method listAudio.
/**
* Lists information about all audio resources for a custom acoustic model.
*
* Lists information about all audio resources from a custom acoustic model. The information includes the name of the
* resource and information about its audio data, such as its duration. It also includes the status of the audio
* resource, which is important for checking the service's analysis of the resource in response to a request to add it
* to the custom acoustic model. You must use credentials for the instance of the service that owns a model to list
* its audio resources.
*
* @param listAudioOptions the {@link ListAudioOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link AudioResources}
*/
public ServiceCall<AudioResources> listAudio(ListAudioOptions listAudioOptions) {
Validator.notNull(listAudioOptions, "listAudioOptions cannot be null");
String[] pathSegments = { "v1/acoustic_customizations", "audio" };
String[] pathParameters = { listAudioOptions.customizationId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AudioResources.class));
}
use of com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioResources in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testListAudio.
@Test
public void testListAudio() throws FileNotFoundException, InterruptedException {
String resourcesAsString = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/audio-resources.json"));
JsonObject audioResources = new JsonParser().parse(resourcesAsString).getAsJsonObject();
String id = "foo";
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(resourcesAsString));
ListAudioOptions listOptions = new ListAudioOptions.Builder().customizationId(id).build();
AudioResources result = service.listAudio(listOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals("GET", request.getMethod());
assertEquals(String.format(PATH_ALL_AUDIO, id), request.getPath());
assertEquals(audioResources.get("audio").getAsJsonArray().size(), result.getAudio().size());
assertEquals(audioResources.get("audio"), GSON.toJsonTree(result.getAudio()));
}
Aggregations