Seeking help with a VueJS issue. I am trying to create a voice search button that records my voice and prints it out in an input form.
<input type="text" name="inputSearch" id="inputSearch"
v-model="inputSearch" class="form-control" x-webkit-speech>
Below is the script written in VueJS:
<script>
export default {
data() {
return {
inputSearch: '',
show: false
}
},
methods: {
voiceSearch: function(event){
this.inputSearch = '';
this.show = false;
if (window.hasOwnProperty('webkitSpeechRecognition')) {
var recognition = new webkitSpeechRecognition();
recognition.continuous = false;
recognition.interimResults = false;
recognition.lang = "en-US";
recognition.start();
recognition.onresult = function(e) {
this.inputSearch = e.results[0][0].transcript;
recognition.stop();
};
recognition.onerror = function(e) {
alert('There are something wrong...');
recognition.stop();
};
}else {
alert('Your browser does not support HTML5/WebKitSpeech. You are not able to use this functionality');
}
}
}
}
</script>
Although I can fetch text from voice recognition, I'm facing difficulty displaying it in the input form.
Thank you!