0

I have referred speak-with-tts-such-as-hindi

and i have done like this:

extToSpeech text2speechHi;

 text2speechHi=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
            @Override    public void onInit(int status) {
                if(status != TextToSpeech.ERROR) {
                    text2speechHi.setLanguage(new Locale("hin"));
                }
            }
        });



text2speechHi.speak(getResources().getString(R.string.hindi_text), TextToSpeech.QUEUE_FLUSH, null);

But still not reading.... how to see the output ? whether change any device setting in which i run the code?? or need to install anything??

what is this eSpeak they have mention in that link...any other free option available?? Any one who implemented this successfully????

It is working in fine for English text2speech.setLanguage(Locale.UK);

Community
  • 1
  • 1
Elizabeth
  • 1,399
  • 1
  • 13
  • 25

1 Answers1

0

You are calling speak() before initialization is done, i.e., before onInit is called, consequently setLanguage hasn't been called yet. Refactor your code to follow the asynchronous pattern, by e.g. moving speak() into the onInit method.

EDIT: OP says code snippet in question is not representative of the actual code. Awaiting clarification before removing or updating answer.

JHH
  • 8,567
  • 8
  • 47
  • 91
  • Actually i am calling speak() from another function. It was working fine if langauge is text2speech.setLanguage(Locale.UK); ...so i dont think its because of any pattern if i am not wrong – Elizabeth Mar 17 '16 at 10:47
  • 1
    In that case, why are you submitting irrelevant code? Please update with your actual code. – JHH Mar 17 '16 at 10:56
  • Do you even have a Hindi TTS engine installed? – JHH Mar 17 '16 at 10:57
  • no what is tts engine?? where to install?? in my mobile?? – Elizabeth Mar 17 '16 at 11:00
  • A tts (text to speech) engine is what actually supplies sound files and transformations from text to synthesized speak. Google's engine should nowadays support Hindi, but it might be a good start to check that you have it installed and active in your device settings (under language). If that looks OK, the next logical step would be to post your actual code along with telling us what actually happens. Also perhaps read up on Android tts, it's all in the docs and their developer blog – JHH Mar 17 '16 at 11:06
  • In my device, under language &input -> Speech -> Text-to-speech output ->picoTTS this is what i have..i think picoTTS doesnt support Hindi..so what to do? – Elizabeth Mar 17 '16 at 11:12
  • Then you install a tts that does. Should be several on Google Play. Google's own tts can be found at https://play.google.com/store/apps/details?id=com.google.android.tts – JHH Mar 17 '16 at 11:14