News update - Similar to alexa (mp3 download)


5 posts
by philicibine » Fri May 12, 2017 9:24 am
thanks to @ktinkerer for his code to play radio stations.

I have adapted it to play the BBC World Service hourly update.

Code: Select all
# =========================================
# Makers! Implement your own actions here.
# =========================================

class HourlyBulletin(object):

    def __init__(self, say, keyword):
        self.say = say
        self.keyword = keyword

    def run(self, voice_command):

        logging.info("starting bulletin")
        self.say("Here is your news update")
        if voice_command == 'hourly bulletin':
         bulletin = "http://wsdownload.bbc.co.uk/worldservice/css/96mp3/latest/bbcnewssummary.mp3"

        p = subprocess.Popen(["/usr/bin/cvlc",bulletin],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
        p.poll()

        gpio.setmode(gpio.BCM)
        gpio.setup(23, gpio.IN)

        while True:
          if gpio.input(23) ==0:
               logging.info("stopping bulletin")
               p.kill()
               break
          time.sleep(0.1)



and further down the file
Code: Select all
    # =========================================
    # Makers! Add your own voice commands here.
    # =========================================

    actor.add_keyword(_('hourly bulletin'), HourlyBulletin(say,_('hourly bulletin')))
Posts: 3
Joined: Thu May 11, 2017 10:44 am
by markblue777 » Fri May 12, 2017 12:00 pm
Nice, think i will be implementing this one later
Posts: 25
Joined: Thu Sep 01, 2016 1:59 pm
by ZooC0d3 » Fri May 12, 2017 2:55 pm
Running nicely on a zero - thanks to both you and ktinkerer.
Posts: 16
Joined: Mon May 02, 2016 9:10 am
by VR6Pete » Mon May 15, 2017 11:44 am
Great !

Is there a stream just for UK news?

Cheers

Pete
Posts: 7
Joined: Sun May 14, 2017 8:10 pm
by ktinkerer » Mon May 15, 2017 12:02 pm
Aha I knew I'd seen this somewhere! I wanted to add it to the list of mods I've been making http://ktinkerer.co.uk/list-mods-raspberry-pi-aiy-project/ Hope you don't mind me adding it.
Posts: 35
Joined: Wed May 10, 2017 8:31 am