當前位置: 首頁>>代碼示例>>Java>>正文


Java TextToSpeech.SUCCESS屬性代碼示例

本文整理匯總了Java中android.speech.tts.TextToSpeech.SUCCESS屬性的典型用法代碼示例。如果您正苦於以下問題:Java TextToSpeech.SUCCESS屬性的具體用法?Java TextToSpeech.SUCCESS怎麽用?Java TextToSpeech.SUCCESS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.speech.tts.TextToSpeech的用法示例。


在下文中一共展示了TextToSpeech.SUCCESS屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Init

public void Init() {
    if (_ttsInitialized) {
        Logger.getInstance().Warning(TAG, "Already initialized!");
        return;
    }

    _ttsSpeaker = new TextToSpeech(_context, status -> {
        if (status == TextToSpeech.SUCCESS) {
            int result = _ttsSpeaker.setLanguage(Locale.US);
            if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                Logger.getInstance().Error(TAG, "This Language is not supported!");
            } else {
                _receiverController.RegisterReceiver(_speakReceiver, new String[]{TTS_SPEAK_TEXT_BROADCAST});
                _ttsInitialized = true;
            }
        } else {
            Logger.getInstance().Error(TAG, "Initialization failed!");
        }
    });
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:20,代碼來源:TTSController.java

示例2: onInit

@Override
public void onInit(int status) {
    // TODO Auto-generated method stub

    if (status == TextToSpeech.SUCCESS) {
        //int result= tts.setLanguage(Locale.ENGLISH);
        Locale locale = new Locale("tr", "TR");
        int result = tts.setLanguage(locale);

        if (result == TextToSpeech.LANG_MISSING_DATA
                || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Log.e("TTS", "Language is not supported");
        } else {
            btn_konus.setEnabled(true);
            String text = editText1.getText().toString();
            speakOut(text);
        }

    } else {
        Log.e("TTS", "Initilization Failed");
    }
}
 
開發者ID:nrkdrk,項目名稱:Image-Text-Reader-And-Tools,代碼行數:22,代碼來源:TextToSpeechActivity.java

示例3: init

public void init(Context ctx) {
    prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
    prefsÆndret();
    tts = new TextToSpeech(ctx, new TextToSpeech.OnInitListener() {
      @Override
      public void onInit(int status) {
        if (status == TextToSpeech.SUCCESS) {
          initialiseret = true;
          int res = tts.setLanguage(new Locale("da", ""));
          if (res == TextToSpeech.LANG_MISSING_DATA || res == TextToSpeech.LANG_NOT_SUPPORTED) {
            res = tts.setLanguage(Locale.getDefault());
            if (res == TextToSpeech.LANG_MISSING_DATA || res == TextToSpeech.LANG_NOT_SUPPORTED) {
              res = tts.setLanguage(Locale.US);
              if (res == TextToSpeech.LANG_MISSING_DATA || res == TextToSpeech.LANG_NOT_SUPPORTED) {
                initialiseret = false;
              }
            }
          }

//          udtal("Tekst til tale initialiseret for sproget " + tts.getLanguage().getDisplayLanguage(tts.getLanguage()));
        }
      }
    });
  }
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:24,代碼來源:Talesyntese.java

示例4: createTTS

private void createTTS() {

        //Creates an instance of Google API TTS
        mTTS = new TextToSpeech(mContext, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                
                //If initializaation is sucessful so set language.
                if (status == TextToSpeech.SUCCESS) {

                    //Set language to PT-BR and get the value returned
                    int result = mTTS.setLanguage(new Locale("pt", "br"));

                    //Check if the language is supported, if not print it on Android Monitor.
                    if (result == TextToSpeech.LANG_MISSING_DATA
                            || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                        Log.e("TextToSpeechManager", "This Language is not supported");
                    }

                } else {
                    Log.e("TextToSpeechManager", "Initilization Failed!");
                }
            }
        });
    }
 
開發者ID:aidaferreira,項目名稱:synesthesiavision,代碼行數:25,代碼來源:TextToSpeechManager.java

示例5: TtsPlatformImpl

