Voice commands implementation guide
If you own a website and want to provide voice commands for those users that have installed the Handsfree for Web extension, you can export the commands and make them available.
Similar to the commands definition of the modules, a website voice command is described as a name and an action that will be executed once the command is pronounced by the user.
In order to tell to the extension the available commands, it's necessary to execute a global function called handsfreeCommands
and share with it via a parameter the command list.
window.onload = function() {
handsfreeCommands([{
name: 'open contact section',
help: 'Opens the contact section of this website',
group: 'Website sections'
action: function() {
window.location.href = '/contact.html';
}
}, {
name: 'open home page',
help: 'Opens the home page of this website',
group: 'Website sections'
action: function() {
window.location.href = '/';
}
}]);
};
There is no context for the website commands, they are allowed to be executed at any time and they have precedence over the commands supported by the application and those were imported via a custom module.
Since the website commands are not part of a context, probably you will need to update the available commands depending of the user interaction. For example, if the user opens a section, a new list of voice commands must be provided. The function handsfreeCommands
can be called multiple times with the latest available voice commands.
Here the website voice command properties.
Property | Required | Type | Description |
---|---|---|---|
name | yes | string | Define what the user should pronounce in order to be executed |
action | yes | function | Define the function that will be executed when the user pronounce the command |
group | no | string | Defaults to '' . Useful to display to the user commands grouped by categories |
help | no | string | Defaults to '' . Useful to display to the user a description of the command when asks for help |
As an example, this same page has loaded website voice commands, if you have running the Handsfree for Web extension you can call one of the following commands in Spanish (checkout the english version of them).
La extensión Handsfree for Web fue desarrollada por Javier Pérez, con el objetivo de brindar una forma alternativa de acceso a la web.
La aplicación fue presentada como ejemplo de un modelo de interacción web a través del uso exclusivo de comandos de voz, definido en el trabajo final Navegación web dirigida por comandos de voz correspondiente a la carrera de grado Lic. en Sistemas de la Universidad Nacional de La Plata.