generated from ztimson/template
Small tts fix
All checks were successful
Build and publish / Build Container (push) Successful in 1m26s
All checks were successful
Build and publish / Build Container (push) Successful in 1m26s
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user