Skip to content
Caleb Bassi edited this page May 20, 2020 · 13 revisions

osprey.config

set_config(dict)

Set any config options. The list of config options and their defaults is available at https://github.com/osprey-voice/osprey/blob/master/osprey/config.py. Only the options that you want to change need to be provided, the rest will be provided from the default.

osprey.control

quit_program()

Quits Osprey.

reload_scripts()

osprey.open

open(str)

Opens a given file with the default program.

open_config_dir()

open_history_file()

open_log_file()

osprey.voice

Context

A collection of commands that can be enabled and disabled based on some conditions.

Context(str, context_group=default_context_group)

Initialize a Context object with a given name. If another Context is later initialized with the same name, it will overwrite the previous one.

Context.set_commands(dict[str: lambda(dict[str: int|list|str])])

Set the rule/action pairs for the Context. A rule is a pattern of words with some additional syntax.

The additional syntax includes:

  • [words]: these words become optional
  • (words1|words2): either words1 or words2 can match, but not both

If a rule is matched, its corresponding action will be called with a match parameter. The match parameter is a dict of elements corresponding to the matched value of a placeholder.

A placeholder is an element with angle brackets and can be one of the following:

  • <word>: a str of one spoken word
  • <phrase>: a str of spoken words
  • <n>: an int from 0 to 100
  • <{choice}>: a str of one of the items of a choice

A placeholder can optionally be followed by one of:

  • *: a list of 0 or more of the placeholder
  • +: a list of 1 or more of the placeholder

If a placeholder is made optional and is not matched in a given transcript, its value in the match parameter is set to None.

Context.set_choices(dict[str: list])

Set the choices for the Context. Choices can be accessed from any rule of the Context with the <{choice}> syntax.

ContextGroup

ContextGroup(str)

ContextGroup.enable()

ContextGroup.disable()

Keypress

insert(str)

Inserts a given string by pressing one key at a time.

press(str)

Presses a key or key combination. The list of keys supported is available at: https://github.com/osprey-voice/osprey/blob/master/osprey/keys.py. Uppercase letters are also supported. Key modifiers are separated by a space. On macOS, Ctrl is converted to the Command key.

repeat(int)

Repeats the previous insert or press a given number of times.

undo_insert()

Undoes the previous insert by pressing Backspace the same number of times as the length of the previously inserted string.

Variables

context_groups: dict[str: ContextGroup]

default_context_group: ContextGroup

IS_WAYLAND_RUNNING: bool