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.

Expressions need at least one concrete word/phrase, so optionals cannot be used alone.

Optional Syntax

(phrase, phrase2, … , phraseN)

Optional Examples

  1. (please) make me coffee
  2. turn on (the, some) lights

Choice

Logical "or" for allowing phrasing choices.

Use it especially when the specific phrasing is unimportant to the intent.

Choice Syntax

[phrase1, phrase2, … , phraseN]

Choice Examples

  1. [make, brew] me coffee
  2. [turn on, activate] the 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.

Even if you are not interested in the specific value that matched the slot type, slots still serve as a convenient macro for choices, especially ones with several values, and/or choices that are used many times in expressions.

When using the same slot type multiple times in one expression, the variable names must be unique to avoid ambiguity.

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%"}'}