TalAter / annyang

:speech_balloon: Speech recognition for your site
https://www.talater.com/annyang/
MIT License
6.57k stars 1.05k forks source link

General Question #457

Open inglesuniversal opened 1 year ago

inglesuniversal commented 1 year ago

How to force annyang.trigger('command') to work, even if NOT in listening mode or Speech API is not available on browser.

Thanks

daemonX10 commented 7 months ago

const userInput = "your user input here"; // Get the user's input const commandKeywords = ["keyword1", "keyword2", "keyword3"];

// Check if any of the keywords are present in the user's input for (const keyword of commandKeywords) { if (userInput.includes(keyword)) { // Perform the action associated with the matched keyword // This can be a function call or any other action console.log(Matched keyword: ${keyword}); break; // Stop checking once a match is found } }

inglesuniversal commented 7 months ago

Thanks will try it out!