Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextToSpeech on Android 11

Up to API 29 tts is working fine on android to speak out any text

But on API 30 tts is not working anymore and i do not know why

The google documentation says :

"Apps targeting Android 11 that use text-to-speech should declare TextToSpeech.Engine#INTENT_ACTION_TTS_SERVICE in the elements of their manifest"

I do not exactly know what they mean and how to implement this in the manifest.

I hope anybody can help me with this.

like image 567
Frank Avatar asked Aug 07 '20 21:08

Frank


People also ask

What is TTS feature of Android?

We've introduced a new feature in version 1.6 of the Android platform: Text-To-Speech (TTS). Also known as "speech synthesis", TTS enables your Android device to "speak" text of different languages.

What is AddSpeech () method in Android?

AddSpeech(String, String, Int32) Adds a mapping between a string of text and a sound resource in a package. AddSpeech(ICharSequence, String, Int32) Adds a mapping between a CharSequence (may be spanned with TtsSpans) of text and a sound resource in a package.


Video Answer


2 Answers

Although probably not the best answer (or maybe just a glitch on Androids part) add the following code just above the <application in your manifest.

<queries>
    <intent>
        <action android:name="android.intent.action.TTS_SERVICE" />
    </intent>
</queries>

<application
    android:allowBackup="false"

After adding this code my TTS service started to work again, but I do get a warning from the manifest file about it not being allowed there, but anywhere in the manifest gives this same warning so I suppress it with <!--suppress AndroidElementNotAllowed --> just above the <manifest tag at the top.

like image 128
Jayce Avatar answered Oct 30 '22 04:10

Jayce


@jayce's answer helps if app is targeting the Android 11 https://developer.android.com/reference/android/speech/tts/TextToSpeech

Note: sorry for the noise but I don't have enough reputation to put my comment there.

like image 35
Gilliy Avatar answered Oct 30 '22 04:10

Gilliy