Skip to content

Commit

Permalink
adjustment errorOccurred
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasferreiralimax committed Oct 25, 2024
1 parent 95fcd2c commit 884f29b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class VoiceCaptureLegacy implements OnInit {
@Output() voiceTranscript = new EventEmitter<string>();

finalTranscript: string = '';
errorOccurred: boolean = false;
recognizing: boolean = false;
recognition: any = null;
animationButton: boolean = false;
Expand Down Expand Up @@ -81,6 +82,7 @@ export class VoiceCaptureLegacy implements OnInit {

this.recognition.onstart = () => {
this.recognizing = true;
this.errorOccurred = false;
this.updateText('speakNow');
this.animationButton = true;
this.cdr.markForCheck();
Expand All @@ -89,6 +91,7 @@ export class VoiceCaptureLegacy implements OnInit {
this.recognition.onerror = (event: any) => {
console.error('Recognition error (onerror event):', event.error);
this.animationButton = false;
this.errorOccurred = true;
this.handleError(event.error);
this.cdr.markForCheck();
};
Expand All @@ -99,7 +102,7 @@ export class VoiceCaptureLegacy implements OnInit {
if (this.finalTranscript) {
this.updateText('');
this.voiceTranscript.emit(this.finalTranscript);
} else {
} else if (!this.errorOccurred) {
console.warn('Recognition stopped without result.');
this.updateText('noSpeech');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class VoiceCapture implements OnInit {

finalTranscript: string = '';
recognizing: boolean = false;
errorOccurred: boolean = false;
recognition: any = null;
animationButton: boolean = false;
translations: { [key: string]: { [key: string]: string } } = translates;
Expand Down Expand Up @@ -84,6 +85,7 @@ export class VoiceCapture implements OnInit {

this.recognition.onstart = () => {
this.recognizing = true;
this.errorOccurred = false;
this.updateText('speakNow');
this.animationButton = true;
this.cdr.markForCheck();
Expand All @@ -92,6 +94,7 @@ export class VoiceCapture implements OnInit {
this.recognition.onerror = (event: any) => {
console.error('Recognition error (onerror event):', event.error);
this.animationButton = false;
this.errorOccurred = true;
this.handleError(event.error);
this.cdr.markForCheck();
};
Expand All @@ -102,7 +105,7 @@ export class VoiceCapture implements OnInit {
if (this.finalTranscript) {
this.updateText('');
this.voiceTranscript.emit(this.finalTranscript);
} else {
} else if (!this.errorOccurred) {
console.warn('Recognition stopped without result.');
this.updateText('noSpeech');

Expand Down

0 comments on commit 884f29b

Please sign in to comment.