MacOS – Starting airplay from command line, to send output of ‘Say’ Mac OS X command to airplay

airplayaudiocommand linemacosterminal

Ok, Sunday question 🙂 Trying to make a little joke…

  1. if you open a terminal, and type "say -a ?", Mac OS X will give you the list of devices it can send spoken words to. On mine, it says:

    39 AirPlay
    47 Built-in Output
    
  2. I have a Denon airplay-ready received in my living room and I'm trying to send spoken words to my wife downstairs… I can send music without any problem using iTunes so, from an infrastructure standpoint, I'm all set.

  3. I want my computer to say (out of the blue) "Honey, why don't you bring me a cup of coffee". I can make it say that locally on my internal laptop speakers, but I can't seem to send that to device 39 successfully.

I am suspecting that there are a few other things that need to be setup before it works, i.e. setting up airplay output to "denon", maybe opening a channel and reserving it. I don't know.

Has anyone played with this? Is there a way to setup airplay from the command line? That would be awesome 🙂

Best Answer

I was playing with this a couple of weeks ago.

To send to my Apple Tv via airplay I used

 say -r160 -a "AirPlay" "Hover over a Method name while holding down the Option key until a question mark  appears"

One thing I noticed at the time was that I sometimes would have to run a second command to switch the audio back to the computer.

 say -r160 -a "AirPlay" "Hover over a Method";say -r160 -a "Built-in Output" "I am back"

*update Just tested using the numbers and they work just as well in place of the device name.