@@ -70,12 +70,12 @@ onMounted(async () => {
70
70
71
71
})
72
72
73
- function _initSTT (continuous = false , phrase = false ) {
73
+ function _initSTT (phrase = false ) {
74
74
const sr = new (window .SpeechRecognition || window .webkitSpeechRecognition )();
75
75
const _type = phrase ? ' Phrase activation' : ' Transcriber'
76
76
sr .lang = store .speechRecognitionLang ;
77
- sr .continuous = continuous ;
78
- sr .interimResults = true ;
77
+ sr .continuous = false ;
78
+ sr .interimResults = store . speechRecognitionInterimResults ;
79
79
sr .maxAlternatives = 1 ;
80
80
sr .started = false ;
81
81
@@ -85,16 +85,16 @@ function _initSTT(continuous = false, phrase = false) {
85
85
sr .addEventListener (" start" , () => {
86
86
sr .started = true ;
87
87
if (window .speechDebug )
88
- console .log (` STT ${ _type } started` , ' color: #ffcc00' );
88
+ console .log (` %c STT ${ _type } started` , ' color: #ffcc00' );
89
89
})
90
90
sr .addEventListener (" end" , () => {
91
91
sr .started = false ;
92
92
if (window .speechDebug )
93
- console .log (` STT ${ _type } finished` , ' color: #ffcc00' );
93
+ console .log (` %c STT ${ _type } finished` , ' color: #ffcc00' );
94
94
})
95
95
96
96
sr .onerror = (event ) => {
97
- console .log (` Error occurred in the speech recognition: ${ _type } ` , event )
97
+ console .log (` %c Error occurred in the speech recognition: ${ _type } ` , ' color: #ff0000 ' , event )
98
98
// Don't restart if we got a not-allowed error, usually because the user has not granted permission
99
99
if (event .error === ' not-allowed' ) {
100
100
store .speechRecognition = false ; // Disable speech recognition entirely
@@ -151,7 +151,7 @@ function initSTT() {
151
151
}
152
152
153
153
function initSTTPhrase () {
154
- sttPhrase .value = _initSTT (true , true );
154
+ sttPhrase .value = _initSTT (true );
155
155
156
156
sttPhrase .value .onresult = (event ) => {
157
157
const text = sttPhrase .value .gatherText (event )
@@ -177,7 +177,7 @@ function initSTTPhrase() {
177
177
}
178
178
})
179
179
if (window .speechDebug )
180
- console .log (` starting phrase activation SR... ` , ' color: #ffcc00' );
180
+ console .log (` %c starting phrase activation SR... ` , ' color: #ffcc00' );
181
181
sttPhrase .value .start ();
182
182
}
183
183
0 commit comments