Small tts fix
All checks were successful
Build and publish / Build Container (push) Successful in 1m26s

This commit is contained in:
2026-03-03 20:23:59 -05:00
parent 5018311990
commit 6c2c3a0d07
2 changed files with 9 additions and 16 deletions

View File

@@ -101,7 +101,7 @@ export class TTS {
}
async speak(t) {
if (!t.trim()) return;
if(!t.trim()) return;
await this._voicesLoaded;
if(this._currentUtterance && !this._isStreaming) this.stop();
return new Promise((res, rej) => {
@@ -118,7 +118,8 @@ export class TTS {
else rej(e);
};
window.speechSynthesis.speak(u);
});
this._emit('onSentenceStart', {sentence: t});
}).finally(() => this._emit('onSentenceEnd', {sentence: t}));
}
stop() {
@@ -143,11 +144,7 @@ export class TTS {
if(ss) {
ss.forEach(s => {
const sentence = s.trim();
sentenceQueue = sentenceQueue.then(async () => {
this._emit('onSentenceStart', { sentence });
await this.speak(sentence);
this._emit('onSentenceEnd', { sentence });
});
sentenceQueue = sentenceQueue.then(async () => this.speak(sentence));
});
}
buf = buf.replace(rx, '');
@@ -155,11 +152,7 @@ export class TTS {
done: async () => {
if (buf.trim()) {
const sentence = buf.trim();
sentenceQueue = sentenceQueue.then(async () => {
this._emit('onSentenceStart', { sentence });
await this.speak(sentence);
this._emit('onSentenceEnd', { sentence });
});
sentenceQueue = sentenceQueue.then(async () => this.speak(sentence));
buf = '';
}
await sentenceQueue;