@Override
 public void onCallStateChanged(int state, String incomingNumber) {
   speechAllowed = state == TelephonyManager.CALL_STATE_IDLE;
   if (!speechAllowed && tts != null && tts.isSpeaking()) {
     // If we're already speaking, stop it.
     tts.stop();
   }
 }
	private static void waitForSpeechFinished() {
		try {
			Thread.sleep(MEDIUM_THREADWAIT);
		} catch (InterruptedException e) { }
		while (myTts.isSpeaking()) {
			try {
				Thread.sleep(MEDIUM_THREADWAIT);
			} catch (InterruptedException e) { }
		}
		try {
			Thread.sleep(MEDIUM_THREADWAIT);
		} catch (InterruptedException e) { }
	}
Ejemplo n.º 3
0
  public void stop() {
    if (speakWord != null) {
      speakWord.stop();
      return;
    }

    myTTS.stop();
    // We wait until the tts is not speaking.
    // This is because top is asynchronized call
    while (myTTS.isSpeaking()) {
      try {
        Thread.sleep(20);
      } catch (InterruptedException e) {
        // Do not need to handle this case.
      }
    }
  }
Ejemplo n.º 4
0
 public static void speak(String text, String loc) {
   int result = mTts.setLanguage(new Locale(loc));
   if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
     Toast.makeText(
             mReviewer.get(),
             mReviewer.get().getString(R.string.no_tts_available_message) + " (" + loc + ")",
             Toast.LENGTH_LONG)
         .show();
     Timber.e("Error loading locale " + loc);
   } else {
     if (mTts.isSpeaking()) {
       Timber.d("tts engine appears to be busy... clearing queue");
       stopTts();
       // sTextQueue.add(new String[] { text, loc });
     }
     Timber.d("tts text '%s' to be played for locale (%s)", text, loc);
     mTts.speak(mTextToSpeak, TextToSpeech.QUEUE_FLUSH, mTtsParams);
   }
 }
Ejemplo n.º 5
0
 public boolean Speaking() {
   return ttobj.isSpeaking();
 }
Ejemplo n.º 6
0
 @JavascriptInterface
 @SuppressWarnings("unused")
 public boolean isSpeaking() {
   return mTextToSpeech.isSpeaking();
 }