0
我需要將webkitSpeechRecognition連接到我的Vue.js項目(適用於Chrome)。Vue.js webkitSpeechRecognition集成
我試圖將代碼插入組件
<template>
<div class="voice">
<h1>{{ msg }}</h1>
<button v-on:click="greet">Speak</button>
</template>
<script>
export default {
name: 'voice',
data() {
return {
msg: 'Speak',
}
},
methods: {
greet: function (event) {
}
}
}
</script>
這個代碼
var recognition = new (SpeechRecognition || webkitSpeechRecognition || mozSpeechRecognition || msSpeechRecognition)();
recognition.lang = 'en-US';
recognition.interimResults = false;
recognition.maxAlternatives = 5;
recognition.start();
recognition.onresult = function(event) {
console.log('You said: ', event.results[0][0].transcript);
};
,但我有錯誤 「webkitSpeechRecognition沒有定義」
它依賴大概只在瀏覽器中支持ds,而不是在任何基於webkit的瀏覽器中。 –
[語音識別API適用於所有瀏覽器]的可能重複(http://stackoverflow.com/questions/27915109/speech-recognition-api-for-all-browsers) –