Using eSpeak tts engine in an 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, such as English, Hindi, Marathi, Telugu, Tamil, etc. Since the default android tts engine does not support these languages, I downloaded the eSpeak tts engine from this and installed it on my phone.

Its default language is set to English. How can I change my language in my code so that it can read texts of other languages ​​in Unicode?

Currently, for a word in a Hindi script, he is talking about some numbers.

How do I recognize the language used in the text? It shows only locales available in standard google tts. How to change tts engine to eSpeak tts?

+1
source share
2 answers

Initialize your TextToSpeech using

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

it

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

engine The package name of the TTS engine that you can get by calling getEngines .

+1
source

Try changing Locale to suit your needs.

This is currently Locale.ENGLISH will change this accordingly.

0
source

Source: https://habr.com/ru/post/985003/


All Articles