Skip to content

useWakeWord

Detects wake words using Hey Buddy, which runs ONNX models entirely in the browser via WebAssembly. No audio leaves the device and no API key is needed.

You need a .onnx wake word model file. You can either:

  • Use a pre-trained model (~1.2 MB each)
  • Train your own with the Hey Buddy Python CLI: heybuddy train "hey miku"

Place the .onnx file in your app’s public directory.

The hook loads onnxruntime-web and hey-buddy-onnx from CDN automatically at runtime — no npm install required for these.

import { useWakeWord } from 'three-vrm-utils/use-wake-word'
function App() {
const wakeWord = useWakeWord({ modelPath: '/models/hey-miku.onnx' }, (label) => {
console.log(`Wake word detected: ${label}`)
})
return <div>{wakeWord.isListening ? 'Listening...' : 'Paused'}</div>
}
import { useRef } from 'react'
import { VRMModel, type VRMModelRef } from 'three-vrm-utils/vrm-model'
import { useWakeWord } from 'three-vrm-utils/use-wake-word'
function App({ isSpeaking }: { isSpeaking: boolean }) {
const ref = useRef<VRMModelRef>(null)
const wakeWord = useWakeWord({ modelPath: '/models/hey-miku.onnx' }, (label) => {
ref.current?.expressionManager.send({ happy: 0.3 })
})
// Stop listening while VRM is speaking to avoid self-trigger
useEffect(() => {
if (isSpeaking) wakeWord.stop()
else wakeWord.start()
}, [isSpeaking])
return <VRMModel ref={ref} url="/model.vrm" blink breathing />
}
OptionTypeDefaultDescription
modelPathstring | string[]Path(s) to .onnx wake word model files
recordbooleanfalseCapture audio from wake word to end of speech
autoStartbooleantrueStart listening on mount
PropertyTypeDescription
isListeningbooleanWhether the hook is actively listening
start() => voidStart listening for the wake word
stop() => voidStop listening and release mic

The second argument is called when a wake word is detected:

useWakeWord(options, (label: string) => {
// label is the model filename without extension
// e.g. "hey-miku" for hey-miku.onnx
})

When using multiple models, label tells you which one triggered.