Search in sources :

Example 1 with DeleteSpeakerModelOptions

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

the class TextToSpeechIT method testGetSpeakerModel.

/**
 * Test getSpeakerModel.
 */
@Test
public void testGetSpeakerModel() {
    try {
        CreateSpeakerModelOptions createSpeakerModelOptions = new CreateSpeakerModelOptions.Builder().speakerName("speakerName").audio(new File(RESOURCE + "numbers.wav")).build();
        SpeakerModel speakerModel = service.createSpeakerModel(createSpeakerModelOptions).execute().getResult();
        speakerId = speakerModel.getSpeakerId();
        assertNotNull(speakerModel.getSpeakerId());
        GetSpeakerModelOptions getSpeakerModelOptions = new GetSpeakerModelOptions.Builder().speakerId(speakerId).build();
        SpeakerCustomModels speakerCustomModels = service.getSpeakerModel(getSpeakerModelOptions).execute().getResult();
        assertNotNull(speakerCustomModels.getCustomizations());
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        DeleteSpeakerModelOptions deleteSpeakerModelOptions = new DeleteSpeakerModelOptions.Builder().speakerId(speakerId).build();
        service.deleteSpeakerModel(deleteSpeakerModelOptions).execute().getResult();
    }
}
Also used : DeleteSpeakerModelOptions(com.ibm.watson.text_to_speech.v1.model.DeleteSpeakerModelOptions) SpeakerModel(com.ibm.watson.text_to_speech.v1.model.SpeakerModel) CreateSpeakerModelOptions(com.ibm.watson.text_to_speech.v1.model.CreateSpeakerModelOptions) GetSpeakerModelOptions(com.ibm.watson.text_to_speech.v1.model.GetSpeakerModelOptions) File(java.io.File) SpeakerCustomModels(com.ibm.watson.text_to_speech.v1.model.SpeakerCustomModels) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) IOException(java.io.IOException) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 2 with DeleteSpeakerModelOptions

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

the class TextToSpeechIT method testCreateSpeakerModel.

/**
 * Test createSpeakerModel.
 */
@Test
public void testCreateSpeakerModel() {
    try {
        CreateSpeakerModelOptions createSpeakerModelOptions = new CreateSpeakerModelOptions.Builder().speakerName("speakerName").audio(new File(RESOURCE + "numbers.wav")).build();
        SpeakerModel speakerModel = service.createSpeakerModel(createSpeakerModelOptions).execute().getResult();
        speakerId = speakerModel.getSpeakerId();
        assertNotNull(speakerModel.getSpeakerId());
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        DeleteSpeakerModelOptions deleteSpeakerModelOptions = new DeleteSpeakerModelOptions.Builder().speakerId(speakerId).build();
        service.deleteSpeakerModel(deleteSpeakerModelOptions).execute().getResult();
    }
}
Also used : DeleteSpeakerModelOptions(com.ibm.watson.text_to_speech.v1.model.DeleteSpeakerModelOptions) SpeakerModel(com.ibm.watson.text_to_speech.v1.model.SpeakerModel) CreateSpeakerModelOptions(com.ibm.watson.text_to_speech.v1.model.CreateSpeakerModelOptions) File(java.io.File) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) IOException(java.io.IOException) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 3 with DeleteSpeakerModelOptions

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

the class TextToSpeechTest method testDeleteSpeakerModelWOptions.

// Test the deleteSpeakerModel operation with a valid options model parameter
@Test
public void testDeleteSpeakerModelWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "";
    String deleteSpeakerModelPath = "/v1/speakers/testString";
    server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody));
    // Construct an instance of the DeleteSpeakerModelOptions model
    DeleteSpeakerModelOptions deleteSpeakerModelOptionsModel = new DeleteSpeakerModelOptions.Builder().speakerId("testString").build();
    // Invoke deleteSpeakerModel() with a valid options model and verify the result
    Response<Void> response = textToSpeechService.deleteSpeakerModel(deleteSpeakerModelOptionsModel).execute();
    assertNotNull(response);
    Void responseObj = response.getResult();
    assertNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "DELETE");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, deleteSpeakerModelPath);
    // Verify that there is no query string
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNull(query);
}
Also used : DeleteSpeakerModelOptions(com.ibm.watson.text_to_speech.v1.model.DeleteSpeakerModelOptions) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Test(org.testng.annotations.Test)

Example 4 with DeleteSpeakerModelOptions

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

the class TextToSpeechIT method testListSpeakerModel.

/**
 * Test listSpeakerModel.
 */
@Test
public void testListSpeakerModel() {
    try {
        CreateSpeakerModelOptions createSpeakerModelOptions = new CreateSpeakerModelOptions.Builder().speakerName("speakerName").audio(new File(RESOURCE + "numbers.wav")).build();
        SpeakerModel speakerModel = service.createSpeakerModel(createSpeakerModelOptions).execute().getResult();
        speakerId = speakerModel.getSpeakerId();
        assertNotNull(speakerModel.getSpeakerId());
        Speakers speakers = service.listSpeakerModels().execute().getResult();
        assertNotNull(speakers.getSpeakers());
        assertTrue(speakers.getSpeakers().size() > 0);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        DeleteSpeakerModelOptions deleteSpeakerModelOptions = new DeleteSpeakerModelOptions.Builder().speakerId(speakerId).build();
        service.deleteSpeakerModel(deleteSpeakerModelOptions).execute().getResult();
    }
}
Also used : DeleteSpeakerModelOptions(com.ibm.watson.text_to_speech.v1.model.DeleteSpeakerModelOptions) SpeakerModel(com.ibm.watson.text_to_speech.v1.model.SpeakerModel) CreateSpeakerModelOptions(com.ibm.watson.text_to_speech.v1.model.CreateSpeakerModelOptions) Speakers(com.ibm.watson.text_to_speech.v1.model.Speakers) File(java.io.File) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) IOException(java.io.IOException) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Aggregations

DeleteSpeakerModelOptions (com.ibm.watson.text_to_speech.v1.model.DeleteSpeakerModelOptions)4 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)3 CreateSpeakerModelOptions (com.ibm.watson.text_to_speech.v1.model.CreateSpeakerModelOptions)3 SpeakerModel (com.ibm.watson.text_to_speech.v1.model.SpeakerModel)3 File (java.io.File)3 IOException (java.io.IOException)3 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)3 Test (org.junit.Test)3 GetSpeakerModelOptions (com.ibm.watson.text_to_speech.v1.model.GetSpeakerModelOptions)1 SpeakerCustomModels (com.ibm.watson.text_to_speech.v1.model.SpeakerCustomModels)1 Speakers (com.ibm.watson.text_to_speech.v1.model.Speakers)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.testng.annotations.Test)1