Page 1 of 1

How to do announcements with Airfoil Pro and Google Homes

PostPosted: Fri Jan 12, 2018 10:57 am
by Juggler
Running the latest version of Indigo and Airfoil on OS X 10.11.6. I have several Google Home Minis through my house and would like to be able to send announcements (indigo.server.speak("text to speak", waitUntilDone=True).

I'm struggling with how to code this in python. I've tried the following:
Code: Select all
airfoilPlugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.airfoilpro")

if airfoilPlugin.isEnabled():
    try:
        result = airfoilPlugin.executeAction("connect", deviceId=SPEAKERID, waitUntilDone=True)
        indigo.server.speak("text to speak", waitUntilDone=True)
        result = airfoilPlugin.executeAction("disconnect", deviceId= SPEAKERID, waitUntilDone=True)

    except Exception, e:
        print "Exception occurred: %s" % unicode(e)

However the above code only seems to connect to the speaker, then disconnect. I do not hear any announcement. I'm sure I'm missing something basic here...

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Fri Jan 12, 2018 12:05 pm
by jay (support)
Is Airfoil directing your Mac's speech to the speaker?

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Fri Jan 12, 2018 12:17 pm
by Juggler
Using the terminal on my Mac, I can get the Google Home to speak with the CLI (say "hello"). To do this, I have to have the source set to com.apple.speech.speechsynthesisd and pre-select the correct Google Home in the light blue list of speakers.

I did see in Airfoil's preferences there is an "Automatically Transmit To" tab. I've tried to use this, but nothing worked.

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Fri Jan 12, 2018 12:23 pm
by Colorado4Wheeler
What is Airfoil's speaker setting? Where's it getting it's audio?

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Fri Jan 12, 2018 12:34 pm
by Juggler
This is how I have it set.

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Fri Jan 12, 2018 3:59 pm
by jay (support)
I don't have any Google Home devices, but all my AirPlay devices are working correctly. I have System Audio selected, and I can direct all sound (including Indigo speech) to any AirPlay destination.

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Fri Jan 12, 2018 4:03 pm
by jay (support)
Are you running the Indigo Client and Server on the same Mac?

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Fri Jan 12, 2018 7:06 pm
by Juggler
No... running Indigo on a headless Mac in my basement. Will have to play more. Wonder if there is something particular to Google Homes?

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Fri Jan 12, 2018 10:29 pm
by Colorado4Wheeler
No, I don’t think it is Google Home because I tried your code myself out of curiosity and it’s the same result to an AirPlay device.

So I then set up an action group that did the same thing and got almost the same result. My test was to say “test speech” and it got “t” out (maybe it was “ch”) but I got a tiny bit of speech.

This led me to try a really long phrase “the brown cow jumped over the big white fence” and got “umped over the big white fence” with the action group but the same phrase in the Py code got nothing at all.

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Sat Jan 13, 2018 1:19 pm
by Juggler
Looks like it may be a timing problem. The following code works for me:
Code: Select all
import time
airfoilPlugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.airfoilpro")

if airfoilPlugin.isEnabled():
    try:
        result = airfoilPlugin.executeAction("connect", deviceId=1419104389, waitUntilDone=True)  # ID of Speaker device
        time.sleep(10)
        indigo.server.speak("text to speak", waitUntilDone=False)
    except Exception, e:
        print "Exception occurred: %s" % unicode(e)

I've then got Airfoil to auto-disconnect from speakers after 1m of silence.

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Sat Jan 13, 2018 3:38 pm
by Colorado4Wheeler
Yea, that was going to be my next step if I hadn't been working on other plugin stuff today, I assumed it was timing based on my test results. The timing of calling it from code is more than the timing of calling it from the native UI apparently.

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Sat Jan 13, 2018 7:12 pm
by Juggler
It's too bad about the 10s timing issue... there is a way with a Google Home that allows you to broadcast a message to all of the ones connected to your account. Unfortunately, this would require Oauth. I remember reading in a thread somewhere that Matt & Jay were looking into adding an Oauth server? +1 for that. (would also allow me to start using my GH for device control).

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Sun Jan 14, 2018 4:44 pm
by jay (support)
So, it's taking 10 seconds for Airfoil to connect to the Google Home? That seems excessive. I just tested it and it connects to my AirPlay devices in < 3secs...

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Sun Jan 14, 2018 5:24 pm
by Colorado4Wheeler
jay (support) wrote:
I just tested it and it connects to my AirPlay devices in < 3secs...


So does mine about 80% of the time, but - and perhaps this is the result of other processes on the computer running Indigo - it can take 5+ seconds. This has been on my todo list to add to one of my plugins for a while so I just rolled it into on to see if running as a plugin thread made any difference and it's about the same performance.

Re: How to do announcements with Airfoil Pro and Google Home

PostPosted: Mon Jan 22, 2018 12:27 pm
by jay (support)
My guess is that it's somewhat network intensive and so connection times can vary given the amount of other things that the device being AirPlayed to is doing and what other network traffic is going on.