Let's make a Pepper Box. There are various articles written by other people, but it is a memorandum.
Reference Add python module http://qiita.com/hws-hitorobo/items/5b0178d291e87c643bf3 Self-made function http://qiita.com/Ryo87/items/77e1d19b80c77d2733c8 Create HTTP GET Box http://qiita.com/Atelier-Akihabara/items/acc8d2ad6c3881f112a4
Let's add a Box for Python Script
under Box libraries> Programming> Templates
.
Double-click to see the initial code.
app.py
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
#put initialization code here
pass
def onUnload(self):
#put clean-up code here
pass
def onInput_onStart(self):
#self.onStopped() #activate the output of the box
pass
def onInput_onStop(self):
self.onUnload() #it is recommended to reuse the clean-up as the box is stopped
self.onStopped() #activate the output of the box
I want console.log ()
in JavaScript,
It seems that self.logger.info ()
can be used.
I deleted the initial comment and added it for the sake of clarity.
app.py
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
pass
def onUnload(self):
pass
def onInput_onStart(self):
self.logger.info("Hello") #← Addendum
pass
def onInput_onStop(self):
self.onUnload()
self.onStopped()
When executed, it will flow to Log Viewer like this.
I am preparing to use the talking function with self.tts = ALProxy ('ALTextToSpeech')
.
You can actually speak with self.tts.post.say ()
.
app.py
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
self.tts = ALProxy('ALTextToSpeech') #← Addendum
def onLoad(self):
pass
def onUnload(self):
pass
def onInput_onStart(self):
self.logger.info("Hello")
self.tts.post.say("Good morning, Mr. Ryuzaki.") #← Addendum
pass
def onInput_onStop(self):
self.onUnload()
self.onStopped()
I talked to Mr. Tatsuzaki who just passed by.
http://liginc.co.jp/member/member_detail?user=dragon
I remembered self.logger.info ()
and self.tts.post.say ()
.
Recommended Posts