|
|
@ -167,17 +167,22 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac |
|
|
|
} |
|
|
|
} |
|
|
|
if (!ttsInitFinish) return |
|
|
|
if (!ttsInitFinish) return |
|
|
|
if (text == "") return |
|
|
|
if (text == "") return |
|
|
|
if (textToSpeech?.isSpeaking == true) |
|
|
|
if (textToSpeech?.isSpeaking == true) { |
|
|
|
textToSpeech?.stop() |
|
|
|
textToSpeech?.stop() |
|
|
|
|
|
|
|
} |
|
|
|
textToSpeech?.speak(text, TextToSpeech.QUEUE_ADD, null, "select_text") |
|
|
|
textToSpeech?.speak(text, TextToSpeech.QUEUE_ADD, null, "select_text") |
|
|
|
lastText = "" |
|
|
|
lastText = "" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Synchronized |
|
|
|
@Synchronized |
|
|
|
override fun onInit(status: Int) { |
|
|
|
override fun onInit(status: Int) { |
|
|
|
textToSpeech?.language = Locale.CHINA |
|
|
|
if (status == TextToSpeech.SUCCESS) { |
|
|
|
ttsInitFinish = true |
|
|
|
textToSpeech?.language = Locale.CHINA |
|
|
|
readAloud(lastText) |
|
|
|
ttsInitFinish = true |
|
|
|
|
|
|
|
readAloud(lastText) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
context.toastOnUi(R.string.tts_init_failed) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequiresApi(Build.VERSION_CODES.M) |
|
|
|
@RequiresApi(Build.VERSION_CODES.M) |
|
|
|