@@ -26,6 +26,7 @@ export class VoiceCaptureLegacy implements OnInit {
26
26
@Output ( ) voiceTranscript = new EventEmitter < string > ( ) ;
27
27
28
28
finalTranscript : string = '' ;
29
+ errorOccurred : boolean = false ;
29
30
recognizing : boolean = false ;
30
31
recognition : any = null ;
31
32
animationButton : boolean = false ;
@@ -81,6 +82,7 @@ export class VoiceCaptureLegacy implements OnInit {
81
82
82
83
this . recognition . onstart = ( ) => {
83
84
this . recognizing = true ;
85
+ this . errorOccurred = false ;
84
86
this . updateText ( 'speakNow' ) ;
85
87
this . animationButton = true ;
86
88
this . cdr . markForCheck ( ) ;
@@ -89,6 +91,7 @@ export class VoiceCaptureLegacy implements OnInit {
89
91
this . recognition . onerror = ( event : any ) => {
90
92
console . error ( 'Recognition error (onerror event):' , event . error ) ;
91
93
this . animationButton = false ;
94
+ this . errorOccurred = true ;
92
95
this . handleError ( event . error ) ;
93
96
this . cdr . markForCheck ( ) ;
94
97
} ;
@@ -99,7 +102,7 @@ export class VoiceCaptureLegacy implements OnInit {
99
102
if ( this . finalTranscript ) {
100
103
this . updateText ( '' ) ;
101
104
this . voiceTranscript . emit ( this . finalTranscript ) ;
102
- } else {
105
+ } else if ( ! this . errorOccurred ) {
103
106
console . warn ( 'Recognition stopped without result.' ) ;
104
107
this . updateText ( 'noSpeech' ) ;
105
108
0 commit comments