优化
This commit is contained in:
@@ -189,6 +189,14 @@ data class Book(
|
|||||||
config().imageStyle = imageStyle
|
config().imageStyle = imageStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setTtsEngine(ttsEngine: String?) {
|
||||||
|
config().ttsEngine = ttsEngine
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTtsEngine(): String? {
|
||||||
|
return config().ttsEngine
|
||||||
|
}
|
||||||
|
|
||||||
fun getDelTag(tag: Long): Boolean {
|
fun getDelTag(tag: Long): Boolean {
|
||||||
return config().delTag and tag == tag
|
return config().delTag and tag == tag
|
||||||
}
|
}
|
||||||
@@ -287,6 +295,7 @@ data class Book(
|
|||||||
var imageStyle: String? = null,
|
var imageStyle: String? = null,
|
||||||
var useReplaceRule: Boolean? = null,// 正文使用净化替换规则
|
var useReplaceRule: Boolean? = null,// 正文使用净化替换规则
|
||||||
var delTag: Long = 0L,//去除标签
|
var delTag: Long = 0L,//去除标签
|
||||||
|
var ttsEngine: String? = null,
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
||||||
class Converters {
|
class Converters {
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ import splitties.init.appCtx
|
|||||||
|
|
||||||
object ReadAloud {
|
object ReadAloud {
|
||||||
private var aloudClass: Class<*> = getReadAloudClass()
|
private var aloudClass: Class<*> = getReadAloudClass()
|
||||||
|
val ttsEngine get() = ReadBook.book?.getTtsEngine() ?: AppConfig.ttsEngine
|
||||||
var httpTTS: HttpTTS? = null
|
var httpTTS: HttpTTS? = null
|
||||||
|
|
||||||
private fun getReadAloudClass(): Class<*> {
|
private fun getReadAloudClass(): Class<*> {
|
||||||
val ttsEngine = AppConfig.ttsEngine
|
val ttsEngine = ttsEngine
|
||||||
if (ttsEngine.isNullOrBlank()) {
|
if (ttsEngine.isNullOrBlank()) {
|
||||||
return TTSReadAloudService::class.java
|
return TTSReadAloudService::class.java
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import io.legado.app.help.AppConfig
|
|||||||
import io.legado.app.help.MediaHelp
|
import io.legado.app.help.MediaHelp
|
||||||
import io.legado.app.lib.dialogs.SelectItem
|
import io.legado.app.lib.dialogs.SelectItem
|
||||||
import io.legado.app.model.NoStackTraceException
|
import io.legado.app.model.NoStackTraceException
|
||||||
|
import io.legado.app.model.ReadAloud
|
||||||
import io.legado.app.model.ReadBook
|
import io.legado.app.model.ReadBook
|
||||||
import io.legado.app.utils.*
|
import io.legado.app.utils.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -36,7 +37,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
|
|||||||
@Synchronized
|
@Synchronized
|
||||||
private fun initTts() {
|
private fun initTts() {
|
||||||
ttsInitFinish = false
|
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 = if (engine.isNullOrBlank()) {
|
||||||
TextToSpeech(this, this)
|
TextToSpeech(this, this)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user