Skip to content Skip to sidebar Skip to footer

How To Restart A Speechrecognition Function In Framer?

I want to build a function in Framer (coffeescript) where I can say a specific word as voice input and something happens. For example I say 'apple' then a rectangle turns green. If

Solution 1:

Use the prefixed properties webkitSpeechRecognition() and webkitSpeechGrammarList(). Was only able to get the engine to recognize "red" as input grammar, though the result event is fired more than once.

var grammar = '#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;'var recognition = newwebkitSpeechRecognition();
var speechRecognitionList = newwebkitSpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
recognition.continuous = true;
recognition.lang = 'en-US';
recognition.interimResults = true;
recognition.maxAlternatives = 0;

var diagnostic = document.querySelector('.output');
var bg = document.querySelector('html');

document.body.onclick = function() {
  recognition.start();
  console.log('Ready to receive a color command.');
}

recognition.onresult = function(event) {
  console.log(event);
  var color = event.results[0][0].transcript;
  diagnostic.textContent = 'Result received: ' + color;
  bg.style.backgroundColor = color;
}
<body>
click
<divclass="output">

Post a Comment for "How To Restart A Speechrecognition Function In Framer?"