I am trying to create an extension that takes the audio from a tab and outputs text using webkitSpeechRecognition.
However, for some reason whenever I try to use speech recognition it errors with the error being "not-allowed". My current code is inside of the "service_worker" script:
window.SpeechRecognition = window.webkitSpeechRecognition || window.SpeechRecognition
const recognition = new SpeechRecognition()
recognition.start()
recognition.onresult = (event) => {
const speechToText = event.results[0][0].transcript
console.log(speechToText)
}
recognition.onerror = (event) => {
console.error(event)
}
Why does it error, and how can I fix it?