NAOqi Audio - Overview | API | Tutorial
See also
Namespace : AL
#include <alproxies/altexttospeechproxy.h>
As any module, this module inherits methods from ALModule API. It also has the following specific methods:
Disables notifications publishing in ALMemory during the synthesis (disabled by default). Please refer to ALTextToSpeechProxy::enableNotifications() for further informations.
Enables notifications publishing in ALMemory during the synthesis (disabled by default). Once enabled, the following notifications are generated:
Returns the list of the languages currently installed on the robot.
Returns: | List of installed languages. Example: ['English', 'French']
For the complete list of language codes, see: Available languages. |
---|
altexttospeech_getavailablelanguages.py
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python texttospeech_getavailablelanguages.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
tts = ALProxy("ALTextToSpeech", IP, PORT)
except Exception,e:
print "Could not create proxy to ALTextToSpeech"
print "Error was: ",e
sys.exit(1)
lang = tts.getAvailableLanguages();
print "Available languages: " + str(lang)
Returns the list of the voices currently installed on the system. Each voice is given in English.
Returns: | Voices Installed |
---|
Returns the language currently used by the text to speech engine.
Returns: | Current language used by the text to speech engine. Example: 'French'
For the complete list of language codes, see: Available languages. |
---|
Returns the value of one of the text to speech engine parameters. The available parameters are: “pitchShift”, “doubleVoice”,”doubleVoiceLevel” and “doubleVoiceTimeShift”. Please refers to ALTextToSpeechProxy::setParameter() for details about this parameters.
Parameters: |
|
---|---|
Returns: | Value of the specified parameter |
Returns the voice currently used by the text to speech engine.
Returns: | Name of the current voice |
---|
Gets the current gain applied to the signal synthesized by the text to speech engine. The default value is 1.0.
Returns: | Volume [0 - 1] |
---|
Loads a voice and the related set of voice parameters defined in a XML file contained in the preferences folder. The name of the XML file must be of the form ALTextToSpeech_Voice_preferencesFileSuffix. The official voice of NAO in each language is defined in this way. Please refers to Tutorial for further details.
Parameters: |
|
---|
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python texttospeech_loadvoicepreference.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
tts = ALProxy("ALTextToSpeech", IP, PORT)
except Exception,e:
print "Could not create proxy to ALTextToSpeech"
print "Error was: ",e
sys.exit(1)
# Loads the set of voice parameters contained in the ALTextToSpeech_Voice_NaoOfficialVoiceEnglish.xml file
tts.loadVoicePreference("NaoOfficialVoiceEnglish")
tts.say("Voice preference loaded")
Says the specified string of characters.
Uses the language defined using ALTextToSpeechProxy::setLanguage() if any, or the default language defined in the robot’s web page.
Parameters: |
|
---|
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python texttospeech_say.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
tts = ALProxy("ALTextToSpeech", IP, PORT)
except Exception,e:
print "Could not create proxy to ALTextToSpeech"
print "Error was: ",e
sys.exit(1)
#Says a test std::string
tts.say("This is a sample text!")
Works similarly to ALTextToSpeechProxy::say() but the synthesized signal is recorded into the specified file instead of being sent to NAO’s loudspeakers. The signal is encoded with a sample rate of 22050Hz (European languages) and 16000Hz (Asian languages), format S16_LE, 1 channel.
Parameters: |
|
---|
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python texttospeech_saytofile.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
tts = ALProxy("ALTextToSpeech", IP, PORT)
except Exception,e:
print "Could not create proxy to ALTextToSpeech"
print "Error was: ",e
sys.exit(1)
#Says a test std::string, and save it into a file
tts.sayToFile("This is a sample text, written in a file!", "/tmp/sample_text.raw")
#Says a test std::string, and save it into a file
tts.sayToFile("This is another sample text", "/tmp/sample_text.wav")
Works similarly to ALTextToSpeechProxy::sayToFile() but sends also the synthesized signal to NAO’s loudspeakers.
Parameters: |
|
---|---|
Returns: | Id of the task. Can be used to interrupt it. |
Sets the language currently used by the text to speech system. Note that each NAOqi restart will however reset that setting to the default language that can be set on the robot’s web page.
Parameters: |
|
---|
Sets the voice to be used by default with a specified language.
Parameters: |
|
---|
Sets parameters of the text to speech engine. The available parameters are:
Parameters: |
|
---|
Parameters | Description |
---|---|
pitchShift | applies a pitch shift to the voice. The value indicates the ratio between the new fundamental frequencies and the original one (examples: 2.0: an octave above, 1.5: a quint above). Acceptable range is [1.0 - 4]. 0 disables the 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. Acceptable range is [1.0 - 4]. 0 disables the effect. |
doubleVoiceLevel | sets the gain of the additional voice compared to the original one. Acceptable range is [0 - 4]. 0 disables the effect. |
doubleVoiceTimeShift | sets the delay (seconds) between the doubled voice and the original one. Acceptable range is [0 - 0.5]. |
altexttospeech_setparameter.py
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python texttospeech_setparameter.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
tts = ALProxy("ALTextToSpeech", IP, PORT)
except Exception,e:
print "Could not create proxy to ALTextToSpeech"
print "Error was: ",e
sys.exit(1)
#Applies a pitch shifting to the voice
tts.setParameter("pitchShift", 1.5)
#Deactivates double voice
tts.setParameter("doubleVoice", 0.0)
tts.say("Pitch shift and double voice changed")
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 ALTextToSpeechProxy::getAvailableVoices() method.
Parameters: |
|
---|
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python texttospeech_setvoice.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
tts = ALProxy("ALTextToSpeech", IP, PORT)
except Exception,e:
print "Could not create proxy to ALTextToSpeech"
print "Error was: ",e
sys.exit(1)
#Changes the basic voice of the synthesis
tts.setVoice("Kenny22Enhanced")
tts.say("Voice changed to Kenny")
Sets the current gain applied to the signal synthesized by the text to speech engine. The default value is 1.0.
Parameters: |
|
---|
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python texttospeech_setvolume.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
tts = ALProxy("ALTextToSpeech", IP, PORT)
except Exception,e:
print "Could not create proxy to ALTextToSpeech"
print "Error was: ",e
sys.exit(1)
#Changes the volume
tts.setVolume(0.5)
tts.say("Volume set to 50%")
This method stops the current and all the pending tasks immediately.
Indicates the occurrence of the bookmarks that are placed (using “mrk=number” number being an integer [0 - 65535]) in the string that needs to be synthesized, see Acapela Mobility Text TAGS for further information.
Parameters: |
|
---|
Note
This event should be prefixed by “ALTextToSpeech/” when subscribing to it.
Indicates the sentence that is currently synthesized.
Parameters: |
|
---|
Note
This event should be prefixed by “ALTextToSpeech/” when subscribing to it.
Indicates the word that is currently synthesized.
Parameters: |
|
---|
Note
This event should be prefixed by “ALTextToSpeech/” when subscribing to it.
Indicates the word that is currently synthesized by its index in the current sentence. Index 0 refers to the first word of the sentence.
Parameters: |
|
---|
Note
This event should be prefixed by “ALTextToSpeech/” when subscribing to it.
Raised when the current sentence synthesis starts.
Parameters: |
|
---|
Note
This event should be prefixed by “ALTextToSpeech/” when subscribing to it.
Raised when the current sentence synthesis is done.
Parameters: |
|
---|
Note
This event should be prefixed by “ALTextToSpeech/” when subscribing to it.