problem description
how to bind the acquired data in data using web speech in vue
the environmental background of the problems and what methods you have tried
found the use of web speech in html on the Internet and used it in the project of vue (cli scaffolding). I wanted to send the converted text to the background, but it was a pity that I couldn"t get it
.related codes
/ / Please paste the code text below (do not replace the code with pictures)
data () {
return {
speechContent: "",
voiceContent: "",
recognition: "",
}
},
methods: {
endRecord () {
console.log(2+this.voiceContent);
this.$axios.get("http://192.168.0.182:8084/question/test",{
params: {
params : this.voiceContent
}
}).then(
res => {
console.log(res);
}
).catch(
err => {
console.log(err);
}
);
this.recognition.stop();
}
},
created () {
this.recognition = new webkitSpeechRecognition();
this.recognition.continuous = true;
this.recognition.interimResults = true;
this.recognition.lang = "cmn-Hans-CN"; // ()
this.recognition.onresult = function(event) {
let current = event.resultIndex;
//
this.voiceContent = event.results[current][0].transcript;
};
}
what result do you expect? What is the error message actually seen?
ask the boss who wants to know how to assign the voiceContent in the hook function created to the voiceContent; in data
and ask the boss to see whether my writing is standardized in vue