Search in sources :

Example 1 with DeleteAudioOptions

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

the class SpeechToTextIT method testAddAudioArchive.

/**
 * Test add audio with an archive file.
 *
 * @throws FileNotFoundException the file not found exception
 */
@Test
public void testAddAudioArchive() throws FileNotFoundException, InterruptedException {
    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();
    String audioName = "test-archive";
    File audio = new File(WAV_ARCHIVE);
    AddAudioOptions addOptions = new AddAudioOptions.Builder().customizationId(id).audioName(audioName).contentType(AddAudioOptions.ContentType.APPLICATION_ZIP).containedContentType(AddAudioOptions.ContainedContentType.AUDIO_WAV).audioResource(audio).build();
    service.addAudio(addOptions).execute();
    try {
        GetAudioOptions getOptions = new GetAudioOptions.Builder().customizationId(id).audioName(audioName).build();
        AudioListing listing = service.getAudio(getOptions).execute();
        assertNotNull(listing);
        assertEquals(audioName, listing.getName());
    } finally {
        DeleteAudioOptions deleteAudioOptions = new DeleteAudioOptions.Builder().customizationId(id).audioName(audioName).build();
        service.deleteAudio(deleteAudioOptions).execute();
        GetAcousticModelOptions getOptions = new GetAcousticModelOptions.Builder().customizationId(id).build();
        for (int x = 0; x < 30 && !service.getAcousticModel(getOptions).execute().getStatus().equals(AcousticModel.Status.AVAILABLE); x++) {
            Thread.sleep(5000);
        }
        DeleteAcousticModelOptions deleteAcousticModelOptions = new DeleteAcousticModelOptions.Builder().customizationId(id).build();
        service.deleteAcousticModel(deleteAcousticModelOptions).execute();
    }
}
Also used : GetAcousticModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAcousticModelOptions) AcousticModel(com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModel) AddAudioOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddAudioOptions) CreateAcousticModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateAcousticModelOptions) GetAudioOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAudioOptions) DeleteAudioOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAudioOptions) DeleteAcousticModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAcousticModelOptions) AudioListing(com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioListing) File(java.io.File) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 2 with DeleteAudioOptions

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

the class SpeechToTextTest method testDeleteAudio.

@Test
public void testDeleteAudio() throws InterruptedException {
    String id = "foo";
    String audioName = "audio1";
    server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
    DeleteAudioOptions deleteOptions = new DeleteAudioOptions.Builder().customizationId(id).audioName(audioName).build();
    service.deleteAudio(deleteOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals("DELETE", request.getMethod());
    assertEquals(String.format(PATH_SPECIFIC_AUDIO, id, audioName), request.getPath());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteAudioOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAudioOptions) ByteString(okio.ByteString) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 3 with DeleteAudioOptions

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

the class SpeechToTextIT method testGetAudio.

/**
 * Test get audio.
 *
 * This test is currently being ignored as it has a very long runtime and causes Travis to timeout.
 * The ignore annotation can be removed to test this locally.
 *
 * @throws InterruptedException the interrupted exception
 */
@Ignore
@Test
public void testGetAudio() throws InterruptedException, FileNotFoundException {
    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();
    String audioName = "sample";
    AddAudioOptions addOptions = new AddAudioOptions.Builder().audioResource(new File(SAMPLE_WAV)).contentType(AddAudioOptions.ContentType.AUDIO_WAV).audioName(audioName).customizationId(id).allowOverwrite(true).build();
    service.addAudio(addOptions).execute();
    try {
        GetAudioOptions getOptions = new GetAudioOptions.Builder().customizationId(id).audioName(audioName).build();
        AudioListing audio = service.getAudio(getOptions).execute();
        assertNotNull(audio);
        assertEquals(audioName, audio.getName());
    } finally {
        DeleteAudioOptions deleteAudioOptions = new DeleteAudioOptions.Builder().customizationId(id).audioName(audioName).build();
        service.deleteAudio(deleteAudioOptions).execute();
        GetAcousticModelOptions getOptions = new GetAcousticModelOptions.Builder().customizationId(id).build();
        for (int x = 0; x < 30 && !service.getAcousticModel(getOptions).execute().getStatus().equals(AcousticModel.Status.AVAILABLE); x++) {
            Thread.sleep(5000);
        }
        DeleteAcousticModelOptions deleteAcousticModelOptions = new DeleteAcousticModelOptions.Builder().customizationId(id).build();
        service.deleteAcousticModel(deleteAcousticModelOptions).execute();
    }
}
Also used : GetAcousticModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAcousticModelOptions) AcousticModel(com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModel) AddAudioOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddAudioOptions) CreateAcousticModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateAcousticModelOptions) GetAudioOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAudioOptions) DeleteAudioOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAudioOptions) DeleteAcousticModelOptions(com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAcousticModelOptions) AudioListing(com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioListing) File(java.io.File) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Aggregations

DeleteAudioOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAudioOptions)3 Test (org.junit.Test)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 AcousticModel (com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModel)2 AddAudioOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddAudioOptions)2 AudioListing (com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioListing)2 CreateAcousticModelOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateAcousticModelOptions)2 DeleteAcousticModelOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAcousticModelOptions)2 GetAcousticModelOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAcousticModelOptions)2 GetAudioOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAudioOptions)2 File (java.io.File)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 ByteString (okio.ByteString)1 Ignore (org.junit.Ignore)1