|
|
@ -95,9 +95,9 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
task = execute { |
|
|
|
task = execute { |
|
|
|
clearSpeakCache() |
|
|
|
clearSpeakCache() |
|
|
|
removeCacheFile() |
|
|
|
removeCacheFile() |
|
|
|
ReadAloud.httpTTS?.let { httpTts -> |
|
|
|
val httpTts = ReadAloud.httpTTS ?: return@execute |
|
|
|
contentList.forEachIndexed { index, item -> |
|
|
|
contentList.forEachIndexed { index, item -> |
|
|
|
if (isActive) { |
|
|
|
ensureActive() |
|
|
|
val speakText = item.replace(AppPattern.notReadAloudRegex, "") |
|
|
|
val speakText = item.replace(AppPattern.notReadAloudRegex, "") |
|
|
|
val fileName = |
|
|
|
val fileName = |
|
|
|
md5SpeakFileName( |
|
|
|
md5SpeakFileName( |
|
|
@ -112,14 +112,14 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
playAudio(fis.fd) |
|
|
|
playAudio(fis.fd) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (hasSpeakCache(fileName)) { //缓存文件还在,可能还没下载完 |
|
|
|
} else if (hasSpeakCache(fileName)) { //缓存文件还在,可能还没下载完 |
|
|
|
return@let |
|
|
|
return@forEachIndexed |
|
|
|
} else { //没有下载并且没有缓存文件 |
|
|
|
} else { //没有下载并且没有缓存文件 |
|
|
|
try { |
|
|
|
|
|
|
|
if (speakText.isEmpty()) { |
|
|
|
if (speakText.isEmpty()) { |
|
|
|
ensureActive() |
|
|
|
ensureActive() |
|
|
|
createSilentSound(fileName) |
|
|
|
createSilentSound(fileName) |
|
|
|
return@let |
|
|
|
return@forEachIndexed |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
createSpeakCache(fileName) |
|
|
|
createSpeakCache(fileName) |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
httpTts.url, |
|
|
|
httpTts.url, |
|
|
@ -197,8 +197,6 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Synchronized |
|
|
|
@Synchronized |
|
|
|
private fun playAudio(fd: FileDescriptor) { |
|
|
|
private fun playAudio(fd: FileDescriptor) { |
|
|
|