Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can also try this,if the text to be spoken is coming from a broadcast listener.first create a service</p> <pre><code>public class MyTell extends Service implements OnInitListener{ public MyTell() { } public static TextToSpeech mTts; @Override public IBinder onBind(Intent intent) { return null; } public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub mPreferences = getSharedPreferences(Mysettings.PREF_NAME, Service.MODE_PRIVATE); pit = Float.parseFloat(mPreferences.getString("pit","0.8")); rate = Float.parseFloat(mPreferences.getString("rate","1.1")); mTts = new TextToSpeech(this, this); super.onStart(intent, startId); } public void onInit(int status) { // TODO Auto-generated method stub if (status == TextToSpeech.SUCCESS) { if (mTts.isLanguageAvailable(Locale.UK) &gt;= 0) Toast.makeText( MyTell.this, "Sucessfull intialization of Text-To-Speech engine Mytell ", Toast.LENGTH_LONG).show(); mTts.setLanguage(Locale.UK); mTts.setPitch(pit); mTts.setSpeechRate(rate); } else if (status == TextToSpeech.ERROR) { Toast.makeText(MyTell.this, "Unable to initialize Text-To-Speech engine", Toast.LENGTH_LONG).show(); } }} </code></pre> <p>then create the listener where you're insert your text</p> <pre><code>public class MyBroadCast extends BroadcastReceiver { public MyPop() { } @Override public void onReceive(Context context, Intent intent) { // TODO: This method is called when the BroadcastReceiver is receiving // an Intent broadcast. //here is where you're use the service you created to speak the text MyTell.mTts.speak("Text to be spoken", TextToSpeech.QUEUE_FLUSH,null); } } </code></pre> <p>make sure you start the service before you use the tts engine and also check if a tts engine is available</p>
    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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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