
Well now you can play any track from youtube - yay

- "Play <trackname>" and after a while (10 seconds) your track will start playing.
- Hold the button for 1 second to kill the music.
Install Intructions:
1. install required programs
First we need mps-youtube and youtube-dl installed
Code: Select all
sudo pip3 install mps-youtube youtube-dl
sudo apt-get update
sudo apt-get install vlc
Code: Select all
mpsyt set player vlc, set playerargs ,exit
Quick method:
Use this pre-edited action.py :
https://drive.google.com/open?id=0B5s6S ... 3FFdk11aVk
copy this to voice-recognizer-raspi/src/action.py and skip to step 8
or
Longer method:
Edit voice-recognizer-raspi/src/action.py :
Code: Select all
import RPi.GPIO as gpio
import time
Code: Select all
# =========================================
# Makers! Implement your own actions here.
# =========================================
playshell = None
class play(object):
def __init__(self, say, keyword):
self.say = say
self.keyword = keyword
def run(self, voice_command):
track = voice_command.replace(self.keyword, '', 1)
global playshell
if (playshell == None):
playshell = subprocess.Popen(["/usr/local/bin/mpsyt",""],stdin=subprocess.PIPE ,stdout=subprocess.PIPE)
playshell.stdin.write(bytes('/' + track + '\n1\n', 'utf-8'))
playshell.stdin.flush()
gpio.setmode(gpio.BCM)
gpio.setup(23, gpio.IN)
while gpio.input(23):
time.sleep(1)
pkill = subprocess.Popen(["/usr/bin/pkill","vlc"],stdin=subprocess.PIPE)
Code: Select all
# =========================================
# Makers! Add your own voice commands here.
# =========================================
actor.add_keyword(_('play'), play(say,_('play')))
Code: Select all
sudo systemctl restart voice-recognizer
(code at https://github.com/mikerr/aiy-playmusic )