|
94 | 94 | <label for="node-input-streaming-mute" style="width: 70%;"> Mute in Streaming Mode</label> |
95 | 95 | </div> |
96 | 96 |
|
| 97 | + <div class="form-row"> |
| 98 | + <label> </label> |
| 99 | + <input type="checkbox" id="node-input-discard-listening" style="display: inline-block; width: auto; vertical-align: top;"> |
| 100 | + <label for="node-input-discard-listening" style="width: 70%;"> Discard Listening events from STT</label> |
| 101 | + </div> |
| 102 | + |
| 103 | + <div class="form-row"> |
| 104 | + <label> </label> |
| 105 | + <input type="checkbox" id="node-input-auto-connect" style="display: inline-block; width: auto; vertical-align: top;"> |
| 106 | + <label for="node-input-auto-connect" style="width: 70%;"> Attempt auto connect on connection close</label> |
| 107 | + </div> |
| 108 | + |
97 | 109 | <div class="form-row"> |
98 | 110 | <label> </label> |
99 | 111 | <input type="checkbox" id="node-input-speakerlabels"style="display: inline-block; width: auto; vertical-align: top;"></input> |
|
155 | 167 | <code>start</code> or <code>stop</code> or an audio blob. No token is needed |
156 | 168 | as the node takes care of that step.</p> |
157 | 169 | <p>>The Mute option allows for the supression of session timeout messages.</p> |
| 170 | + <p>>The Discard Listening option allows for listening events from STT to be discarded.</p> |
158 | 171 | <p>For more information about the Speech To Text service, read the <a href="https://www.ibm.com/watson/services/speech-to-text/">documentation</a>.</p> |
159 | 172 | </script> |
160 | 173 |
|
|
193 | 206 | return self.indexOf(value) === index; |
194 | 207 | } |
195 | 208 |
|
| 209 | + stt.showSelectedFields = function(fields) { |
| 210 | + for (i = 0; i < fields.length; i++) { |
| 211 | + $(fields[i]).parent().show(); |
| 212 | + } |
| 213 | + } |
| 214 | + |
| 215 | + stt.hideSelectedFields = function(fields) { |
| 216 | + for (i = 0; i < fields.length; i++) { |
| 217 | + $(fields[i]).parent().hide(); |
| 218 | + } |
| 219 | + } |
| 220 | + |
| 221 | + |
196 | 222 | // Function to be used at the start, as don't want to expose any fields, unless the models are |
197 | 223 | // available. The models can only be fetched if the credentials are available. |
198 | 224 | stt.hideEverything = function () { |
199 | 225 | if (!stt.models) { |
| 226 | + var fields = []; |
200 | 227 | $('#credentials-not-found').show(); |
201 | | - $('label#node-label-message').parent().hide(); |
202 | | - $('input#node-input-alternatives').parent().hide(); |
203 | | - $('input#node-input-speakerlabels').parent().hide(); |
204 | | - $('input#node-input-smartformatting').parent().hide(); |
205 | | - $('select#node-input-lang').parent().hide(); |
206 | | - $('select#node-input-band').parent().hide(); |
207 | | - $('select#node-input-langcustom').parent().hide(); |
| 228 | + |
| 229 | + fields.push('#node-label-message' |
| 230 | + + ', #node-input-alternatives' |
| 231 | + + ', #node-input-speakerlabels' |
| 232 | + + ', #node-input-smartformatting' |
| 233 | + + ', #node-input-lang' |
| 234 | + + ', #node-input-band' |
| 235 | + + ', #node-input-langcustom'); |
| 236 | + stt.hideSelectedFields(fields); |
208 | 237 | } |
209 | 238 | } |
210 | 239 |
|
211 | 240 | // Check if there is a model then can show the fields. |
212 | 241 | // available. The models can only be fetched if the credentials are available. |
213 | 242 | stt.VisibilityCheck = function () { |
| 243 | + var showFields = []; |
| 244 | + var hideFields = []; |
214 | 245 | if (stt.models) { |
215 | | - $('label#node-label-message').parent().hide(); |
216 | | - $('input#node-input-alternatives').parent().show(); |
217 | | - $('input#node-input-speakerlabels').parent().show(); |
218 | | - $('input#node-input-smartformatting').parent().show(); |
219 | | - $('select#node-input-lang').parent().show(); |
220 | | - //$('select#node-input-langcustom').parent().show(); |
221 | | - $('select#node-input-band').parent().show(); |
| 246 | + showFields.push('#node-input-alternatives' |
| 247 | + + ', #node-input-speakerlabels' |
| 248 | + + ', #node-input-smartformatting' |
| 249 | + + ', #node-input-lang' |
| 250 | + + ', #node-input-band'); |
| 251 | + |
| 252 | + hideFields.push('#node-label-message'); |
222 | 253 | } else { |
223 | | - $('label#node-label-message').parent().hide(); |
224 | | - $('input#node-input-alternatives').parent().hide(); |
225 | | - $('input#node-input-speakerlabels').parent().hide(); |
226 | | - $('input#node-input-smartformatting').parent().hide(); |
227 | | - $('select#node-input-lang').parent().hide(); |
228 | | - $('select#node-input-langcustom').parent().hide(); |
229 | | - $('select#node-input-band').parent().hide(); |
| 254 | + hideFields.push('#node-label-message' |
| 255 | + + ', #node-input-alternatives' |
| 256 | + + ', #node-input-speakerlabels' |
| 257 | + + ', #node-input-smartformatting' |
| 258 | + + ', #node-input-langcustom' |
| 259 | + + ', #node-input-lang' |
| 260 | + + ', #node-input-band'); |
230 | 261 | } |
| 262 | + stt.hideSelectedFields(hideFields); |
| 263 | + stt.showSelectedFields(showFields); |
231 | 264 | } |
232 | 265 |
|
233 | 266 |
|
|
372 | 405 | } |
373 | 406 | }); |
374 | 407 |
|
| 408 | + $('#node-input-streaming-mode').change(function () { |
| 409 | + var fields = []; |
| 410 | + fields.push('#node-input-streaming-mute' |
| 411 | + + ', #node-input-discard-listening' |
| 412 | + + ', #node-input-auto-connect'); |
| 413 | + |
| 414 | + var checked = $('#node-input-streaming-mode').prop('checked') |
| 415 | + if (checked) { |
| 416 | + stt.showSelectedFields(fields); |
| 417 | + } else { |
| 418 | + stt.hideSelectedFields(fields); |
| 419 | + } |
| 420 | + }); |
| 421 | + |
375 | 422 | $('#node-input-flushcache').click(function () { |
376 | 423 | stt.flushCache(); |
377 | 424 | }); |
|
550 | 597 | 'payload-response' :{value: false}, |
551 | 598 | 'streaming-mode' :{value: false}, |
552 | 599 | 'streaming-mute' :{value: true}, |
| 600 | + 'discard-listening' :{value: false}, |
553 | 601 | 'default-endpoint' :{value: true}, |
554 | 602 | 'service-endpoint' :{value: 'https://stream.watsonplatform.net/speech-to-text/api'} |
555 | 603 | }, |
|
0 commit comments