程序说明书索引 >> 红色说明书索引

>音频系统

引言

ALAudio Player (音频播放器)

ALTextToSpeech (声音合成)

ALSpeechRecognition (语音识别)

ALAudioDevice (音频器件)

ALSoundDetection(声音识别)

ALAudioSourceLocalization(音频源定位)

使用指导

本使用指导介绍如何说话、改变语音效果或是更改合成引擎的语言和语音。

注释:

所有提供的范例都使用Python语言编写。

在模块上创建一个代理

在使用TTS模块前,您必须在TTS模块上创建一个代理。

#Creates a proxy on the text-to-speech module from naoqi import ALProxy tts = ALProxy("ALTextToSpeech",IP,9559) #IP = IP address of your robot

说一个文本字符串

可以使用say函数来说一句话。

#Sends a string to the text-to-speech module tts.say("Hello World!")

改变音高

通过API可以调整语音音高。例如:

tts.setParameter("pitchShift", 1.1)

本命令提高主音的音高。1.1是调整的语音与原语音之间的基频比。

改变双语音参数

双语音渲染可使用三个参数进行修改:

  • doubleVoice: 调整的语音与原语音之间的基频比。
  • doubleVoiceLevel: 次音与主音间的音量比。
  • doubleVoiceTimeShift: 次音与主音间的时间变化。

例如,一个机器人的语音可以使用以下命令生成:

tts.setParameter("doubleVoice", 1) tts.setParameter("doubleVoiceLevel", 0.5) tts.setParameter("doubleVoiceTimeShift", 0.1) tts.setParameter("pitchShift", 1.1)

改变合成引擎的语言

可以使用setLanguage函数更改合成引擎的语言。 通过getAvailableLanguages函数可以获得可使用的语言列表。

#Example : set the language of the synthesis engine to English : tts.setLanguage("English")

改变合成引擎的语音

可以使用setVoice函数更改合成引擎的语音。 通过getAvailableVoices函数可以获得可使用的语音列表。 更改语音时,当前语言会自动替换为与该语音相匹配的语言。

#Example : use the voice of Kenny : tts.setVoice("Kenny22Enhanced")

改变合成的音量

可以使用setVolume函数更改语言合成的音量。 音量必须设定在0.0和1.0之间。 通过getVolume函数可以获得当前音量。

#Example : Adjust the volume of the text to speech to its maximum tts.setVolume(1.0)





Copyright © 2010 Aldebaran-Robotics - 版权所有