Search in sources :

Example 1 with Pronunciation

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

the class TextToSpeechIT method testGetWordPronunciation.

/**
 * Test word pronunciation.
 */
@Test
public void testGetWordPronunciation() {
    String word = "Congressman";
    GetPronunciationOptions getOptions1 = new GetPronunciationOptions.Builder().text(word).voice(GetPronunciationOptions.Voice.EN_US_MICHAELVOICE).format(GetPronunciationOptions.Format.IBM).build();
    Pronunciation pronunciation = service.getPronunciation(getOptions1).execute();
    assertNotNull(pronunciation);
    assertNotNull(pronunciation.getPronunciation());
    GetPronunciationOptions getOptions2 = new GetPronunciationOptions.Builder().text(word).format(GetPronunciationOptions.Format.IBM).build();
    pronunciation = service.getPronunciation(getOptions2).execute();
    assertNotNull(pronunciation);
    assertNotNull(pronunciation.getPronunciation());
    GetPronunciationOptions getOptions3 = new GetPronunciationOptions.Builder().text(word).voice(GetPronunciationOptions.Voice.EN_US_MICHAELVOICE).build();
    pronunciation = service.getPronunciation(getOptions3).execute();
    assertNotNull(pronunciation);
    assertNotNull(pronunciation.getPronunciation());
    GetPronunciationOptions getOptions4 = new GetPronunciationOptions.Builder().text(word).voice(GetPronunciationOptions.Voice.EN_US_MICHAELVOICE).format(GetPronunciationOptions.Format.IPA).build();
    pronunciation = service.getPronunciation(getOptions4).execute();
    assertNotNull(pronunciation);
    assertNotNull(pronunciation.getPronunciation());
}
Also used : Pronunciation(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Pronunciation) GetPronunciationOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetPronunciationOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 2 with Pronunciation

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

the class TextToSpeech method getPronunciation.

/**
 * Gets the pronunciation for a word.
 *
 * Returns the phonetic pronunciation for the word specified by the `text` parameter. You can request the
 * pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default
 * translation for the language of that voice or for a specific custom voice model to see the translation for that
 * voice model. **Note:** This method is currently a beta release.
 *
 * @param getPronunciationOptions the {@link GetPronunciationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Pronunciation}
 */
public ServiceCall<Pronunciation> getPronunciation(GetPronunciationOptions getPronunciationOptions) {
    Validator.notNull(getPronunciationOptions, "getPronunciationOptions cannot be null");
    String[] pathSegments = { "v1/pronunciation" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    builder.query("text", getPronunciationOptions.text());
    if (getPronunciationOptions.voice() != null) {
        builder.query("voice", getPronunciationOptions.voice());
    }
    if (getPronunciationOptions.format() != null) {
        builder.query("format", getPronunciationOptions.format());
    }
    if (getPronunciationOptions.customizationId() != null) {
        builder.query("customization_id", getPronunciationOptions.customizationId());
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Pronunciation.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) Pronunciation(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Pronunciation)

Aggregations

Pronunciation (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Pronunciation)2 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 GetPronunciationOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetPronunciationOptions)1 Test (org.junit.Test)1