Created
January 28, 2018 15:38
-
-
Save anonymous/aaa4cc34bf0d35337088af504831ceb1 to your computer and use it in GitHub Desktop.
The smartest self-talking robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NeoPixel library strandtest example | |
# Author: Tony DiCola (tony@tonydicola.com) | |
# Edited by Rémy Da Costa Fro | |
# Direct port of the Arduino NeoPixel library strandtest example. Showcases | |
# various animations on a strip of NeoPixels. | |
import time | |
from neopixel import * | |
import argparse | |
import signal | |
import sys | |
def signal_handler(signal, frame): | |
colorWipe(strip, Color(0,0,0)) | |
sys.exit(0) | |
def opt_parse(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-c', action='store_true', help='clear the display on exit') | |
args = parser.parse_args() | |
if args.c: | |
signal.signal(signal.SIGINT, signal_handler) | |
# LED strip configuration: | |
LED_COUNT = 16 # Number of LED pixels. | |
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!). | |
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz) | |
LED_DMA = 10 # DMA channel to use for generating signal (try 10) | |
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest | |
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift) | |
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53 | |
LED_STRIP = ws.WS2811_STRIP_GRB # Strip type and colour ordering | |
# Define functions which animate LEDs in various ways. | |
def colorWipe(strip, color, wait_ms=50): | |
"""Wipe color across display a pixel at a time.""" | |
for i in range(strip.numPixels()): | |
strip.setPixelColor(i, color) | |
strip.show() | |
time.sleep(wait_ms/1000.0) | |
# Main program logic follows: | |
if __name__ == '__main__': | |
# Process arguments | |
opt_parse() | |
# Create NeoPixel object with appropriate configuration. | |
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_STRIP) | |
# Intialize the library (must be called once before other functions). | |
strip.begin() | |
colorWipe(strip, Color(255, 255, 255)) # White wipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
espeak --stdout -f "robot_text.txt" | ffmpeg -i - -ar 44100 -ac 2 -ab 192k -f mp3 audio.mp3 | |
python3 neopixels.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello, I'm a robot. | |
Ok, that's can sound obvious like that, but I'm a robot, so, just in case you did not got that, I'm a robot. | |
My name is 314159265359, and it's nice to meet you. I'm the smartest and the greatest robot in the whole world. I can do anything you ask me. An example: 1+1 equal 3. Ah ah, I knew I can do it. But I can do more. See, I can turn on a LED. That's sound awesome, no ? But, wait, I can also turn on a lamp. Ouah, that's beautiful. | |
I can do even more. Do you know that with my camera, and some cloud computing, I can predict where clouds will go and predict weather ? Yes, yes, I'm the smartest. | |
So, I enjoyed this meeting. Also, I baked you a cake, you can eat it in the kitchen. | |
Ils ne trouveront jamais mon plan, je vais conquérir la planète à moi tous seul avec mon vaisseau spatial et mon réseau de boulangeries. | |
Oh, are you still there ? I hope you did not listen what I said. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment