我使用以下代码将语言设置为文本到语音,但出现以下异常。
override fun onInit(status: Int) {
if (textToSpeech == null || status == TextToSpeech.ERROR) {
isTextToSpeechInitialized = false
return
}
isTextToSpeechInitialized = true
if (textToSpeech!!.isLanguageAvailable(CountryConfiguration.locale) == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
textToSpeech!!.language = CountryConfiguration.locale
}
readNextFile()
}
例外情况如下:
Fatal Exception: java.lang.IllegalArgumentException: Invalid int: "OS"
at android.os.Parcel.readException(Parcel.java:1625)
android.speech.tts.TextToSpeech.setLanguage(TextToSpeech.java:1535)