react-voice-handler
v1.1.0
Published
A lightweight React hook for voice commands using the Web Speech API with multi-language support and error handling.
Downloads
5
Maintainers
Readme
const App: React.FC = () => { const commands = [ { command: 'hello', action: () => alert('Hello there!') }, { command: '안녕하세요', action: () => alert('hello') }, { command: 'goodbye', action: () => alert('Goodbye!') }, ];
const { startRecognition, stopRecognition } = useVoiceCommands(commands, { continuous: true, lang: LangEnum.EnglishUS });
return ( <div> <h1>Voice Command App</h1> <button onClick={startRecognition}>Start Listening</button> <button onClick={stopRecognition}>Stop Listening</button> </div> ); };
export default App;
const { startRecognition, stopRecognition } = useVoiceCommands(commands, { onError: handleError });