Memo to create your own Box with Pepper's Python

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

environment

Create

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

Try to log

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.

Let me talk

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

Summary

I remembered self.logger.info () and self.tts.post.say ().

Recommended Posts

Memo to create your own Box with Pepper's Python
Create folders from '01' to '12' with python
How to create your own Transform
Create your own Linux commands in Python
Convert memo at once with Python 2to3
Create wordcloud from your tweet with python3
Memo to ask for KPI with python
[LLDB] Create your own command in Python
Create your own DNS server with Twisted
Create your own Composite Value with SQLAlchemy
To import your own module with jupyter
Publish your own Python library with Homebrew
Create your own virtual camera with Python + OpenCV and apply original effects
How to access data with object ['key'] for your own Python class
Try to make your own AWS-SDK with bash
Make your own module quickly with setuptools (python)
Steps to create a Twitter bot with python
Steps to install your own library with pip
Create your own exception
The road to updating Splunkbase with your own Splunk app for Python v2 / v3
Flow of creating your own package with setup.py with python
A memo connected to HiveServer2 of EMR with python
Create your own Big Data in Python for validation
[Introduction to Udemy Python 3 + Application] 66. Creating your own exceptions
Create your own Random Dot Stereogram (RDS) in Python.
Try to improve your own intro quiz in Python
Let's call your own C ++ library with Python (Preferences)
Introduction to Mathematics Starting with Python Study Memo Vol.1
[Blender × Python] Create your own function & summary so far
[Python] A memo to write CSV vertically with Pandas
[Road to intermediate Python] Define in in your own class
[Python] How to create a 2D histogram with Matplotlib
Connect to BigQuery with Python
Twitter graphing memo with Python
Create 3d gif with python3
Connect to Wikipedia with Python
Post to slack with Python 3
Create your own Django middleware
Switch python to 2.7 with alternatives
Write to csv with Python
Create a directory with python
Until you can install your own Python library with pip
Create a Mastodon bot with a function to automatically reply with Python
Try sorting your own objects with priority queue in Python
Probably the easiest way to create a pdf with Python3
Run the intellisense of your own python library with VScode.
Create a message corresponding to localization with python translation string
[Python Kivy] How to create an exe file with pyinstaller
Reinforcement learning 23 Create and use your own module with Colaboratory
[Django] Memo to create an environment of Django + MySQL + Vue.js [Python]
Try HeloWorld in your own language (with How to & code)
Create a Python (Django) learning environment with Docker so that you can debug with VS Code (almost your own procedure memo)
Create plot animation with Python + Matplotlib
Python: How to use async with
[Python] Make your own LINE bot
Create Awaitable with Python / C API
Link to get started with python
[Python] logging in your own module
[Python] Write to csv file with Python
Nice to meet you with python
Try to operate Facebook with Python