当前位置: 首页>>代码示例>>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;未经允许,请勿转载。