i'm doing a voice command project. Basically, the voice is transcribed into text, and this text is compared with some keyword, and if it is equal to the keyword, it executes a function.
i'm trying to make a function that will open a new tab by searching google whatever is transcribed from the word "search". If the phrase "search potato" is transcribed, the browser will search potato and ignore the word "search".
My problem is that the variable that stores what is transcribed only takes the word "search" and ignores everything that comes after it
if (transcript == `search`) { // search keyword
msg.text = 'Searching' // a text-to-speech saying the browser is searching
speechSynthesis.speak(msg) // a text-to-speech saying the browser is searching
window.open(`https://www.google.com/search?q=${transcript}`)
}
I thought of making a condition that if the transcript has the word search, do the search with the whole phrase, but i don't know how to write this condition within the syntax
note: i was trying to use array to do this, but it is getting the letter that is composing the word "search", Eg: transcript[1] returns e from search