From 16ed77693c7cbfab991b27823668024f2453a61b Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 21 Sep 2021 14:00:14 +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 --- .../legado/app/service/HttpReadAloudService.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 23d1a6d43..d065b4927 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -86,16 +86,14 @@ class HttpReadAloudService : BaseReadAloudService(), task?.cancel() task = execute { removeCacheFile() - ReadAloud.httpTTS?.let { + ReadAloud.httpTTS?.let { httpTts -> contentList.forEachIndexed { index, item -> if (isActive) { val fileName = - md5SpeakFileName(it.url, AppConfig.ttsSpeechRate.toString(), item) + md5SpeakFileName(httpTts.url, AppConfig.ttsSpeechRate.toString(), item) if (hasSpeakFile(fileName)) { //已经下载好的语音缓存 if (index == nowSpeak) { val file = getSpeakFileAsMd5(fileName) - - @Suppress("BlockingMethodInNonBlockingContext") val fis = FileInputStream(file) playAudio(fis.fd) } @@ -105,19 +103,17 @@ class HttpReadAloudService : BaseReadAloudService(), try { createSpeakCacheFile(fileName) AnalyzeUrl( - it.url, + httpTts.url, speakText = item, - speakSpeed = AppConfig.ttsSpeechRate + speakSpeed = AppConfig.ttsSpeechRate, + source = httpTts, + headerMapF = httpTts.getHeaderMap(true) ).getByteArray().let { bytes -> ensureActive() - val file = getSpeakFileAsMd5IfNotExist(fileName) - //val file = getSpeakFile(index) file.writeBytes(bytes) removeSpeakCacheFile(fileName) - val fis = FileInputStream(file) - if (index == nowSpeak) { @Suppress("BlockingMethodInNonBlockingContext") playAudio(fis.fd)