pull/1327/head
gedoor 3 years ago
parent eb47b3d6c1
commit b3d376ee9e
  1. 13
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt
  2. 2
      app/src/main/java/io/legado/app/utils/StringUtils.kt
  3. 4
      app/src/main/res/xml/pref_config_aloud.xml

@ -8,11 +8,9 @@ import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.help.AppConfig
import io.legado.app.help.MediaHelp
import io.legado.app.lib.dialogs.SelectItem
import io.legado.app.model.ReadBook
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent
import io.legado.app.utils.servicePendingIntent
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.*
import java.util.*
class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener {
@ -35,7 +33,12 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
@Synchronized
private fun initTts() {
ttsInitFinish = false
textToSpeech = TextToSpeech(this, this)
val engine = GSON.fromJsonObject<SelectItem<String>>(AppConfig.ttsEngine)?.value
textToSpeech = if (engine.isNullOrBlank()) {
TextToSpeech(this, this)
} else {
TextToSpeech(this, this, engine)
}
}
@Synchronized

@ -245,7 +245,7 @@ object StringUtils {
* 是否数字
*/
fun isNumeric(str: String): Boolean {
val pattern = Pattern.compile("[0-9]+")
val pattern = Pattern.compile("-?[0-9]+")
val isNum = pattern.matcher(str)
return isNum.matches()
}

@ -25,8 +25,8 @@
<io.legado.app.ui.widget.prefs.Preference
android:defaultValue="false"
android:title="@string/speak_engine"
android:summary="本地TTS"
android:key="speakEngine"
android:summary="TTS"
android:key="appTtsEngine"
app:iconSpaceReserved="false" />
</io.legado.app.ui.widget.prefs.PreferenceCategory>

Loading…
Cancel
Save