Search in sources :

Example 6 with Words

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

the class TextToSpeech method listVoiceModels.

/**
 * Lists all available custom voice models for a language or for all languages.
 *
 * Lists metadata such as the name and description for the custom voice models that you own. Use the `language` query
 * parameter to list the voice models that you own for the specified language only. Omit the parameter to see all
 * voice models that you own for all languages. To see the words in addition to the metadata for a specific voice
 * model, use the `GET /v1/customizations/{customization_id}` method. You must use credentials for the instance of the
 * service that owns a model to list information about it. **Note:** This method is currently a beta release.
 *
 * @param listVoiceModelsOptions the {@link ListVoiceModelsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link VoiceModels}
 */
public ServiceCall<VoiceModels> listVoiceModels(ListVoiceModelsOptions listVoiceModelsOptions) {
    String[] pathSegments = { "v1/customizations" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    if (listVoiceModelsOptions != null) {
        if (listVoiceModelsOptions.language() != null) {
            builder.query("language", listVoiceModelsOptions.language());
        }
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModels.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) VoiceModels(com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModels)

Example 7 with Words

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

the class CustomizationsIT method testAddWordsJapanese.

/**
 * Test add words and list words for Japanese.
 */
@Test
public void testAddWordsJapanese() {
    model = createVoiceModelJapanese();
    final List<Word> expected = instantiateWordsJapanese();
    AddWordsOptions addOptions = new AddWordsOptions.Builder().customizationId(model.getCustomizationId()).words(expected).build();
    service.addWords(addOptions).execute();
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build();
    final Words words = service.listWords(listOptions).execute();
    assertEquals(expected.size(), words.getWords().size());
}
Also used : Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word) AddWordsOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions) Words(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 8 with Words

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

the class CustomizationsIT method testGetWord.

/**
 * Test get word.
 */
@Test
public void testGetWord() {
    model = createVoiceModel();
    final List<Word> expected = instantiateWords();
    AddWordsOptions addOptions = new AddWordsOptions.Builder().customizationId(model.getCustomizationId()).words(expected).build();
    service.addWords(addOptions).execute();
    GetWordOptions getOptions = new GetWordOptions.Builder().customizationId(model.getCustomizationId()).word(expected.get(0).getWord()).build();
    final Translation translation = service.getWord(getOptions).execute();
    assertEquals(expected.get(0).getTranslation(), translation.getTranslation());
}
Also used : Translation(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation) Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word) AddWordsOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions) GetWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 9 with Words

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

the class CustomizationsIT method testDeleteWord.

/**
 * Test delete word with string.
 */
@Test
public void testDeleteWord() {
    model = createVoiceModel();
    final Word expected = instantiateWords().get(0);
    AddWordOptions addOptions = new AddWordOptions.Builder().word(expected.getWord()).translation(expected.getTranslation()).customizationId(model.getCustomizationId()).build();
    service.addWord(addOptions).execute();
    DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder().customizationId(model.getCustomizationId()).word(expected.getWord()).build();
    service.deleteWord(deleteOptions).execute();
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build();
    final Words results = service.listWords(listOptions).execute();
    assertEquals(0, results.getWords().size());
}
Also used : AddWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions) Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word) Words(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions) DeleteWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Example 10 with Words

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

the class CustomizationsIT method testAddWord.

/**
 * Test add word.
 */
@Test
public void testAddWord() {
    model = createVoiceModel();
    final Word expected = instantiateWords().get(0);
    AddWordOptions addOptions = new AddWordOptions.Builder().word(expected.getWord()).translation(expected.getTranslation()).customizationId(model.getCustomizationId()).build();
    service.addWord(addOptions).execute();
    ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build();
    final Words results = service.listWords(listOptions).execute();
    assertEquals(1, results.getWords().size());
    final Word result = results.getWords().get(0);
    assertEquals(expected, result);
    assertEquals(expected.getWord(), result.getWord());
    assertEquals(expected.getTranslation(), result.getTranslation());
}
Also used : AddWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions) Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word) Words(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words) ListWordsOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)13 Words (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words)12 ListWordsOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions)11 Word (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)9 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)7 Words (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words)7 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)7 AddWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions)6 ListWordsOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions)6 MockResponse (okhttp3.mockwebserver.MockResponse)6 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)5 Ignore (org.junit.Ignore)5 JsonObject (com.google.gson.JsonObject)4 JsonParser (com.google.gson.JsonParser)4 Translation (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation)4 VoiceModel (com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel)4 FileInputStream (java.io.FileInputStream)4 ByteString (okio.ByteString)4 AddWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions)3