Search in sources :

Example 31 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project LibreraReader by foobnix.

the class TTSEngine method getCurrentEngineName.

public String getCurrentEngineName() {
    try {
        if (ttsEngine != null) {
            String enginePackage = ttsEngine.getDefaultEngine();
            List<EngineInfo> engines = ttsEngine.getEngines();
            for (final EngineInfo eInfo : engines) {
                if (eInfo.name.equals(enginePackage)) {
                    return engineToString(eInfo);
                }
            }
        }
    } catch (Exception e) {
        LOG.e(e);
    }
    return "---";
}
Also used : EngineInfo(android.speech.tts.TextToSpeech.EngineInfo)

Example 32 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project android_packages_apps_Settings by crdroidandroid.

the class TextToSpeechSettings method initSettings.

private void initSettings() {
    final ContentResolver resolver = getContentResolver();
    // Set up the default rate and pitch.
    mDefaultRate = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_RATE, TextToSpeech.Engine.DEFAULT_RATE);
    mDefaultPitch = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_PITCH, TextToSpeech.Engine.DEFAULT_PITCH);
    mDefaultRatePref.setProgress(getSeekBarProgressFromValue(KEY_DEFAULT_RATE, mDefaultRate));
    mDefaultRatePref.setOnPreferenceChangeListener(this);
    mDefaultRatePref.setMax(getSeekBarProgressFromValue(KEY_DEFAULT_RATE, MAX_SPEECH_RATE));
    mDefaultPitchPref.setProgress(getSeekBarProgressFromValue(KEY_DEFAULT_PITCH, mDefaultPitch));
    mDefaultPitchPref.setOnPreferenceChangeListener(this);
    mDefaultPitchPref.setMax(getSeekBarProgressFromValue(KEY_DEFAULT_PITCH, MAX_SPEECH_PITCH));
    if (mTts != null) {
        mCurrentEngine = mTts.getCurrentEngine();
        mTts.setSpeechRate(mDefaultRate / 100.0f);
        mTts.setPitch(mDefaultPitch / 100.0f);
    }
    SettingsActivity activity = null;
    if (getActivity() instanceof SettingsActivity) {
        activity = (SettingsActivity) getActivity();
    } else {
        throw new IllegalStateException("TextToSpeechSettings used outside a " + "Settings");
    }
    if (mCurrentEngine != null) {
        EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
        Preference mEnginePreference = findPreference(KEY_TTS_ENGINE_PREFERENCE);
        ((GearPreference) mEnginePreference).setOnGearClickListener(this);
        mEnginePreference.setSummary(info.label);
    }
    checkVoiceData(mCurrentEngine);
}
Also used : GearPreference(com.android.settings.widget.GearPreference) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) SeekBarPreference(com.android.settings.widget.SeekBarPreference) ListPreference(android.support.v7.preference.ListPreference) LayoutPreference(com.android.settings.applications.LayoutPreference) GearPreference(com.android.settings.widget.GearPreference) Preference(android.support.v7.preference.Preference) SettingsActivity(com.android.settings.SettingsActivity) ContentResolver(android.content.ContentResolver)

Example 33 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project android_packages_apps_Settings by crdroidandroid.

the class TtsEnginePreferenceFragment method initSettings.

private void initSettings() {
    if (mTts != null) {
        mCurrentEngine = mTts.getCurrentEngine();
    }
    mEnginePreferenceCategory.removeAll();
    SettingsActivity activity = (SettingsActivity) getActivity();
    List<EngineInfo> engines = mEnginesHelper.getEngines();
    for (EngineInfo engine : engines) {
        TtsEnginePreference enginePref = new TtsEnginePreference(getPrefContext(), engine, this, activity);
        mEnginePreferenceCategory.addPreference(enginePref);
    }
}
Also used : EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) SettingsActivity(com.android.settings.SettingsActivity)

Example 34 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project android_packages_apps_Settings by SudaMod.

the class TextToSpeechSettings method onGearClick.

@Override
public void onGearClick(GearPreference p) {
    if (KEY_TTS_ENGINE_PREFERENCE.equals(p.getKey())) {
        EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
        final Intent settingsIntent = mEnginesHelper.getSettingsIntent(info.name);
        startActivity(settingsIntent);
    }
}
Also used : EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) Intent(android.content.Intent)

Example 35 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project platform_packages_apps_Settings by BlissRoms.

the class TtsEnginePreferenceFragment method initSettings.

private void initSettings() {
    if (mTts != null) {
        mCurrentEngine = mTts.getCurrentEngine();
    }
    mEnginePreferenceCategory.removeAll();
    SettingsActivity activity = (SettingsActivity) getActivity();
    List<EngineInfo> engines = mEnginesHelper.getEngines();
    for (EngineInfo engine : engines) {
        TtsEnginePreference enginePref = new TtsEnginePreference(getPrefContext(), engine, this, activity);
        mEnginePreferenceCategory.addPreference(enginePref);
    }
}
Also used : EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) SettingsActivity(com.android.settings.SettingsActivity)

Aggregations

EngineInfo (android.speech.tts.TextToSpeech.EngineInfo)37 Intent (android.content.Intent)15 SettingsActivity (com.android.settings.SettingsActivity)13 ArrayList (java.util.ArrayList)8 ContentResolver (android.content.ContentResolver)7 PackageManager (android.content.pm.PackageManager)7 ResolveInfo (android.content.pm.ResolveInfo)7 ServiceInfo (android.content.pm.ServiceInfo)7 GearPreference (com.android.settings.widget.GearPreference)7 SeekBarPreference (com.android.settings.widget.SeekBarPreference)7 ListPreference (android.support.v7.preference.ListPreference)6 Preference (android.support.v7.preference.Preference)6 LayoutPreference (com.android.settings.applications.LayoutPreference)6 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 ProgressDialog (android.app.ProgressDialog)1 ComponentName (android.content.ComponentName)1 DialogInterface (android.content.DialogInterface)1