Skip to content

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 ​

The say function triggers Manatee to speak the phrase given.

js
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.

js
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.

js
// 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.

js
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
js
audio.play("asterisk");

Audio.volume ​

Controls the volume of the current audio device.

js
var v = audio.volume;
audio.volume = v + 1;

Audio.muted ​

Get/set the muted state of the current audio device.

js
if (audio.muted) audio.muted = false;
Releases
v3.1.0
  • Add the ability to play system sounds in the play method.
v3.0.0
  • Initial release of the Audio module for Manatee 2.1.