2017-03-20 6 views

답변

0

단 하나의 인스턴스 만 SpeechRecognition 개체와 상호 작용해야합니다.

start()으로 청취자를 시작할 수 있습니다. stop() 또는 abort()으로 청취자를 중지 할 수 있습니다.

강제 종료() 메소드는 약간 정지 방법과 다릅니다

웹 음성 API의 중단() 메소드는 입력 오디오를 듣고에서 음성 인식 서비스를 중지하고, 시도하지 않습니다 는 SpeechRecognitionResult를 반환합니다.

var recognition = new SpeechRecognition(); 
var speechRecognitionList = new SpeechGrammarList(); 
speechRecognitionList.addFromString(grammar, 1); 
recognition.grammars = speechRecognitionList; 

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

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

abortBtn.onclick = function() { 
    recognition.abort(); 
    console.log('Speech recognition aborted.'); 
} 

recognition.onspeechend = function() { 
    recognition.stop(); 
    console.log('Speech recognition has stopped.'); 
} 

SpeechRecognition 문서에서 자세한 내용을 알아보십시오 : 여기

똑바로 문서의 예입니다.