forked from Medici-Mansion/fofogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
56 lines (47 loc) · 2.28 KB
/
test.js
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
53
54
55
56
function sendSpeech() {
var recognition = new SpeechRecognition()
var speechRecognitionList = new SpeechGrammarList()
recognition.grammars = speechRecognitionList
recognition.lang = 'ko'
recognition.interimResults = false // true: 중간 결과를 반환, false: 최종 결과만 반환
recognition.continious = false // true: 음성인식을 계속해서 수행, false: 음성인식을 한번만 수행
recognition.maxAlternatives = 10
recognition.start()
recognition.onresult = function (event) {
var speechResult = event.results[0][0].transcript.toLowerCase()
console.log('Confidence: ' + event.results[0][0].confidence)
console.log('Speech Result: ' + speechResult)
}
recognition.onaudiostart = function (event) {
//Fired when the user agent has started to capture audio.
console.log('SpeechRecognition.onaudiostart')
}
recognition.onaudioend = function (event) {
//Fired when the user agent has finished capturing audio.
console.log('SpeechRecognition.onaudioend')
}
recognition.onend = function (event) {
//Fired when the speech recognition service has disconnected.
console.log('SpeechRecognition.onend')
}
recognition.onnomatch = function (event) {
//Fired when the speech recognition service returns a final result with no significant recognition. This may involve some degree of recognition, which doesn't meet or exceed the confidence threshold.
console.log('SpeechRecognition.onnomatch')
}
recognition.onsoundstart = function (event) {
//Fired when any sound — recognisable speech or not — has been detected.
console.log('SpeechRecognition.onsoundstart')
}
recognition.onsoundend = function (event) {
//Fired when any sound — recognisable speech or not — has stopped being detected.
console.log('SpeechRecognition.onsoundend')
}
recognition.onspeechstart = function (event) {
//Fired when sound that is recognised by the speech recognition service as speech has been detected.
console.log('SpeechRecognition.onspeechstart')
}
recognition.onstart = function (event) {
//Fired when the speech recognition service has begun listening to incoming audio with intent to recognize grammars associated with the current SpeechRecognition.
console.log('SpeechRecognition.onstart')
}
}