I am working on a project and need to input data in a form which contain input task name type=text with id=task_name. The user should be able to input data using annyang voice recognition, annyang is starting and can see red dot on page but when passing the commands nothing shows up, did i make an error somewhere. Clicking on a button will make annyang start and after that user could add use voice command to input data but voice command is not working.
Here is my code
<script>
start_vc.addEventListener('click', () => {
const speech = new SpeechSynthesisUtterance();
speech.text = 'How can i help you!';
speech.lang = 'en-UK';
speech.volume = 1;
speech.rate = 1;
speech.pitch = 1;
window.speechSynthesis.speak(speech);
if (annyang) {
var commands = {
'input task name': function(variable) {
let task_name = document.getElementById("task_name");
task_name.value = variable;
}
};
// Add our commands to annyang
annyang.addCommands(commands);
// Start listening.
annyang.start();
}
});
</script>
Did i make an error somewhere and if i made an error can someone tell me what was it i kind of new to javascript