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

  1. make me coffee
  2. 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

  1. (please) make me coffee
  2. turn on (the, some) lights
  3. (@politeAdditions) steep some tea
  4. 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

  1. [make, brew] me coffee
  2. [turn on, activate] the lights
  3. [@brewCommands, steep] me some tea
  4. 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

  1. make me $beverage:bev1
  2. turn on lights in $room:r1 and $room:r2

Utterances

  1. "make me coffee"
  2. "turn on lights in kitchen and study"

Results

  1. {'{intent: "makeDrink", bev1: "coffee"}'}
  2. {'{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

  1. stop at the $pv.TwoDigitOrdinal:floor floor
  2. set fan speed to $pv.Percent:speed

Utterances

  1. "stop at the eleventh floor"
  2. "set the fan speed to twenty-five percent"

Results

  1. {'{intent: "selectFloor", floor: "11th"}'}
  2. {'{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

  1. @brew me a coffee
  2. set the lights to @max

Utterances

  1. "make me coffee"
  2. "brew me coffee"
  3. "set the lights to one hundred percent"
  4. "set the lights to full brightness"

Results

  1. {'{intent: "makeDrink"}'}
  2. {'{intent: "makeDrink"}'}
  3. {'{intent: "setLightBrightnessMax"}'}
  4. {'{intent: "setLightBrightnessMax"}'}

Issue with this doc? Please let us know.