PHP Classes

File: js/HVoice.js

Recommend this page to a friend!
  Classes of joerverson   PHP Voice Recognition   js/HVoice.js   Download  
File: js/HVoice.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Voice Recognition
Recognize user voice using the Web speech API
Author: By
Last change:
Date: 1 year ago
Size: 984 bytes
 

Contents

Class file image Download
$(function(){ var voice = new webkitSpeechRecognition(); var interrupt = true; voice.continuous = true; voice.interimResults = true; voice.lang = 'pt-br'; $('.startVoice').on("click",function(){ if(interrupt) { voice.start(); interrupt = false; }else{ voice.stop(); interrupt = true; } }); voice.onresult = function(e){ var word = e.results[e.resultIndex][0].transcript.trim(); if(e.results[e.resultIndex].isFinal){ // para que venha o resultado final e decisivo console.log(word); terms.forEach(function(action){ if(new RegExp(action.term).test(word)){ action.take(); } }); } } voice.onerror = function(error){ $('.errorVoice').html('ERROR found! : ' + error.error); } // apresentação do error encontrado });