TextToSpeechBeta : engine ?

133 views
Skip to first unread message

Nanard

unread,
Oct 17, 2010, 1:21:40 PM10/17/10
to TTS-for-Android
Hi,

I have used TTS for some time now, and I'm currently upgrading to
TextToSpeechBeta. It seems the official documentation, and Java Help
is not well documented.

What I'd like to do :

- list all available Engines. Even without TTSExtended installed, I
retrive : TTS_ONLY, ESPEAK, PICO
Why ?

- how can I know the String reprenting the Engine to pass to
setEngineByPackageNameExtended() ?

- How can I know which language/Locale is supported to each Engine ?


TTSExtended seems great, but a little hard to guess how to use it !

Thanks for your help.

Nolan Darilek

unread,
Oct 17, 2010, 1:35:27 PM10/17/10
to tts-for...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here's how I get a list of installed engines, their labels and package
names. I use this list to populate a preference allowing the user to
pick. This is Scala code, but hopefully it's still clear:

val intent = new Intent("android.intent.action.START_TTS_ENGINE")
val pm = getPackageManager
val engines = pm.queryIntentActivities(intent, 0).map { engine =>
var label = engine.loadLabel(pm).toString()
if(label == "") label = engine.activityInfo.name.toString()
(label, engine.activityInfo.packageName)
}
val enginesPreference =
findPreference("speechEngine").asInstanceOf[ListPreference]
enginesPreference.setEntries(engines.map(_._1).toArray[CharSequence])

enginesPreference.setEntryValues(engines.map(_._2).toArray[CharSequence])

Basically, fire off the intent, calculate a label for each package, then
create a List of Tuples of the form (label, package). Then, find the
preference, populating its entries with all the labels and its values
with the package names such that selecting the label sets the preference
to the correct package.

Hope that helps. Not sure if some of the casts are necessary, but the
intersection of Java and Scala collections seems a bit hazy in
places--to me, at least.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAky7M94ACgkQIaMjFWMehWKYDgCdHk8Fyu7r0USw4bwz5wDDfoCl
OmUAn1COh3hkI+bKI2vnL0f7WiDOBA2J
=j/E1
-----END PGP SIGNATURE-----

Nanard

unread,
Oct 17, 2010, 6:11:45 PM10/17/10
to TTS-for-Android
Thanks a lot : it helps !

In Java :
Intent intent = new Intent("android.intent.action.START_TTS_ENGINE");
PackageManager pm = context.getPackageManager();
List<ResolveInfo> engines = pm.queryIntentActivities(intent,
0);// PackageManager.MATCH_DEFAULT_ONLY);
for(int i=0;i<engines.size();i++) {
final String name = engines.get(i).loadLabel(pm).toString();
final String classPath =
engines.get(i).activityInfo.packageName;
androidTTSEngineInstalled.add(new AndroidTTSEngine(name,
classPath));
}


Now for each Engine, how to get available Locales/languages ... ?

davemac

unread,
Oct 17, 2010, 9:25:09 PM10/17/10
to TTS-for-Android
At least for Pico, this appears to work:

...
// This could be in your onCreate(), to setup the TTS engine.
// Check to be sure that TTS exists and is okay to use
Intent checkIntent = new Intent();

checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkIntent, REQ_TTS_STATUS_CHECK);
...


protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == REQ_TTS_STATUS_CHECK) {
switch (resultCode) {
case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS:
// TTS is up and running
mTts = new TextToSpeech(this, this);
Log.v(TAG, "Pico is installed okay");
ArrayList<String> available =

data.getStringArrayListExtra("availableVoices");
break;
...

I haven't tried it on the others so don't know. Does anyone else know
if this works on the others as well?

- dave
www.androidbook.com

Nanard

unread,
Nov 10, 2010, 5:25:21 AM11/10/10
to TTS-for-Android
Thanks

It seems managing several TTS Engine & several Android OS version is a
bit... tricky


for instance, I have updated my app to allways check (and ask to
install) TTS Extended. But Android 2.2 users don't find it on the
Market, they then get an error.

So, I have to add a check in my code to know if we are on Android 2.2
or not, and decided or not to launch the Intent to download/check TTS
Extended.

I also have some problems with Svox engine.

On my 1.6 or emulator (2.1) : I can find Pico & eSpeak, but even on
the emulator (2.2) I can not find Svox. Nor my customers...


TTS feature has become a bit complicated those last months

clchen

unread,
Nov 12, 2010, 1:06:43 PM11/12/10
to TTS-for-Android


On Nov 10, 2:25 am, Nanard <bsegon...@gmail.com> wrote:
> Thanks
>
> It seems managing several TTS Engine & several Android OS version is a
> bit...  tricky
>
> for instance, I have updated my app to allways check (and ask to
> install) TTS Extended.  But Android 2.2 users don't find it on the
> Market, they then get an error.
You shouldn't force an install for TTS Extended. All of the TTS
Extended features have already been rolled into the platform TTS in
Froyo. If you don't force it, the TTS Extended library will fall
through and use the platform TTS automatically.

>
> So, I have to add a check in my code to know if we are on Android 2.2
> or not, and decided or not to launch the Intent to download/check TTS
> Extended.
>
> I also have some problems with Svox engine.
>
> On my 1.6 or emulator (2.1) : I can find Pico & eSpeak, but even on
> the emulator (2.2) I can not find Svox. Nor my customers...
You need to install eSpeak as a plugin for Froyo and later versions.
It is available on Android Market.

-Charles

Nanard

unread,
Nov 16, 2010, 4:55:27 AM11/16/10
to TTS-for-Android
Any experience with Svox & Flite ?

Are they correclty founded as TTS Engine in all platform version ?

Are all spoken languages/locales correctly founded on all country
specific devices ?
Reply all
Reply to author
Forward
0 new messages