How to Programmatically Change TTS Default Engine
Asked Answered
C

2

20

In addition to the Pico TTS engine that comes with Android, I have another TTS engine installed. I can change which is the default used by the system -- manually:

Settings > Voice input & output > Text-to-speech settings > Default Engine

I would like to be able to do that programmatically, from within my application. Is this possible?

If so, how would I go about that?

Chloras answered 9/9, 2011 at 13:41 Comment(0)
B
6

You can't change the default engine. You can however, change the engine you are using by calling TextToSpeech.setEngineByPackageName() (available since 2.2) or use the constructor that takes an engine package parameter (available in ICS, so not really useful right now).

There is also no API before ICS to find out what engines are installed, so you need to know the other engine's package beforehand to be able to use it.

Boucher answered 8/11, 2011 at 9:18 Comment(1)
Method deprecated in API level 14.Puss
W
16

The above answer is no longer valid as the method is deprecated. Android API 14 and above you need to use the constructor for setting the engine.

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

The "engine" String is the package name of the TTS engine you want to use.

Weaponless answered 29/5, 2016 at 11:0 Comment(2)
How do you know what is the string for the Google TTS engine?Copalite
You can find out the engine name when you activate it and run TextToSpeech.EngineInfo() or check value of mCurrentEngine of the TextToSpeech object.Myeloid
B
6

You can't change the default engine. You can however, change the engine you are using by calling TextToSpeech.setEngineByPackageName() (available since 2.2) or use the constructor that takes an engine package parameter (available in ICS, so not really useful right now).

There is also no API before ICS to find out what engines are installed, so you need to know the other engine's package beforehand to be able to use it.

Boucher answered 8/11, 2011 at 9:18 Comment(1)
Method deprecated in API level 14.Puss

© 2022 - 2024 — McMap. All rights reserved.