annyang icon indicating copy to clipboard operation
annyang copied to clipboard

General Question

Open inglesuniversal opened this issue 2 years ago • 2 comments

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

Thanks

inglesuniversal avatar Mar 22 '23 03:03 inglesuniversal

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 } }

daemonX10 avatar Oct 05 '23 12:10 daemonX10

Thanks will try it out!

inglesuniversal avatar Oct 05 '23 15:10 inglesuniversal