This is project is exported from java-google-translate-text-to-speech,and it provides a wrapper of Google Translate with the following functions:
- Translate text from one language to another language
- Detect the language of given texts
- text-to-speech
- Convert the original eclipse-based project to a maven project
- Fix the non-working detection component
You may refer to the below test cases for the usage.
@Test
public void testTranslateText() {
String text = translator.translate("I am programmer", Language.ENGLISH, Language.PORTUGUESE);
assertEquals("Eu sou programador", text);
}
@Test
public void testDetectLanguage() {
String language = translator.detect("Hello World");
assertEquals("en", language);
}
@Test
public void testPlayingAudio() throws IOException, JavaLayerException {
Audio audio = Audio.getInstance();
InputStream sound = audio.getAudio("你好世界", Language.CHINESE_SIMPLIFIED);
audio.play(sound);
assertTrue(sound != null);
}