How can I use text to speak for Arabic in Android Java or Kotlin? I've tried using android.speech.tts.TextToSpeech but Arabic is unavailable.
Anyone know of any free API's I can use for Arabic text to speak?
Sorry for my question being unclear. Below in Kotlin is an example of what I am trying to do:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
tts = TextToSpeech(view.context, TextToSpeech.OnInitListener { status ->
if (status != TextToSpeech.ERROR) {
val loc = Locale("ar")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val voiceName = loc.toLanguageTag()
val voice = Voice(voiceName, loc, Voice.QUALITY_HIGH, Voice.LATENCY_HIGH, false, null)
tts?.voice = voice
}
else {
tts?.language = loc
}
//tts?.language = Locale.Arabic
}
})
tts_button.setOnClickListener {
val toSpeak = "As-salamu alaykum"
//val toSpeak = "السلام عليكم"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
tts?.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null, null)
}
else {
tts?.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null)
}
}
}
Google's API clearly does not support Arabic. Anyone know of a different free API or library I can use instead that supports Arabic?
If you still think my question is unclear, please leave a comment and I will attempt to clarify further what I mean.
from How can I add text to speak for Arabic in Android?
No comments:
Post a Comment