gotev / android-speech

Android speech recognition and text to speech made easy
http://gotev.github.io/android-speech/
Apache License 2.0
473 stars 156 forks source link

Arabic text to speech #36

Closed joeshc closed 4 years ago

joeshc commented 4 years ago

Is it possible to read Arabic text to speech? I've tested not working(Locale mLocale = new Locale("ar"); Please help,Advance thanks

gotev commented 4 years ago

Hi @joeshc it should be possible, since the library uses Android's internal Voice Search capabilities, but it depends on the device and Android version.

To get a list of supported locales:

fun supportedLanguages() {
    val supportedLanguages = RecognizerIntent.getVoiceDetailsIntent(this)
    sendOrderedBroadcast(supportedLanguages, null, object : BroadcastReceiver() {
        override fun onReceive(p0: Context?, p1: Intent?) {
            val supported = getResultExtras(true).getStringArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)
            // do what you need with those values
        }
    }, null, Activity.RESULT_OK, null, null)
}

Executing this on a Google Pixel 4 with Android API 29 returns the following locales:

af-ZA, az-AZ, id-ID, ms-MY, jv-ID, su-ID, ca-ES, cs-CZ, da-DK, de-DE, de-AT, 
et-EE, en-AU, en-CA, en-001, en-GH, en-IN, en-IE, en-KE, en-NZ, en-NG, en-PH, 
en-ZA, en-TZ, en-GB, en-US, es-AR, es-BO, es-CL, es-CO, es-CR, es-EC, es-US, 
es-SV, es-ES, es-GT, es-HN, es-MX, es-NI, es-PA, es-PY, es-PE, es-PR, es-DO, 
es-UY, es-VE, eu-ES, fil-PH, fr-FR, fr-CA, gl-ES, hr-HR, zu-ZA, is-IS, it-IT, 
sw, sw-TZ, lv-LV, lt-LT, hu-HU, nl-NL, nb-NO, uz-UZ, pl-PL, pt-BR, pt-PT, 
ro-RO, sl-SI, sk-SK, fi-FI, sv-SE, vi-VN, tr-TR, el-GR, bg-BG, ru-RU, sr-RS, 
uk-UA, ka-GE, hy-AM, he-IL, ar-IL, ar-JO, ar-AE, ar-BH, ar-DZ, ar-SA, ar-KW, 
ar-MA, ar-TN, ar-OM, ar-PS, ar-QA, ar-LB, ar-EG, fa-IR, ur-PK, ur-IN, am-ET, 
hi-IN, ta-IN, ta-LK, ta-SG, ta-MY, bn-BD, bn-IN, km-KH, kn-IN, mr-IN, gu-IN, 
si-LK, te-IN, ml-IN, ne-NP, lo-LA, th-TH, my-MM, ko-KR, cmn-Hans-CN, 
cmn-Hans-HK, cmn-Hant-TW, yue-Hant-HK, ja-JP, en-ID, en-TH