fix: 系统 TTS 调速立即重播当前位置
This commit is contained in:
1 file changed
+6
@@ -32,6 +32,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
|
|||||||
private var ttsInitFinish = false
|
private var ttsInitFinish = false
|
||||||
private val ttsUtteranceListener = TTSUtteranceListener()
|
private val ttsUtteranceListener = TTSUtteranceListener()
|
||||||
private var speakJob: Coroutine<*>? = null
|
private var speakJob: Coroutine<*>? = null
|
||||||
|
private var utteranceStartPos = 0
|
||||||
private val TAG = "TTSReadAloudService"
|
private val TAG = "TTSReadAloudService"
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
@@ -161,6 +162,9 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
|
|||||||
} else {
|
} else {
|
||||||
val speechRate = (ReadConfig.ttsSpeechRate + 5) / 10f
|
val speechRate = (ReadConfig.ttsSpeechRate + 5) / 10f
|
||||||
textToSpeech?.setSpeechRate(speechRate)
|
textToSpeech?.setSpeechRate(speechRate)
|
||||||
|
if (reset && !pause) {
|
||||||
|
play()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +196,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
|
|||||||
|
|
||||||
override fun onStart(s: String) {
|
override fun onStart(s: String) {
|
||||||
LogUtils.d(TAG, "onStart nowSpeak:$nowSpeak pageIndex:$pageIndex utteranceId:$s")
|
LogUtils.d(TAG, "onStart nowSpeak:$nowSpeak pageIndex:$pageIndex utteranceId:$s")
|
||||||
|
utteranceStartPos = paragraphStartPos
|
||||||
textChapter?.let {
|
textChapter?.let {
|
||||||
if (contentList[nowSpeak].matches(AppPattern.notReadAloudRegex)) {
|
if (contentList[nowSpeak].matches(AppPattern.notReadAloudRegex)) {
|
||||||
nextParagraph()
|
nextParagraph()
|
||||||
@@ -214,6 +219,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
|
|||||||
|
|
||||||
override fun onRangeStart(utteranceId: String?, start: Int, end: Int, frame: Int) {
|
override fun onRangeStart(utteranceId: String?, start: Int, end: Int, frame: Int) {
|
||||||
super.onRangeStart(utteranceId, start, end, frame)
|
super.onRangeStart(utteranceId, start, end, frame)
|
||||||
|
paragraphStartPos = utteranceStartPos + start
|
||||||
val msg =
|
val msg =
|
||||||
"onRangeStart nowSpeak:$nowSpeak pageIndex:$pageIndex utteranceId:$utteranceId start:$start end:$end frame:$frame"
|
"onRangeStart nowSpeak:$nowSpeak pageIndex:$pageIndex utteranceId:$utteranceId start:$start end:$end frame:$frame"
|
||||||
LogUtils.d(TAG, msg)
|
LogUtils.d(TAG, msg)
|
||||||
|
|||||||
Reference in new issue
Block a user