forked from 1core2life/smart-mirror-A-team
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeechtest.html
54 lines (38 loc) · 1.59 KB
/
speechtest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src='http://cdnjs.cloudflare.com/ajax/libs/annyang/2.6.0/annyang.min.js'></script>
<script>
//듣기 시작 : annyang.start!
annyang.start({ autoRestart: false, continuous: true })
var recognition = annyang.getSpeechRecognizer(); // Anntayng이 인식한 텍스트 반환
var final_transcript = ''; //최종 trascript 변수
recognition.interimResults = false; //중간결과값 설정X
recognition.onresult = function(event){
var interim_transcript = '';
final_transcript = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
final_transcript += event.results[i][0].transcript;
console.log("final_transcript="+final_transcript);
//annyang.trigger(final_transcript);
//If the sentence is "final" for the Web Speech API, we can try to trigger the sentence
} else {
interim_transcript += event.results[i][0].transcript;
console.log("interim_transcript="+interim_transcript);
}
}
document.getElementById('result').innerHTML = '중간값:='+interim_transcript+'<br/>결과값='+final_transcript;
console.log('interim='+interim_transcript+'|final='+final_transcript);
};
</script>
</head>
<body class="" id="grid">
<br/><br/>
한국어 음성 처리 테스트<br/><br/>
<div id='result'>
결과가 없습니다.
</div>
</body>
</html>