use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class SpeechToTextIT method testGetWord.
/**
* Test get word.
*/
public void testGetWord() {
GetWordOptions getOptions = new GetWordOptions.Builder().customizationId(customizationId).wordName("string").build();
Word result = service.getWord(getOptions).execute();
assertNotNull(result);
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testAddWord.
/**
* Test add word.
*
* @throws InterruptedException the interrupted exception
* @throws FileNotFoundException the file not found exception
*/
@Test
public void testAddWord() throws InterruptedException, FileNotFoundException {
String id = "foo";
Word newWord = loadFixture("src/test/resources/speech_to_text/word.json", Word.class);
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
AddWordOptions addOptions = new AddWordOptions.Builder().wordName(newWord.getWord()).customizationId(id).word(newWord.getWord()).displayAs(newWord.getDisplayAs()).soundsLike(newWord.getSoundsLike()).build();
service.addWord(addOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals("PUT", request.getMethod());
assertEquals(String.format(PATH_WORD, id, newWord.getWord()), request.getPath());
assertEquals(GSON.toJson(newWord), request.getBody().readUtf8());
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testGetWord.
/**
* Test get word.
*
* @throws InterruptedException the interrupted exception
* @throws FileNotFoundException the file not found exception
*/
@Test
public void testGetWord() throws InterruptedException, FileNotFoundException {
String id = "foo";
String wordName = "bar";
String wordAsStr = getStringFromInputStream(new FileInputStream("src/test/resources/speech_to_text/word.json"));
JsonObject word = new JsonParser().parse(wordAsStr).getAsJsonObject();
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(wordAsStr));
GetWordOptions getOptions = new GetWordOptions.Builder().customizationId(id).wordName(wordName).build();
Word result = service.getWord(getOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals("GET", request.getMethod());
assertEquals(String.format(PATH_WORD, id, wordName), request.getPath());
assertEquals(word, GSON.toJsonTree(result));
}
use of com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word in project java-sdk by watson-developer-cloud.
the class SpeechToTextTest method testAddWords.
/**
* Test add words.
*
* @throws InterruptedException the interrupted exception
* @throws FileNotFoundException the file not found exception
*/
@Test
public void testAddWords() throws InterruptedException, FileNotFoundException {
String id = "foo";
Word newWord = loadFixture("src/test/resources/speech_to_text/word.json", Word.class);
Map<String, Object> wordsAsMap = new HashMap<String, Object>();
wordsAsMap.put("words", new Word[] { newWord });
server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}"));
CustomWord word = new CustomWord();
word.setWord(newWord.getWord());
word.setDisplayAs(newWord.getDisplayAs());
word.setSoundsLike(newWord.getSoundsLike());
AddWordsOptions addOptions = new AddWordsOptions.Builder().customizationId(id).addWords(word).build();
service.addWords(addOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals("POST", request.getMethod());
assertEquals(String.format(PATH_WORDS, id), request.getPath());
assertEquals(GSON.toJson(wordsAsMap), request.getBody().readUtf8());
}
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 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());
}
Aggregations