Rhino Syntax Cheat Sheet
Intents & Expressions
Create a context to detect intent from speech, intents such as "Make Coffee" or "Turn on Lights".
Intents are composed of a collection of expressions, each consisting of a different combination of tokens
(phrases, slots, and macros). When a user's utterance matches any expression within an intent, the intent is detected. For example, "make coffee" or "make me coffee" could be expressions, each of which signal the "Make Coffee" intent.
Phrase
Match a series of words from a spoken language, exactly.
Phrases are made up of words, strings of alphabetic characters and apostrophes, each separated by spaces.
All other elements of expressions are built on phrases, and a phrase by itself is a valid expression.
Pronunciation checks are performed as you edit your context. Each word in the phrase must be present in the Picovoice dictionary.
Phrase Syntax
word1 word2 … wordN
Phrase Examples
make me coffee
turn on the lights
Optional
Allow optional phrases within a larger expression.
Useful for capturing variations on articles, politeness, and formality.
phrase, slot and macro types can all be used within an optional.
Expressions need at least one concrete word/phrase, so optionals cannot be used alone.
Optional Syntax
(phrase, phrase2, @macro1, $slot:slot1, … , phraseN)
Optional Examples
(please) make me coffee
turn on (the, some) lights
(@politeAdditions) steep some tea
I would like a ($size:size, regular) espresso
Choice
Logical "or" for allowing phrasing choices.
Use it especially when the specific phrasing is unimportant to the intent.
phrase, slot and macro types can all be used within a choice.
Choice Syntax
[phrase1, phrase2, @macro1, $slot:slot1, … , phraseN]
Choice Examples
[make, brew] me coffee
[turn on, activate] the lights
[@brewCommands, steep] me some tea
Turn off [all the, $location:location] lights
Slot
Provide a choice from a collection, and capture the specific choice.
Slot types are defined as a list of possible phrases. A beverage slot might be a list of e.g. "coffee", "tea", "latte", and "london fog". Any of these phrases will match the slot, and the specific choice is returned in a callback.
When using the same slot type multiple times in one expression, the variable names must be unique to avoid ambiguity.
If you are not interested in the specific value that matched the slot type, the macro type serves as a convenient alias for a set of synonymous phrases.
Slot Syntax
$slot_type:slot_variable
Slot Examples
(Assuming slot types "beverage" and "room" have been defined, and populated with phrases)
Expressions
make me $beverage:bev1
turn on lights in $room:r1 and $room:r2
Utterances
- "make me coffee"
- "turn on lights in kitchen and study"
Results
{'{intent: "makeDrink", bev1: "coffee"}'}
{'{intent: "turnOnLights", r1: "living room", r2: "study"}'}
Built-in Slots
Rhino includes basic built-in slots for common requirements. These slots are prefixed with 'pv.' to distinguish them from regular slots.
Built-in slots return the value of the result instead of the phrase that triggered the result. E.g. pv.SingleDigitInteger will return "1" when it detects the phrase "one".
Built-in Slot Types
- pv.Alphabetic
- pv.Alphanumeric
- pv.Percent
- pv.SingleDigitInteger
- pv.SingleDigitOrdinal
- pv.TwoDigitInteger
- pv.TwoDigitOrdinal
Built-in Slot Examples
Expressions
stop at the $pv.TwoDigitOrdinal:floor floor
set fan speed to $pv.Percent:speed
Utterances
- "stop at the eleventh floor"
- "set the fan speed to twenty-five percent"
Results
{'{intent: "selectFloor", floor: "11th"}'}
{'{intent: "setFanSpeed", speed: "25%"}'}
Macro
A collection of phrases where the phrase selection is not captured.
Macro types can be used to represent a list of possible phrases. A "brew command" macro might be a list of e.g. "brew", "prepare", "make", and "craft". Any of these phrases will match the macro.
Macro types can also be used as a convenient alias for choices, especially with choices that are used many times in expressions. If you are interested in the specific value used in the utterance, the slot type allows you to capture the selected phrase.
Macro Syntax
@macro_type
Macro Examples
(Assuming macro types "brew" and "max" have been defined, and populated with phrases)
Expressions
@brew me a coffee
set the lights to @max
Utterances
- "make me coffee"
- "brew me coffee"
- "set the lights to one hundred percent"
- "set the lights to full brightness"
Results
{'{intent: "makeDrink"}'}
{'{intent: "makeDrink"}'}
{'{intent: "setLightBrightnessMax"}'}
{'{intent: "setLightBrightnessMax"}'}