+11
-8
@@ -102,21 +102,24 @@ export class JarvisDaemon extends EventEmitter {
|
||||
if (this.state === 'SPEAKING') this.setState('LISTENING');
|
||||
}
|
||||
_speakReply(spoken) {
|
||||
if (!this.voiceLoop) {
|
||||
this._finishSpeech();
|
||||
return;
|
||||
}
|
||||
const play = async () => {
|
||||
await this.ensureTts();
|
||||
const playing = this.voiceLoop?.speak?.(spoken);
|
||||
if (!playing) {
|
||||
if (!this.voiceLoop?.status?.tts) {
|
||||
const reason = this.voiceLoop?.status?.errors?.tts;
|
||||
if (reason && reason !== 'Spoken replies are disabled') this.emit('Error', 'TTS', reason);
|
||||
this._finishSpeech();
|
||||
return;
|
||||
}
|
||||
await playing;
|
||||
await this.voiceLoop.speak(spoken);
|
||||
};
|
||||
Promise.resolve(play()).catch((error) => {
|
||||
this.emit('Error', 'TTS', error.message);
|
||||
if (this.state === 'SPEAKING') this._finishSpeech();
|
||||
});
|
||||
Promise.resolve(play())
|
||||
.catch((error) => {
|
||||
this.emit('Error', 'TTS', error.message);
|
||||
})
|
||||
.finally(() => this._finishSpeech());
|
||||
}
|
||||
async ensureTts() {
|
||||
if (!this.voiceLoop) return;
|
||||
|
||||
Reference in New Issue
Block a user