use of android.speech.tts.TextToSpeech in project android_packages_apps_Settings by DirtyUnicorns.
the class TtsEnginePreferenceFragment method onUpdateEngine.
/**
* Step 3: We have now bound to the TTS engine the user requested. We will attempt to check
* voice data for the engine if we successfully bound to it, or revert to the previous engine if
* we didn't.
*/
public void onUpdateEngine(int status) {
if (status == TextToSpeech.SUCCESS) {
Log.d(TAG, "Updating engine: Successfully bound to the engine: " + mTts.getCurrentEngine());
android.provider.Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, mTts.getCurrentEngine());
} else {
Log.d(TAG, "Updating engine: Failed to bind to engine, reverting.");
if (mPreviousEngine != null) {
// This is guaranteed to at least bind, since mPreviousEngine would be
// null if the previous bind to this engine failed.
mTts = new TextToSpeech(getActivity().getApplicationContext(), null, mPreviousEngine);
}
mPreviousEngine = null;
}
}
use of android.speech.tts.TextToSpeech in project android_packages_apps_Settings by DirtyUnicorns.
the class TtsEnginePreferenceFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.tts_engine_picker);
mEnginePreferenceCategory = (PreferenceCategory) findPreference("tts_engine_preference_category");
mEnginesHelper = new TtsEngines(getActivity().getApplicationContext());
mTts = new TextToSpeech(getActivity().getApplicationContext(), null);
initSettings();
}
use of android.speech.tts.TextToSpeech in project android_packages_apps_Settings by crdroidandroid.
the class TextToSpeechSettings method onResume.
@Override
public void onResume() {
super.onResume();
if (mTts == null || mCurrentDefaultLocale == null) {
return;
}
if (!mTts.getDefaultEngine().equals(mTts.getCurrentEngine())) {
try {
mTts.shutdown();
mTts = null;
} catch (Exception e) {
Log.e(TAG, "Error shutting down TTS engine" + e);
}
mTts = new TextToSpeech(getActivity().getApplicationContext(), mInitListener);
setTtsUtteranceProgressListener();
initSettings();
} else {
// Do set pitch correctly after it may have changed, and unlike speed, it doesn't change
// immediately.
final ContentResolver resolver = getContentResolver();
mTts.setPitch(android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_PITCH, TextToSpeech.Engine.DEFAULT_PITCH) / 100.0f);
}
Locale ttsDefaultLocale = mTts.getDefaultLanguage();
if (mCurrentDefaultLocale != null && !mCurrentDefaultLocale.equals(ttsDefaultLocale)) {
updateWidgetState(false);
checkDefaultLocale();
}
}
use of android.speech.tts.TextToSpeech in project android_packages_apps_Settings by crdroidandroid.
the class TtsEnginePreferenceFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.tts_engine_picker);
mEnginePreferenceCategory = (PreferenceCategory) findPreference("tts_engine_preference_category");
mEnginesHelper = new TtsEngines(getActivity().getApplicationContext());
mTts = new TextToSpeech(getActivity().getApplicationContext(), null);
initSettings();
}
use of android.speech.tts.TextToSpeech in project android_packages_apps_Settings by crdroidandroid.
the class TtsEnginePreferenceFragment method onUpdateEngine.
/**
* Step 3: We have now bound to the TTS engine the user requested. We will attempt to check
* voice data for the engine if we successfully bound to it, or revert to the previous engine if
* we didn't.
*/
public void onUpdateEngine(int status) {
if (status == TextToSpeech.SUCCESS) {
Log.d(TAG, "Updating engine: Successfully bound to the engine: " + mTts.getCurrentEngine());
android.provider.Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, mTts.getCurrentEngine());
} else {
Log.d(TAG, "Updating engine: Failed to bind to engine, reverting.");
if (mPreviousEngine != null) {
// This is guaranteed to at least bind, since mPreviousEngine would be
// null if the previous bind to this engine failed.
mTts = new TextToSpeech(getActivity().getApplicationContext(), null, mPreviousEngine);
}
mPreviousEngine = null;
}
}
Aggregations