sudo apt-get install alsa-utils sudo apt-get install mplayer
# utf8, # -*- coding: utf-8 -*- # import webiopi import subprocess import feedparser # GPIO GPIO = webiopi.GPIO # GPIO LIGHT = 23 BUTTON1 = 17 BUTTON2 = 22 def setup(): # GPIO GPIO.setFunction(LIGHT, GPIO.OUT) GPIO.setFunction(BUTTON1, GPIO.IN) GPIO.setFunction(BUTTON2, GPIO.IN) def loop(): # 1 if (GPIO.digitalRead(BUTTON1) == GPIO.HIGH): # ( ) GPIO.digitalWrite(LIGHT, not GPIO.digitalRead(LIGHT)) # 2 if (GPIO.digitalRead(BUTTON2) == GPIO.HIGH): # subprocess.call(["mplayer", "http://translate.google.com/translate_tts?tl=ru&ie=UTF-8&q=, , ."]) # d = feedparser.parse('http://rp5.kz/rss/76334/ru') # subprocess.call(["mplayer", "http://translate.google.com/translate_tts?tl=ru&ie=UTF-8&q="+d.entries[0].title]) def destroy(): # , ) GPIO.digitalWrite(LIGHT, GPIO.LOW)
Source: https://habr.com/ru/post/362075/
All Articles