Podcast Player for the Raspberry Pi AIY Project

I’ve added a podcast player with pause, resume and play a random episode to my MagPi Raspberry Pi Google AIY Projects box.

The code for the podcast player is here: https://github.com/ktinkerer/aiyprojects-raspbian/tree/podcast_player

You will need to copy actions.py, main.py and vlc.py from this branch and put them in your ~voice-recognizer-raspi/src/ folder.

This needs vlc to be installed.

sudo apt-get update
sudo apt-get install vlc

You also need to install the python package feedparser.

sudo pip install feedparser

Check vlc is working using:

cvlc http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_6music.m3u8

This should start playing a radio stream. Stop it with ctrl-c

Add your own podcasts in the list of urls, I’ve left some of my podcasts as an example but you will probably want to delete these. You need the podcast rss feed for this to work.

Restart the voice recognition service:

sudo systemctl restart voice-recognizer.service

Play podcasts with the command “podcast “. By default it will play the latest episode. To play a random episode say “random podcast . Pause and resume podcasts with “podcast pause” and “podcast resume”.

Check the logs for errors using

sudo journalctl -u voice-recognizer -f

You may need to tweak your podcast names depending on what the voice recogniser registers.

If you want to use all the mods I’ve made they are on this branch: https://github.com/ktinkerer/aiyprojects-raspbian/tree/my_mods/src

Using Voice Keywords – OK Google

This didn’t work with voice keywords as once the podcast was playing it was hard to get the box to recognise the keyword or the command. To get around this I’ve come up with a method where if you want to use voice keywords you can get the box to then wait until the button is pressed and this will stop the podcast playing.

To do this use the updated Github code and find these lines:

# Uncomment the following line if you want to use a voice trigger to start the podcast and the button to stop it, podcast will not pause and resume
# self.wait_for_button()

Delete the comment (and the space!) before self.wait_for_button()
Also, make sure you import the gpio module.

import RPi.GPIO as gpio

Pause and resume will no longer work with this method, the box will not respond to any commands until the button is pressed, then it will start listening for commands again.

Currently, if the podcast finishes playing the box will still be unresponsive until the button is pressed. I am trying to think of a way to get around this, any ideas let me know.

10 Comments

Add a Comment

Your email address will not be published. Required fields are marked *