Skip to content

Commit

Permalink
prevent unintended session restarts in VoiceProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
boluwatifee4 committed Jan 28, 2025
1 parent 403cfc1 commit a02dcca
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libs/core/src/lib/speech/voice-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ export class VoiceProcessor {
console.log('VoiceProcessor: Session ended.');
this.isListening = false;

// Only restart if it was NOT intentionally stopped
if (this.restartAllowed && !this.isStoppedSpeechRecog) {
console.log('VoiceProcessor: Restarting session...');
this.startListening(() => {
// console.log('VoiceProcessor: Restarted session.');
});
console.log('VoiceProcessor: Restarting session due to unexpected stop...');
// eslint-disable-next-line @typescript-eslint/no-empty-function
setTimeout(() => this.startListening(() => { }), 560); // Small delay to prevent spam
}
}


/** Handle errors during speech recognition */
private handleError(event: any): void {
console.error('VoiceProcessor: Error occurred:', event.error);
Expand Down

0 comments on commit a02dcca

Please sign in to comment.