From 834a95728d3ad1e785cbdab9edf41d801551653c Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 7 Feb 2022 12:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/service/TTSReadAloudService.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 13b251143..b2ef936b0 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -77,10 +77,16 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener kotlin.runCatching { MediaHelp.playSilentSound(this@TTSReadAloudService) val tts = textToSpeech ?: throw NoStackTraceException("tts is null") - tts.speak("", TextToSpeech.QUEUE_FLUSH, null, null) + var result = tts.speak("", TextToSpeech.QUEUE_FLUSH, null, null) + if (result == TextToSpeech.ERROR) { + throw NoStackTraceException("朗读出错:空") + } for (i in nowSpeak until contentList.size) { val text = contentList[i].replace(AppPattern.notReadAloudRegex, "") - tts.speak(text, TextToSpeech.QUEUE_ADD, null, AppConst.APP_TAG + i) + result = tts.speak(text, TextToSpeech.QUEUE_ADD, null, AppConst.APP_TAG + i) + if (result == TextToSpeech.ERROR) { + AppLog.put("tts朗读出错:$text") + } } }.onFailure { AppLog.put("tts朗读出错", it)