|
|
|
@ -43,6 +43,7 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
|
private val cacheFiles = hashSetOf<String>() |
|
|
|
|
private var downloadTask: Coroutine<*>? = null |
|
|
|
|
private var playIndexJob: Job? = null |
|
|
|
|
private var downloadTaskIsActive = false |
|
|
|
|
private var downloadErrorNo: Int = 0 |
|
|
|
|
private var playErrorNo = 0 |
|
|
|
|
|
|
|
|
@ -103,7 +104,12 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun downloadAudio() { |
|
|
|
|
launch { |
|
|
|
|
downloadTask?.cancel() |
|
|
|
|
while (downloadTaskIsActive) { |
|
|
|
|
//在线tts大部分只能单线程,等待上次访问结束 |
|
|
|
|
delay(100) |
|
|
|
|
} |
|
|
|
|
downloadTask = execute { |
|
|
|
|
clearSpeakCache() |
|
|
|
|
removeCacheFile() |
|
|
|
@ -202,6 +208,11 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}.onStart { |
|
|
|
|
downloadTaskIsActive = true |
|
|
|
|
}.onFinally { |
|
|
|
|
downloadTaskIsActive = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|