Adding wildcards to Google AIY actions on Raspberry Pi.

I’ve been playing with Google AIY on raspberry pi for nearly an hour now and I love it. If you are lucky you can get your kit from issue 57 of The MagPi Magazine.

Google provided a python based example app that recognises the command you spoke to the box and runs your action. The problem with it is that the command needs to match literally without and option to add variable part (a parameter). In real world I want to give parameters to the commands, for example “Add note my note“. So I’ve hacked the app to do just that. Here are the steps:
1. Modify the actionbase.py to recognize patterns. In class class KeywordHandler(object): change the handle method:

class KeywordHandler(object):

    """Perform the action when the given keyword is in the command."""

    def __init__(self, keyword, action):
        self.keyword = keyword.lower()
        self.action = action

    def get_phrases(self):
        return [self.keyword]

    def handle(self, command):
        if("*" in self.keyword):
            match = re.match(self.keyword.lower(), command.lower())
            if match:
                param=match.group(1)
                self.action.run(param)
                return True
        else:
            if self.keyword in command.lower():
                self.action.run(command)
                return True
            else:
                return False

2. Make sure the action you are running understands that the param given to it is the variable part. I’ve modified the SpeakAction to do just that:

class SpeakAction(object):

    """Says the given text via TTS."""

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

    def run(self, voice_command):
        newwords=self.words.replace("$1",voice_command)
        self.say(newwords)

3. Add new action in make_actor method:

    actor.add_keyword(_('add note (.*)'),SpeakAction(say,"adding $1"))

Have fun!

Share and Enjoy:
  • Digg
  • Facebook
  • Blip
  • Kciuk.pl
  • StumbleUpon
  • Wykop
Share

AI may help electic cars

https://www.fastcompany.com/40405140/this-driverless-electric-pod-is-the-delivery-guy-of-the-future

Since a truck hauling 20 tons of freight needs a lot of energy to move, it has to stop fairly frequently to charge; the T-pod can make it 124 miles before it has to plug in again. For other electric semis, charging time is a bigger deterrent, because it’s also wasting a driver’s time.

“If you have to stand still maybe one-third of the time to actually charge, that makes the business case for having a truck driver in a battery-powered truck not that good,” says Robert Falck, CEO of Einride, the Sweden-based startup making the T-pod. “But if you remove them and create a system where the truck driver drives it remotely and controls a fleet, you overcome that problem.”

Share and Enjoy:
  • Digg
  • Facebook
  • Blip
  • Kciuk.pl
  • StumbleUpon
  • Wykop
Share

Loss of jobs to AI and Robotics

http://www.pwc.co.uk/economic-services/ukeo/pwc-uk-economic-outlook-full-report-march-2017-v2.pdf

https://www.theguardian.com/technology/2017/jan/05/japanese-company-replaces-office-workers-artificial-intelligence-ai-fukoku-mutual-life-insurance

JPMorgan Software Reviews Contracts in Seconds Which Normally Takes Their Lawyers 360,000 Hours

https://www.newscientist.com/article/mg23331144-500-ai-learns-to-write-its-own-code-by-stealing-from-other-programs/

Share and Enjoy:
  • Digg
  • Facebook
  • Blip
  • Kciuk.pl
  • StumbleUpon
  • Wykop
Share

I’m not happy with Virgin Hub 3.0 (BT Hub 4 is much better)

 

For last two months I’ve been using Virgin Media Hub 3.0 and I haven’t found a single think to like about it. Part of it is that Virgin Media internet isn’t as good as promised – 200Mbps link gives this speed only during benchmarks to VM servers. Real world speeds usually hover around 20Mbps with up to 50-60Mbps when using multiple sources – for tasks like downloading CentOS images (I’ve testes many, many mirrors).

The things I do not like about the VM hub are:

  • DHCP cache is reset every restart, so my systems get different IPs from time to time (BT Hub remembered all system correctly)
  • UPnP doesn’t work. It is enabled, but I haven’t found any application that was able to set up port forwarding correctly
  • Using the admin panel is pain in the back – (login screen the admin panel takes 13 seconds to load, main screen takes about 22 seconds to display!) – see screenshots.

    vmpanel

    vmpanel2.

  • WiFi range seems to be less than average. I get the best coverage upstairs when the router is laying on a side.

I’m going to set the VM router into modem only mode and I’ll use BT Hub as my router instead.

Share and Enjoy:
  • Digg
  • Facebook
  • Blip
  • Kciuk.pl
  • StumbleUpon
  • Wykop
Share

Should I buy wireless headphones?

Well… no.

 

I really wanted to have wireless headphones for running and gym visits, so I got myself a pair of Skull Candy SMOKIN’ BUDS 2 WIRELESS. Those headphones sound good enough for exercise – on par with in-ear headphones I used so far (Sony from Xperia Z and Z3 and Skull Candy buds).

But I’m not happy with the purchase. Here’s why:

  • The wireless headphones need charging. I’ve already run out of power once in the gym. And even if you have power the headphones tell you they need  charging soon by… beeping. Beep… beep… beep… every few seconds. Try to concentrate with that in your ears.
  • The headphones are not wireless. There’s no wire to connect to the phone, but there’s quite a lot of wire connecting the in-ear buds. And this wire is more annoying that a standard cable, because it’s not attached to a fixed point, so it bounces around neck. And it has a sizeable bit of plastic in the middle. Skull Candy tried to patch this by adding a quite heavy rubbery neck bundle. Which stills bounces a bit and is no less irritating.
  • Android 6 cannot reliable handle BT audio. I’m using BT audio in my car, with Sony SRS-X55 speaker and with those headphones. Switching between Sony speaker, car and SB2 sometimes confuses Android. I had to go to BT settings to remove the connection and reconnect the phone again to all those devices several times. It doesn’t always help – I had to restart my phone three times as well. Which is not what I want to be doing in gym’s changing room!
  • BT range is good in theory, but seems to have gaps. Maybe my phone (Xperia z3) has a directional antenna or maybe it’s the headphones. I can leave the phone 3 to 5 meters from me and the sound is working well, but as soon as I slip the phone into my pocket the sounds starts to break. Not much, but I’m getting very short breaks every few steps – just like my body is blocking the signal.

Would I buy different headphones instead of SB2? No. The whole approach is broken and the whole ecosystem needs updating. I’ll try again in 3 years.

Share and Enjoy:
  • Digg
  • Facebook
  • Blip
  • Kciuk.pl
  • StumbleUpon
  • Wykop
Share