This is a basic demo to show how to use Rhino for web browsers, using the IIFE version of the library (i.e. an HTML script tag). It instantiates a Rhino worker engine and uses it with the @picovoice/web-voice-processor to access (and automatically downsample) microphone audio.
Use yarn
or npm
to install the dependencies, and the start
script to start a local web server hosting the demo.
yarn
yarn start
(or)
npm install
npm run start
Open localhost:5000
in your web browser, as hinted at in the output:
┌──────────────────────────────────────────────────┐
│ │
│ Serving! │
│ │
│ - Local: http://localhost:5000 │
│ - On Your Network: http://192.168.1.69:5000 │
│ │
│ Copied local address to clipboard! │
│ │
└──────────────────────────────────────────────────┘
Wait until Rhino and the WebVoiceProcessor have initialized. The demo is running a context called "Clock" (available as a .rhn
file in the GitHub repository). Press the "Push to Talk" button to start a voice interaction.
Try a phrase that is in the context:
"Set a timer for two minutes"
The results will appear on screen:
{
"isFinalized": true,
"isUnderstood": true,
"intent": "setTimer",
"slots": { "minutes": "10" }
}
Try a phrase that is out-of-context:
"What's my horoscope?"
{
"isFinalized": true,
"isUnderstood": false,
"intent": null,
"slots": {}
}
This command falls outside of the domain of "Alarm Clock" and is therefore not understood.
The Alarm Clock was trained to understand a particular set of expressions. These are built using a simple grammar and grouped together into a YAML file. This file is trained by Picovoice Console to create a .rhn
file for the WebAssembly (WASM) platform.
context:
expressions:
setAlarm:
- "set (a, an, the) [alarm, timer] for $pv.TwoDigitInteger:hours [hour, hours] (and) $pv.TwoDigitInteger:minutes [minute, minutes] (and) $pv.TwoDigitInteger:seconds [second, seconds]"
- "set (a, an, the) [alarm, timer] for $pv.TwoDigitInteger:hours [hour, hours] (and) $pv.TwoDigitInteger:minutes [minute, minutes]"
- "set (a, an, the) [alarm, timer] for $pv.TwoDigitInteger:hours [hour, hours] (and) $pv.TwoDigitInteger:seconds [second, seconds]"
- "set (a, an, the) [alarm, timer] for $pv.TwoDigitInteger:hours [hour, hours]"
- "set (a, an, the) [alarm, timer] for $pv.TwoDigitInteger:minutes [minute, minutes] (and) $pv.TwoDigitInteger:seconds [second, seconds]"
- "set (a, an, the) [alarm, timer] for $pv.TwoDigitInteger:minutes [minute, minutes]"
- "set (a, an, the) [alarm, timer] for $pv.TwoDigitInteger:seconds [second, seconds]"
- "$pv.TwoDigitInteger:hours [hour, hours] (and) $pv.TwoDigitInteger:minutes [minute, minutes] (and) $pv.TwoDigitInteger:seconds [second, seconds]"
- "$pv.TwoDigitInteger:hours [hour, hours] (and) $pv.TwoDigitInteger:minutes [minute, minutes]"
- "$pv.TwoDigitInteger:hours [hour, hours] (and) $pv.TwoDigitInteger:seconds [second, seconds]"
- "$pv.TwoDigitInteger:hours [hour, hours]"
- "$pv.TwoDigitInteger:minutes [minute, minutes] (and) $pv.TwoDigitInteger:seconds [second, seconds]"
- "$pv.TwoDigitInteger:minutes [minute, minutes]"
- "$pv.TwoDigitInteger:seconds [second, seconds]"
reset:
- "reset (the) (timer)"
pause:
- "[pause, stop] (the) (timer)"
resume:
- "resume (the) (timer)"