|
|
@ -42,20 +42,21 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener |
|
|
|
clearTTS() |
|
|
|
clearTTS() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Synchronized |
|
|
|
override fun onInit(status: Int) { |
|
|
|
override fun onInit(status: Int) { |
|
|
|
launch { |
|
|
|
if (status == TextToSpeech.SUCCESS) { |
|
|
|
if (status == TextToSpeech.SUCCESS) { |
|
|
|
textToSpeech?.language = Locale.CHINA |
|
|
|
textToSpeech?.language = Locale.CHINA |
|
|
|
textToSpeech?.setOnUtteranceProgressListener(TTSUtteranceListener()) |
|
|
|
textToSpeech?.setOnUtteranceProgressListener(TTSUtteranceListener()) |
|
|
|
ttsIsSuccess = true |
|
|
|
ttsIsSuccess = true |
|
|
|
play() |
|
|
|
play() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
launch { |
|
|
|
toast(R.string.tts_init_failed) |
|
|
|
toast(R.string.tts_init_failed) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("DEPRECATION") |
|
|
|
@Synchronized |
|
|
|
override fun play() { |
|
|
|
override fun play() { |
|
|
|
if (contentList.isEmpty() || !ttsIsSuccess) { |
|
|
|
if (contentList.isEmpty() || !ttsIsSuccess) { |
|
|
|
return |
|
|
|
return |
|
|
|