Skip to main content

Ideas around Java Speech API and Language Translation

Posted by brunogh on November 10, 2008 at 6:26 PM PST

Have you seen this unofficial Java API for Google Translator? So, I was thinking that it could be interesting to mix this stuff with Java Speech API (JSAPI).

JSAPI was divided to support two things: speech recognizers and synthesizers. Speech synthesis is the process of generating human speech from written text for a specific language. Speech recognition is the process of converting human speech to words/commands. This converted text can be used or interpreted in different ways (interesting and simple definition from this article).

It seems that there are not too many open source projects that cares about the recognizer part. I have found a very interesting one called Sphinx, but did not have time to try it yet. I was thinking how cool would be to have an open source software to make possible a talk between two different people, like you say something in a language, it translates to another language and say that. Have anybody seen anything like that? Non commercial? For voip?

So, I work in part of a demo, but only with the the synthesizer part, the text input is manually. I used FreeTTS for that. Basically this piece of code gets an word input in Portuguese, translates it to English and then say the word.

package speech;

import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;

public class Main {

    public static void main(String[] args) {
        VoiceManager voiceManager = VoiceManager.getInstance();
        Voice voice = voiceManager.getVoice("kevin16");

        String text = null;
        do {
            try {
                System.out.println("Type a word in Portuguese and listen it in English -> ");
                text = new BufferedReader(new InputStreamReader(;
                voice.speak(Translate.translate(text, Language.PORTUGESE, Language.ENGLISH));
            } catch (Exception ex) {
        } while (!text.equals("!quit"));


If you got excited to work in an open source project like that, go ahead and write something! I can guarantee your fun!

Have a nice week!
Bruno Ghisi

Related Topics >>



while running the above code, it says java.lang.Exception: [google-api-translate-java] Referrer is not set. Call setHttpReferrer() How to set the referrer. I've tried most of the url but was unable to run the code. What is the exact URL ? Kindly help me out.


While running the above code, it says- System property "mbrola.base" is undefined. Will not use MBROLA voices. The error occurs at line:- Voice voice = voiceManager.getVoice("kevin16"); Kindly help me out.

Hello, please make sure if you have setted it right. Otherwise try its users list.

Hai i tried this freetts example, but audio file is not detecting. Tell me how can i overcome this problem....

Hello alois, I wish I had time right now to start a project like that. Anyway, if anyone got interested, I can help in some way too. We definitely would find problems with the grammar syntax, but we still can start something... Cheers!

Really cool idea ! Don't know any app doing that, but would be interested to contribute in a such project ! Lot of possibility, but I wonder how this can be efficient, cause automatic translation fail on grammar syntax ...