Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get list of installed TTS engines you should get uid of <em>com.ivona.tts</em> package:<br> <a href="http://developer.android.com/reference/android/content/pm/PackageManager.html#getApplicationInfo(java.lang.String,%20int%29">http://developer.android.com/reference/android/content/pm/PackageManager.html#getApplicationInfo(java.lang.String,%20int%29</a><br> and then ask <strong>PackageManager</strong> for all applications that share this uid:<br> <a href="http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackagesForUid(int%29">http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackagesForUid(int%29</a></p> <p>To change TTS engine use this method:<br> <a href="http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#setEngineByPackageName(java.lang.String%29">http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#setEngineByPackageName(java.lang.String%29</a></p> <p>(Please note, that this method is deprecated and on newer API levels you should use the following constructor:<br> <a href="http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#TextToSpeech(android.content.Context,%20android.speech.tts.TextToSpeech.OnInitListener,%20java.lang.String%29">http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#TextToSpeech(android.content.Context,%20android.speech.tts.TextToSpeech.OnInitListener,%20java.lang.String%29</a>)</p> <p>Finally to set specific Ivona voice you must parse language/country/name from voice package name and pass it to:<br> <a href="http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#setLanguage(java.util.Locale%29">http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#setLanguage(java.util.Locale%29</a> eg. to choose com.ivona.tts.voicebeta.eng.gbr.amy you should use:<br></p> <pre><code>tts.setLanguage(new Locale("eng", "gbr", "amy")); </code></pre> <p>Here's sample Activity that prints available voices to logcat:</p> <pre><code>package com.example.com.ivona.tts.test; import java.util.regex.Matcher; import java.util.regex.Pattern; import android.app.Activity; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.util.Log; public class TTSActivity extends Activity implements TextToSpeech.OnInitListener { private static final String TAG = "TTSActivity"; private TextToSpeech tts; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tts = new TextToSpeech(TTSActivity.this, TTSActivity.this); } @Override public void onInit(int status) { PackageManager pm = getPackageManager(); ApplicationInfo ai = null; try { ai = pm.getApplicationInfo("com.ivona.tts", 0); } catch (NameNotFoundException e) { e.printStackTrace(); return; } String[] ivonaVoices = pm.getPackagesForUid(ai.uid); Log.d(TAG, "Possible tts.setLanguage() usage:"); Pattern p = Pattern.compile("^com\\.ivona\\.tts\\.voicebeta\\.([^.]+)\\.([^.]+)\\.([^.]+)$"); for (String voice: ivonaVoices) { Matcher m = p.matcher(voice); if (m.matches()) Log.d(TAG, String.format("tts.setLanguage(\"%s\", \"%s\", \"%s\")", m.group(1), m.group(2), m.group(3))); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload