audio API examples

Following listing presents how to use audio features of the robot's modules using robot structure.

robot.audio.Run(),//starts infinite loop which updates audio streams
//using recognition - utilizes URecog or UKinect modules 
robot.audio.recognition.LoadGrammar("speech.grxml");//loads speech recognition grammar by calling appropriate SAPI or MSP functions based on settings in configuration file
robot.audio.recognition.AddPhrase("","yes");
robot.audio.recognition.AddPhrase("","no");//adds grammar phrases by calling appropriate SAPI or MSP module functions based on settings in configuration file
robot.audio.recognition.result;//recognition result of MSP/SAPI recognition
robot.audio.recognition.ResetGrammar();//clear robot grammar by calling appropriate SAPI or MSP module functions based on settings in configuration file
//using speech synthesis based on USpeech module
robot.audio.speech.availableVoices();//check available voices
//set speech parameters
robot.audio.speech.volume = 50;
robot.audio.speech.rate = 5;
robot.audio.speech.pitch = 5;
robot.audio.speech.Say("I am speaking without moving my mouth!", 0);//say the text with the first avaliable (index 0) voice in operating system
//WARNING!!!
//The above usage of robot.audio.speech can be used for talking without any of EMYS joints. For normal speech synthesis accompanied by movements simulating mouth movement use the following functions.
robot.body.neck.head.Say("I am speaking and moving my mouth simultaneously", 10, 0);//say the text with maximum intensity (of robot joints movement) with the first (index 0) voice in operating system
//using music player from robot structure
robot.audio.musicPlayer.tempoEnable =1;//enable manipulating tempo
robot.audio.musicPlayer.Play("music.mp3"),//play music in background
//change playback parameters during playing
robot.audio.musicPlayer.volume = 100;
robot.audio.musicPlayer.tempoTempo = -4;
robot.audio.musicPlayer.tempoPitch = 1;

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.9.1, 15.05.2017

FLASH Documentation