Audio
The Audio module contains functionality to produce audio from the speakers of the machine on which it runs. It has the following main functionality:
Audio.say
get Manatee to speak a phraseAudio.play
to play.wav
file or a system sound
Audio.say
The say
function triggers Manatee to speak the phrase given.
var audio = Module.load("Audio", {version: "v1.2.0"});
audio.say("Hello, world!");
The default voice synthesizer is the built-in Windows Speech API (SAPI) which has english voices and renders the audio on the local machine. You can also choose to use the Google Text-to-Speech API which has support for multiple languages and much higher quality voice synthesis.
Google Text-to-Speech requires internet connectivity
Using Google TTS will send the phrase you want to speak to Google servers, so be aware of this if e.g. your phrase contains sensitive information.
You can choose the Google TTS with the synth
option - and you can then select a language with the lang
option.
audio.say("Hej, verden!", {lang: 'da-DK', synth: 'Google'});
It is also possible to select a specific voice using the voice
option. See Audio.voices for how to list available voices.
Audio.voices
Lists the available voices.
// List the default set of voices
var voices = audio.voices();
// List Danish Google voices
voices = audio.voices({lang: "da-DK", synth: "Google"});
Audio.play
The play
function will synchronously play the given .wav
file or a system sound.
audio.play("C:/Users/robot/Desktop/sound.wav");
You can also play a system sound. The available system sounds are:
asterisk
beep
exclamation
hand
question
audio.play("asterisk");
Audio.volume
Controls the volume of the current audio device.
var v = audio.volume;
audio.volume = v + 1;
Audio.muted
Get/set the muted state of the current audio device.
if (audio.muted) audio.muted = false;
Releases
- v3.1.0
- Add the ability to play system sounds in the
play
method.
- Add the ability to play system sounds in the
- v3.0.0
- Initial release of the Audio module for Manatee 2.1.