This module handles the text to speech operations. It converts std::strings into a PCM signal and sends it into the two speakers. The voice parameters can be changed using the FX settings.
int say (const string& stringToSay)
Performs the text-to-speech operations : it takes a std::string as input and outputs a sound in both speakers. It logs an error if the std::string is empty. String encoding must be UTF8.. Asynchronous.
Text to say, encoded in UTF-8.
Id of the task. Can be used to interrupt it.
Example in python :
#Says a test std::string tts = ALProxy("ALTextToSpeech") tts.say("This is a sample text!")
int sayToFile (const string& pStringToSay, const string& pFileName)
Performs the text-to-speech operations: it takes a std::string as input and outputs the corresponding audio signal in the specified file.. Asynchronous.
Text to say, encoded in UTF-8.
RAW file where to store the generated signal. The signal is encoded with a sample rate of 22050Hz, format S16_LE, 2 channels.
Id of the task. Can be used to interrupt it.
Example in python :
#Says a test std::string, and save it into a file tts = ALProxy("ALTextToSpeech") tts.sayToFile("This is a sample text, written in a file!", "/tmp/sample_text.raw")
int sayToFileAndPlay (const string& pStringToSay)
This method performs the text-to-speech operations: it takes a std::string, outputs the synthesis resulting audio signal in a file, and then plays the audio file. The file is deleted afterwards. It is useful when you want to perform a short synthesis, when few CPU is available. Do not use it if you want a low-latency synthesis or to synthesize a long std::string.. Asynchronous.
Text to say, encoded in UTF-8.
Id of the task. Can be used to interrupt it.
Example in python :
#Says a test std::string safely Vincent : pouquoi c'est plus safe, je comprends pas ! ? tts = ALProxy("ALTextToSpeech") tts.sayToFileAndPlay("This is a sample text.")
void setLanguage (const string& pLanguage)
Changes the language used by the Text-to-Speech engine. It automatically changes the voice used since each of them is related to a unique language. If you want that change to take effect automatically after reboot of your robot, refer to the robot web page (setting page).
Language name. Must belong to the languages available in TTS (can be obtained with the getAvailableLanguages method). It should be an identifier std::string.
Example in python :
#Sets the language to english tts = ALProxy("ALTextToSpeech") tts.setLanguage("English")
string getLanguage ()
Returns the language currently used by the text-to-speech engine.
Language of the current voice.
Example in python :
//gets the language of the current voice tts = ALProxy("ALTextToSpeech") lang = tts.getLanguage();
string getLanguageEncoding (const string& pLanguage)
Returns the encoding that should be used with the specified language.
Language name (as a std::string). Must belong to the languages available in TTS.
Encoding of the specified language.
vector<string> getAvailableLanguages ()
Outputs the languages installed on the system.
Array of std::string that contains the languages installed on the system.
Example in python :
tts = ALProxy("ALTextToSpeech") lang = tts.getAvailableLanguages();
void setParameter (const string& pEffectName, const float& pEffectValue)
Changes the parameters of the voice. The available parameters are:
pitchShift: applies a pitch shifting to the voice. The value indicates the ratio between the new fundamental frequencies and the old ones (examples: 2.0: an octave above, 1.5: a quint above). Correct range is (1.0 -- 4), or 0 to disable effect.
doubleVoice: adds a second voice to the first one. The value indicates the ratio between the second voice fundamental frequency and the first one. Correct range is (1.0 -- 4), or 0 to disable effect
doubleVoiceLevel: the corresponding value is the level of the double voice (1.0: equal to the main voice one). Correct range is (0 -- 4).
doubleVoiceTimeShift: the corresponding value is the delay between the double voice and the main one. Correct range is (0 -- 0.5)
If the effect value is not available, the effect parameter remains unchanged.
Name of the parameter.
Value of the parameter.
Example in python :
tts = ALProxy("ALTextToSpeech") #Applies a pitch shifting to the voice tts.setParameter("pitchShift", 1.5) #Deactivates double voice tts.setParameter("doubleVoice", 0.0)
float getParameter (const string& pParameterName)
Returns the value of one of the voice parameters. The available parameters are: "pitchShift", "doubleVoice","doubleVoiceLevel" and "doubleVoiceTimeShift"
Name of the parameter.
Value of the specified parameter
Example in python :
#Gets the value of the pitch shift and displays it tts = ALProxy("ALTextToSpeech") ps=tts.getParameter("pitchShift") print ps
void setVoice (const string& pVoiceID)
Changes the voice used by the text-to-speech engine. The voice identifier must belong to the installed voices, that can be listed using the 'getAvailableVoices' method. If the voice is not available, it remains unchanged. No exception is thrown in this case.
The voice (as a std::string).
Example in python :
tts = ALProxy("ALTextToSpeech") #Changes the basic voice of the synthesis tts.setVoice("Heather22Enhanced")
string getVoice ()
Returns the voice currently used by the text-to-speech engine.
Name of the current voice
Example in python :
tts = ALProxy("ALTextToSpeech") #Gets the current voice of the synthesis engine voice = tts.getVoice()
vector<string> getAvailableVoices ()
Outputs the available voices. The returned list contains the voice IDs.
Array of std::string containing the voices installed on the system.
Example in python :
tts = ALProxy("ALTextToSpeech") #Lists the installed voices voicelist = tts.getAvailableVoices() print voicelist
void setVolume (const float& volume)
Sets the volume of text-to-speech output.
Volume (between 0.0 and 1.0).
Example in python :
tts = ALProxy("ALTextToSpeech") #Changes the volume tts.setVolume(0.5)
float getVolume ()
Fetches the current volume the text to speech.
Volume (integer between 0 and 100).
Example in python :
tts = ALProxy("ALTextToSpeech") #Gets the volume a= tts.getVolume() print a
void loadVoicePreference (const string& pPreferenceName)
Loads a set of voice parameters defined in a xml file contained in the preferences folder.The name of the xml file must begin with ALTextToSpeech_Voice_
Name of the voice preference.
Example in python :
tts = ALProxy("ALTextToSpeech") //loads the set of voice parameters contained in the ALTextToSpeech_Voice_NaoOfficialVoiceEnglish.xml file tts.loadVoicePreference("NaoOfficialVoiceEnglish");
void enableNotifications ()
Enables the notifications puted in ALMemory during the synthesis (TextStarted, TextDone, CurrentBookMark, CurrentWord, ...)
void disableNotifications ()
Disables the notifications puted in ALMemory during the synthesis (TextStarted, TextDone, CurrentBookMark, CurrentWord, ...)
string version ()
Returns the version of the module.
A string containing the version of the module.
AL::ALValue getMethodHelp (const string& methodName)
Retrieves a method's description.
The name of the method.
A structure containing the method's description.
AL::ALValue getModuleHelp ()
Retrieves the module's description.
A structure describing the module.
string getUsage (const string& name)
Gets the method usage string. This summarise how to use the method.
The name of the method.
A string that summarises the usage of the method.
Example in python :
#Create a proxy on the text-to-speech module tts = ALProxy("ALTextToSpeech") tts.say("Hello World!")