protected TtsPlatformImpl(long nativeTtsPlatformImplAndroid, Context context) {
    mInitialized = false;
    mNativeTtsPlatformImplAndroid = nativeTtsPlatformImplAndroid;
    mTextToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                if (status == TextToSpeech.SUCCESS) {
                    ThreadUtils.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            initialize();
                        }
                    });
                }
            }
        });
    addOnUtteranceProgressListener();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:18,代碼來源:TtsPlatformImpl.java

示例6: speak

/**
 * Attempt to start speaking an utterance. If it returns true, will call back on
 * start and end.
 *
 * @param utteranceId A unique id for this utterance so that callbacks can be tied
 *     to a particular utterance.
 * @param text The text to speak.
 * @param lang The language code for the text (e.g., "en-US").
 * @param rate The speech rate, in the units expected by Android TextToSpeech.
 * @param pitch The speech pitch, in the units expected by Android TextToSpeech.
 * @param volume The speech volume, in the units expected by Android TextToSpeech.
 * @return true on success.
 */
@CalledByNative
private boolean speak(int utteranceId, String text, String lang,
                      float rate, float pitch, float volume) {
    if (!mInitialized) {
        mPendingUtterance = new PendingUtterance(this, utteranceId, text, lang, rate,
                pitch, volume);
        return true;
    }
    if (mPendingUtterance != null) mPendingUtterance = null;

    if (!lang.equals(mCurrentLanguage)) {
        mTextToSpeech.setLanguage(new Locale(lang));
        mCurrentLanguage = lang;
    }

    mTextToSpeech.setSpeechRate(rate);
    mTextToSpeech.setPitch(pitch);

    int result = callSpeak(text, volume, utteranceId);
    return (result == TextToSpeech.SUCCESS);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:34,代碼來源:TtsPlatformImpl.java

示例7: onInit

@Override
public void onInit(int status) {
    if (status == TextToSpeech.SUCCESS) {
        int result = mTts.setLanguage(Locale.getDefault());
        isInit = true;

        if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {

            Log.e("error", "This Language is not supported");
        }
        Log.d("TextToSpeech", "Initialization Suceeded! " + System.currentTimeMillis());

        speak(mContext.getString(R.string.hello1) + ",");
    } else {
        Log.e("error", "Initialization Failed! " + status);
    }
}
 
開發者ID:quaap,項目名稱:PhoneFoneFun,代碼行數:17,代碼來源:TextToVoice.java

示例8: onInit

@Override
public void onInit(int status) {

    switch (status) {
        case TextToSpeech.SUCCESS:
            notifyHardwareOfShieldSelection();
            configureTTSLocale();
            break;

        case TextToSpeech.ERROR:
            Toast.makeText(activity, R.string.text_to_speech_text_to_speech_failed, Toast.LENGTH_SHORT)
                    .show();
            Log.e("[ERROR] doc.saulmm.text2speech.MainActivity.onInit ",
                    "TTS Failed");
            break;
    }
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:17,代碼來源:TextToSpeechShield.java

示例9: onInit

@Override
public void onInit(int status) {
    if(status==TextToSpeech.SUCCESS){
        ready=true;
        mTts.setLanguage(Locale.getDefault());//telefonun dili neyse o
        //  Toast.makeText(this,"başarılı tts",Toast.LENGTH_SHORT).show();
        Log.i("tts","tts success");


    }

    else if(status==TextToSpeech.ERROR){
        ready=false;
        //   Toast.makeText(this,"error tts",Toast.LENGTH_SHORT).show();
        Log.e("tts","tts error");

    }
}
 
開發者ID:kbrkkn,項目名稱:Uygulama-Android,代碼行數:18,代碼來源:MainActivity.java

示例10: run

@Override
public void run() {
    mImagePreprocessor = new ImagePreprocessor();

    mTtsSpeaker = new TtsSpeaker();
    mTtsSpeaker.setHasSenseOfHumor(true);
    mTtsEngine = new TextToSpeech(ImageClassifierActivity.this,
            new TextToSpeech.OnInitListener() {
                @Override
                public void onInit(int status) {
                    if (status == TextToSpeech.SUCCESS) {
                        mTtsEngine.setLanguage(Locale.US);
                        mTtsEngine.setOnUtteranceProgressListener(utteranceListener);
                        mTtsSpeaker.speakReady(mTtsEngine);
                    } else {
                        Log.w(TAG, "Could not open TTS Engine (onInit status=" + status
                                + "). Ignoring text to speech");
                        mTtsEngine = null;
                    }
                }
            });
    mCameraHandler = CameraHandler.getInstance();
    mCameraHandler.initializeCamera(
            ImageClassifierActivity.this, mBackgroundHandler,
            ImageClassifierActivity.this);

    mTensorFlowClassifier = new TensorFlowImageClassifier(ImageClassifierActivity.this);

    setReady(true);
}
 
開發者ID:FoxLabMakerSpace,項目名稱:SIGHT-For-the-Blind,代碼行數:30,代碼來源:ImageClassifierActivity.java

示例11: initTts

private void initTts() {
    mTtsEngine = new TextToSpeech(A2dpSinkActivity.this,
            new TextToSpeech.OnInitListener() {
                @Override
                public void onInit(int status) {
                    if (status == TextToSpeech.SUCCESS) {
                        mTtsEngine.setLanguage(Locale.US);
                    } else {
                        Log.w(TAG, "Could not open TTS Engine (onInit status=" + status
                                + "). Ignoring text to speech");
                        mTtsEngine = null;
                    }
                }
            });
}
 
開發者ID:androidthings,項目名稱:sample-bluetooth-audio,代碼行數:15,代碼來源:A2dpSinkActivity.java

示例12: speak

@ReactMethod
public void speak(String utterance, String queueMode, Promise promise) {
	if(notReady(promise)) return;

	if(IS_DUCKING) {
		int amResult = audioManager.requestAudioFocus(afChangeListener, 
														AudioManager.STREAM_MUSIC, 
														AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);

		if(amResult != AudioManager.AUDIOFOCUS_REQUEST_GRANTED)
			promise.reject("error", "Android AudioManager error, failed to request audio focus");
	}

	String utteranceId = Integer.toString(utterance.hashCode());

	int mode = TextToSpeech.QUEUE_ADD;
	if(queueMode.equals("ADD")) 
		mode = TextToSpeech.QUEUE_ADD;
	else if(queueMode.equals("FLUSH")) 
		mode = TextToSpeech.QUEUE_FLUSH;

	int speakResult = speak(utterance, mode, utteranceId);
	if(speakResult == TextToSpeech.SUCCESS) {
		promise.resolve(utteranceId);
	} else {
		promise.reject("error", "Unable to play. Error at speak(utterance, queueMode)");
	}
}
 
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:28,代碼來源:RNAndroidTextToSpeechModule.java

示例13: stop

@ReactMethod
public void stop(Promise promise) {
	if(notReady(promise)) return;

	int result = tts.stop();
	if(result == TextToSpeech.SUCCESS) {
		promise.resolve("success");
	} else {
		promise.reject("error", "Unknown error code at stop()");
	}
}
 
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:11,代碼來源:RNAndroidTextToSpeechModule.java

示例14: setDefaultPitch

@ReactMethod
public void setDefaultPitch(float pitch, Promise promise) {
	if(notReady(promise)) return;

	int result = tts.setPitch(pitch);
	if(result == TextToSpeech.SUCCESS) {
		WritableMap map = Arguments.createMap();
		map.putString("status", "Success");
		map.putDouble("pitch", (double)pitch);
		promise.resolve(map);
	} else {
		promise.reject("error", "Unable to set pitch");
	}
}
 
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:14,代碼來源:RNAndroidTextToSpeechModule.java

示例15: setDefaultSpeechRate

@ReactMethod
public void setDefaultSpeechRate(float speechRate, Promise promise) {
	if(notReady(promise)) return;

	int result = tts.setSpeechRate(speechRate);
	if(result == TextToSpeech.SUCCESS) {
		WritableMap map = Arguments.createMap();
		map.putString("status", "Success");
		map.putDouble("speechRate", (double)speechRate);
		promise.resolve(map);
	} else {
		promise.reject("error", "Unable to set speech rate");
	}
}
 
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:14,代碼來源:RNAndroidTextToSpeechModule.java


注:本文中的android.speech.tts.TextToSpeech.SUCCESS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。