Skip to content
ggodart edited this page Jan 6, 2021 · 1 revision

Voice_Cmd

See original

SYNOPSIS

  $v_backyard_light = new  Voice_Cmd 'Backyard Light [on,off]';
  set $backyard_light $state if $state = said $v_backyard_light;

  $v_test1 = new Voice_Cmd '{turn,set} the {living,famliy} room {light,lights} [on,off]';
  $v_test2 = new Voice_Cmd '{Please, } tell me the time';
  $v_test3 = new Voice_Cmd '{What time is it,Tell me the time}';
  $v_fan   = new Voice_Cmd 'Fan [on,off]', 'Ok, I turned the fan $v_indoor_fountain->{said}';
  $v_fan   = new Voice_Cmd 'Fan [on,off]', 'Ok, I turned the fan %STATE%';

In addition to the said command on a specific object, you can use &Voice_Cmd::said_this_pass to detect which command was spoken this pass and &Voice_Cmd::noise_this_pass to detect if noise was detected this pass (this function currently only works with viavoice).

  if (my $speak_num = &Voice_Cmd::said_this_pass) {
    my $text = &Voice_Cmd::text_by_num($speak_num);
    print_log "spoken text: $speak_num, $text";
  }

  if (my $text = &Voice_Cmd::noise_this_pass) {
    print_log "Noise detected" if $text eq 'Noise';
  }

DESCRIPTION

Use the Voice_Cmd object to create voice commands. Even without a Voice Recognition engine installed, this is useful as these commands can also be run from the Tk, web, telnet, and file interfaces.

INHERITS

Generic_Item

INI PARAMETERS

METHODS

Method Description
new($command, $response, $confirm, $vocabulary) $command - can be a simple string (e.g. 'What time is it') or it can include a list of 'states' (e.g. 'Turn the light [on,off]'). The state enumeration group is a comma delimited string surrounded with []. In addition to one state enumeration group, you can specify any number of phrase enumeration groups. These are comma delimited strings surrounded by {} (e.g. 'Turn the {family room,downstairs} TV [on,off]'). Use this when you have several different ways to describe the same thing.
$response - is the text or wave file that will be played back when the VR engine detects this command. If not defined, the mh.ini parameter voice_cmd_response is used (default is "Ok, %HEARD%"). You can put %STATE%, %HEARD%, or any variable in the response string and have it substituted/evaluated when the response is spoken.
$confirm - is either 0 or 1 (default is 0). If set to 1, then mh will ask 'Confirm with a yes or a no'. If yes or no is not heard within 10 seconds, the command is aborted.
$vocabulary - allows you to define multiple vocabularies. You can then use these functions to enable and disable the vocabularies:
&Voice_Cmd::enablevocab($vocabulary)
&Voice_Cmd::disablevocab($vocabulary)
Vocabularies are enabled by default. The default vocabulary is misterhouse. See mh/code/bruce/viavoice_control.pl for examples. This code allows you to switch between 'awake', 'asleep', and 'off' VR modes.
NOTE: Currently only the viavoice VR engine (mh.ini parameter voice_cmd=viavoice) will use the $response, $confirm, and $vocabulary_name options. We may be able to create a viavoice_server for windows, but that would probably not be free like it is on linux. If you have a linux box on your network, you can have your windows MisterHousee use the linux viavoice_server process.
set_order Controls the order that the commands are listed in web Category list. The default is alphabetically by file, then by name.

INHERITED METHODS

Method Description
said Is true for the one pass after the command was issued. If the command was built from a list of possible states, then said returns the state that matches.
state Returns the same thing as said, except it is valid for all passes, not just the pass after the command was issued.
set_icon Point to the icon member you want the web interface to use. See the 'Customizing the web interface' section of this document for details.

AUTHOR

Clone this wiki locally