newbee
newbee

Reputation: 409

using eSpeak tts engine in application

I have this code for text to speech in my application.

public void onInit(int status) {
    // TODO Auto-generated method stub
     if (status == TextToSpeech.SUCCESS) {
         //Setting speech language           
         int result = tts.setLanguage(Locale.ENGLISH);            
         //If your device doesn't support language you set above
         if (result == TextToSpeech.LANG_MISSING_DATA
                 || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                //Cook simple toast message with message
                Toast.makeText(this, "Language not supported", Toast.LENGTH_LONG).show();
                //Log.e("TTS", "Language is not supported");
         }                 
         //TTS is not initialized properly
     } else {
                Toast.makeText(this, "TTS Initilization Failed", Toast.LENGTH_LONG).show();
                //Log.e("TTS", "Initilization Failed");
     }
}

My application includes many different languages like English, Hindi, Marathi, Telugu, Tamil, etc. Since the default android tts engine does not support these languages, I downloaded eSpeak tts engine from this link and installed it on my phone.

Its default language is set as English. How do i change its language in my code so that it can read unicode texts of other languages as well?

Currently, for a word in hindi script, it speaks some numbers.

How do i make it recognise the language used in the text? It shows only the locales available in the default google tts. How do I change the tts engine to eSpeak tts?

Upvotes: 1

Views: 3463

Answers (2)

Hoan Nguyen
Hoan Nguyen

Reputation: 18151

Initialize your TextToSpeech using

TextToSpeech (Context context, TextToSpeech.OnInitListener listener, String engine)

That is

tts = new TextToSpeech(this, this, "com.googlecode.eyesfree.espeak");

engine Package name of the TTS engine to use, which you can get by calling getEngines.

Upvotes: 1

Mr_Hmp
Mr_Hmp

Reputation: 2535

Try changing the Locale according to your need.

Currently it is Locale.ENGLISH change this accordingly.

Upvotes: 0

Related Questions