Chromecast+TTS = Party: PA.js

December 11, 2016

I put this together in an afternoon hack session and was planning to extend it and clean up the code. However, its been months and the holidays are rolling around and it’s yet to be published! I wanted to put out a small writeup how to harness your Chromecasts for home automation, scripting, and fun.

Back at my previous job, we had installed Chromecasts throughout the building hooked up to speakers and TVs. We used them during social functions to play music throughout the building and the deck. I’ve always been a fan of the Chromecast since the initial announcement and still own my v1. I was familiar with the network model how Chromecasts use MultiCast for service discovery. This is how all your wifi devices on the same router are able to see each other. I thought it would be really cool to broadcast announcements throughout the building.

But to have a resource play I needed to stream a resource accessible to the Chromecast like a public URL. At this point, I was looking at Text-to-Speech libraries and found sadly there are far few and between standalone free and open source projects. You could use OSX Say to record a WAV to stream but it wouldn’t work on other platforms and I would have to reupload to somewhere like s3 or a public server (too slow!).

However the useful marrying of using Google Text-to-speech as public resources to translate English to English. Success! now a streamable URL could be pointed to the Chromecast and we could selectively blast all the Chromecasts in the building. Even Google Translate had an easter egg where you could make beatbox using german tones. However, this since has been removed videos still exist for posterity.

Have fun and Thanks for the wonderful work of Mafintosh on Chromecast to make this surprisingly easy. Source code attached, it takes in input and broadcasts it to all your Chromecasts in your building.