File tree Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -469,20 +469,25 @@ function maxLengthReached(){
469469
470470//send result message (partial or final)
471471function sendWebSpeechCompatibleRecognitionResult ( isFinal , transcript ) {
472- postMessage ( {
473- recognitionEvent : {
474- type : "result" ,
475- resultIndex : 0 ,
476- results : [ {
477- isFinal : isFinal ,
478- "0" : {
479- transcript : transcript
480- }
481- } ] ,
482- timeStamp : Date . now ( )
483- } ,
484- eventFormat : "webSpeechApi"
485- } ) ;
472+ if ( isFinal && ! transcript ) {
473+ //this is actually a 'nomatch'/'no-speech' error (no-speech usually fails more gently)
474+ sendWebSpeechCompatibleError ( "no-speech" , "Final result was empty" ) ;
475+ } else {
476+ postMessage ( {
477+ recognitionEvent : {
478+ type : "result" ,
479+ resultIndex : 0 ,
480+ results : [ {
481+ isFinal : isFinal ,
482+ "0" : {
483+ transcript : transcript
484+ }
485+ } ] ,
486+ timeStamp : Date . now ( )
487+ } ,
488+ eventFormat : "webSpeechApi"
489+ } ) ;
490+ }
486491}
487492function sendDefaultRecognitionResult ( event ) {
488493 if ( event && ! event . type ) event . type = "result" ;
You can’t perform that action at this time.
0 commit comments