|
|
@ -41,6 +41,7 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
private val ttsFolderPath: String by lazy { |
|
|
|
private val ttsFolderPath: String by lazy { |
|
|
|
cacheDir.absolutePath + File.separator + "httpTTS" + File.separator |
|
|
|
cacheDir.absolutePath + File.separator + "httpTTS" + File.separator |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private var speechRate: Int = AppConfig.speechRatePlay |
|
|
|
private val cacheFiles = hashSetOf<String>() |
|
|
|
private val cacheFiles = hashSetOf<String>() |
|
|
|
private var task: Coroutine<*>? = null |
|
|
|
private var task: Coroutine<*>? = null |
|
|
|
private var playIndexJob: Job? = null |
|
|
|
private var playIndexJob: Job? = null |
|
|
@ -113,7 +114,7 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
contentList.forEachIndexed { index, content -> |
|
|
|
contentList.forEachIndexed { index, content -> |
|
|
|
ensureActive() |
|
|
|
ensureActive() |
|
|
|
val fileName = |
|
|
|
val fileName = |
|
|
|
md5SpeakFileName(httpTts.url, AppConfig.ttsSpeechRate.toString(), content) |
|
|
|
md5SpeakFileName(httpTts.url, speechRate.toString(), content) |
|
|
|
val speakText = content.replace(AppPattern.notReadAloudRegex, "") |
|
|
|
val speakText = content.replace(AppPattern.notReadAloudRegex, "") |
|
|
|
if (hasSpeakFile(fileName)) { //已经下载好的语音缓存 |
|
|
|
if (hasSpeakFile(fileName)) { //已经下载好的语音缓存 |
|
|
|
if (index == nowSpeak) { |
|
|
|
if (index == nowSpeak) { |
|
|
@ -131,7 +132,7 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
httpTts.url, |
|
|
|
httpTts.url, |
|
|
|
speakText = speakText, |
|
|
|
speakText = speakText, |
|
|
|
speakSpeed = AppConfig.ttsSpeechRate, |
|
|
|
speakSpeed = speechRate, |
|
|
|
source = httpTts, |
|
|
|
source = httpTts, |
|
|
|
headerMapF = httpTts.getHeaderMap(true) |
|
|
|
headerMapF = httpTts.getHeaderMap(true) |
|
|
|
) |
|
|
|
) |
|
|
@ -317,6 +318,7 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
override fun upSpeechRate(reset: Boolean) { |
|
|
|
override fun upSpeechRate(reset: Boolean) { |
|
|
|
task?.cancel() |
|
|
|
task?.cancel() |
|
|
|
exoPlayer.stop() |
|
|
|
exoPlayer.stop() |
|
|
|
|
|
|
|
speechRate = AppConfig.speechRatePlay |
|
|
|
downloadAudio() |
|
|
|
downloadAudio() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|