Fix TTS paused after forward/backward (#123)

This commit is contained in:
Huang Xin
2025-01-08 15:18:58 +01:00
committed by GitHub
parent 89b2eba2af
commit 3e43905321
2 changed files with 3 additions and 4 deletions
@@ -27,7 +27,7 @@ export class TTSController extends EventTarget {
if (!ssml) {
this.#nossmlCnt++;
// FIXME: in case we are at the end of the book, need a better way to handle this
if (this.#nossmlCnt < 100) {
if (this.#nossmlCnt < 10) {
await this.view.next(1);
this.forward();
}
@@ -47,8 +47,6 @@ export class TTSController extends EventTarget {
if (lastCode === 'end') {
this.forward();
} else {
this.state = 'paused';
}
}
@@ -72,7 +72,8 @@ function findMark(charIndex: number, marks: TTSMark[]) {
async function* speakWithBoundary(ssml: string) {
const lang = getXmlLang(ssml);
const { plainText, marks } = parseSSMLMarks(ssml);
// console.log('text', ssml, plainText, marks);
// console.log('ssml', ssml, marks);
// console.log('text', plainText);
const synth = window.speechSynthesis;
const utterance = new SpeechSynthesisUtterance(plainText);