Search in sources :

Example 6 with Word

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word 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 7 with Word

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word 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 8 with Word

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

the class CustomizationsIT method instantiateWordsJapanese.

private List<Word> instantiateWordsJapanese() {
    Word word1 = new Word();
    word1.setWord("hodor");
    word1.setTranslation("hold the door");
    word1.setPartOfSpeech(Word.PartOfSpeech.JOSI);
    Word word2 = new Word();
    word2.setWord("clodor");
    word2.setTranslation("close the door");
    word2.setPartOfSpeech(Word.PartOfSpeech.HOKA);
    return ImmutableList.of(word1, word2);
}
Also used : Word(com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)

Example 9 with Word

use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word 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)

Example 10 with Word

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

the class CustomizationsTest method testDeleteWord.

/**
 * Test delete word.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testDeleteWord() throws InterruptedException {
    final String expected = instantiateWords().get(0).getWord();
    server.enqueue(new MockResponse().setResponseCode(204));
    DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder().customizationId(CUSTOMIZATION_ID).word(expected).build();
    service.deleteWord(deleteOptions).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID) + "/" + expected, request.getPath());
    assertEquals("DELETE", request.getMethod());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteWordOptions(com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

Word (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word)16 Test (org.junit.Test)16 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)8 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)8 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)8 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 Words (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words)6 MockResponse (okhttp3.mockwebserver.MockResponse)6 Word (com.ibm.watson.developer_cloud.speech_to_text.v1.model.Word)5 AddWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions)5 Translation (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation)5 GetWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions)4 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)3 CustomWord (com.ibm.watson.developer_cloud.speech_to_text.v1.model.CustomWord)3 DeleteWordOptions (com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions)3 ByteString (okio.ByteString)3 JsonObject (com.google.gson.JsonObject)2 GetWordOptions (com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetWordOptions)2 Pronunciation (com.ibm.watson.developer_cloud.text_to_speech.v1.model.Pronunciation)2