✏️
WorDroid
  • Getting Started
  • Requirements
  • Changelog
  • Step 1: Register your app
    • Register your app
    • Add your site
    • Add Navigation Drawer & Bottom Navigation Items
    • Configure Basic Settings
  • Step 2: Wordpress Plugin
    • Install the WordPress plugin
    • Sync the settings from dashboard
    • Customize app homepage
    • Notification Settings
  • OneSignal Configuration
  • Firebase Configuration
  • Step 3 : Android Studio Part
    • Change Package Name
    • Firebase Configuration
    • Add Site URL and Other Configuration
    • Change Text-to-speech language
    • Configure Login
    • Generating APK / Signed APK
  • FAQ
  • Bug Fixes
    • Release APK Crashes after signing
    • Unable to comment on posts
  • Data Helper
Powered by GitBook
On this page

Was this helpful?

  1. Step 3 : Android Studio Part

Change Text-to-speech language

PreviousAdd Site URL and Other ConfigurationNextConfigure Login

Last updated 5 years ago

Was this helpful?

Make sure the voice pack of the language is installed in the phone before you change the TTS language.

By default the TTS's language is determined by the phone's language. If the language of the phone is English then the TTS language will also be the same.

You can change this by going into the PostFragment.java

if (i == TextToSpeech.SUCCESS) {
    int result = tts.setLanguage(Locale.getDefault());

    if (result == TextToSpeech.LANG_MISSING_DATA
            || result == TextToSpeech.LANG_NOT_SUPPORTED) {
        showSnackbar(getResources().getString(R.string.text_to_speak_language_not_supported));
    }
} else {
    Log.e("TTS", "Initilization Failed!");
}

Change the Locale.getDefault() with new Locale("fr","CA"). fr is the language and CA is the country. Check the list of available locale

if (i == TextToSpeech.SUCCESS) {
    int result = tts.setLanguage(new Locale("fr","CA"));

    if (result == TextToSpeech.LANG_MISSING_DATA
            || result == TextToSpeech.LANG_NOT_SUPPORTED) {
        showSnackbar(getResources().getString(R.string.text_to_speak_language_not_supported));
    }
} else {
    Log.e("TTS", "Initilization Failed!");
}

https://www.oracle.com/technetwork/java/javase/java8locales-2095355.html