pull/1604/head
kunfei 3 years ago
parent 1b53fa30c4
commit a4a074f54b
  1. 9
      app/src/main/java/io/legado/app/data/entities/Book.kt
  2. 3
      app/src/main/java/io/legado/app/model/ReadAloud.kt
  3. 3
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt

@ -189,6 +189,14 @@ data class Book(
config().imageStyle = imageStyle
}
fun setTtsEngine(ttsEngine: String?) {
config().ttsEngine = ttsEngine
}
fun getTtsEngine(): String? {
return config().ttsEngine
}
fun getDelTag(tag: Long): Boolean {
return config().delTag and tag == tag
}
@ -287,6 +295,7 @@ data class Book(
var imageStyle: String? = null,
var useReplaceRule: Boolean? = null,// 正文使用净化替换规则
var delTag: Long = 0L,//去除标签
var ttsEngine: String? = null,
) : Parcelable
class Converters {

@ -14,10 +14,11 @@ import splitties.init.appCtx
object ReadAloud {
private var aloudClass: Class<*> = getReadAloudClass()
val ttsEngine get() = ReadBook.book?.getTtsEngine() ?: AppConfig.ttsEngine
var httpTTS: HttpTTS? = null
private fun getReadAloudClass(): Class<*> {
val ttsEngine = AppConfig.ttsEngine
val ttsEngine = ttsEngine
if (ttsEngine.isNullOrBlank()) {
return TTSReadAloudService::class.java
}

@ -12,6 +12,7 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.MediaHelp
import io.legado.app.lib.dialogs.SelectItem
import io.legado.app.model.NoStackTraceException
import io.legado.app.model.ReadAloud
import io.legado.app.model.ReadBook
import io.legado.app.utils.*
import java.util.*
@ -36,7 +37,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
@Synchronized
private fun initTts() {
ttsInitFinish = false
val engine = GSON.fromJsonObject<SelectItem<String>>(AppConfig.ttsEngine)?.value
val engine = GSON.fromJsonObject<SelectItem<String>>(ReadAloud.ttsEngine)?.value
textToSpeech = if (engine.isNullOrBlank()) {
TextToSpeech(this, this)
} else {

Loading…
Cancel
Save