Skip to content

Instantly share code, notes, and snippets.

@Younes-Charfaoui
Last active August 22, 2019 23:46
Show Gist options
  • Save Younes-Charfaoui/5680355d8d9cc58c90d25edd7e455273 to your computer and use it in GitHub Desktop.
Save Younes-Charfaoui/5680355d8d9cc58c90d25edd7e455273 to your computer and use it in GitHub Desktop.
override fun onInit(status: Int) {
// check the results in status variable.
if (status == TextToSpeech.SUCCESS) {
// setting the language to the default phone language.
val ttsLang = textToSpeech.setLanguage(Locale.getDefault())
// check if the language is supportable.
if (ttsLang == TextToSpeech.LANG_MISSING_DATA || ttsLang == TextToSpeech.LANG_NOT_SUPPORTED) {
Toast.makeText(this, "We can't support your language", Toast.LENGTH_LONG).show()
}
} else {
Toast.makeText(this, "TTS Initialization failed!", Toast.LENGTH_SHORT).show()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment