Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

java - Text to speech issue in API Level 22

I was trying to converting text to speech in API level 22. Unfortunately, it's not working below API level 23.

tts=new TextToSpeech(MainActivity.this, new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            if (status!=TextToSpeech.ERROR)
            {
                tts.setLanguage(Locale.US);
            }
        }
    });


    btnSpeak.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String text=etxtText.getText().toString();

            tts.speak(text,TextToSpeech.QUEUE_FLUSH,null);
            //1.0f is default speech rate, increase to high and decrease to lower
            tts.setSpeechRate(1.0f);


        }
    });



}


@Override
protected void onPause() {

    if (tts!=null)
    {
        //to stop speech
        tts.stop();
        tts.shutdown();

    }
    super.onPause();
}

It's working in upper version. But, not in API level 22. Is there possible way to run it in API level 22.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...