Getting Started with Python SDK (1) - Let NAO Speak

Getting Started with Python SDK (1) - Let NAO Speak

After the installation of the python for naoqi environment is complete, let's first try to make NAO say "Hello world":

from naoqi import ALProxy
tts = ALProxy("ALTextTpSpeech", "<IP of your robot>", 9559)
tts.say("Hello world")

This is a very simple program, right? Then add a little more difficulty and let it say a tongue twister:

#!/usr/bin/python
# -*- coding: utf-8 -*-

from naoqi import ALProxy
tts = ALProxy("ALTextToSpeech", "192.168.1.112", 9559)

tts.setLanguage("Chinese")

tts.say("你好,我是NAO")
tts.say("我不仅会说你好,我还会说绕口令")
tts.say("牛郎恋刘娘,刘娘念牛郎")
tts.say("牛郎年年恋刘娘")
tts.say("郎恋娘来娘念郎")
tts.say("念娘恋娘")
tts.say("念郎恋郎")
tts.say("念恋娘郎")

ALTextToSpeech is an interface that can speak in NAOqi. We import it to the object tts through ALProxy, and say() and setLanguage() are both member functions of this class, which are used to pass in the text to be spoken and set the language respectively. effect.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325689580&siteId=291194637