-
Notifications
You must be signed in to change notification settings - Fork 3
language
Xinrui Wang edited this page Dec 3, 2017
·
3 revisions
This class provides tools to translate sentences, translate language, break sentence, and convert text to speech via Azure service. This script is based on this project.
- You need to first add the following line to your
gradle
dependencies {
compile 'io.github.firemaples:microsoft-translator-java-api:0.8.5'
}
- Get your Azure keys.
A Windows Azure Portal Subscription Key (See the picture below, just use one of key 1 or key 2) - sign up here
- Put the keys in
src/res/values/string.xml
<string name="microsoft_translate_key" templateMergeStrategy="preserve" translatable="false">
**********
</string>
-
key
: Azure service key
This function translate message from a language to another language.
- Parameters:
-
message
(String): String to translate. -
from
(Language): input language type (could be found inpublic enum Language{...}
) -
to
(Language): output language type - return value(String): Translated message.
-
This function detects the language of the input message.
- Parameters:
-
message
(String): String to detect - return value(Language): language of the message
-
This function parse the sentence by providing an array of breaking positions.
- Parameters:
-
message
(String): String to parse -
from
(Language): input language type (could be found inpublic enum Language{...}
) - return value: an array of breaking positions
-
This function uploads the message to server and plays the audio downloaded from the provided URL.
- Parameters:
-
message
(String): String to parse -
language
(SpokenDialect): spoken dialect type (could be found inpublic enum SpokenDialect {...}
) - return value: NULL
-