Library for Python 3.4+ to push text message or audio file with the Google Home.
pip install googlehomepush
PyChromecast depends on the Python packages gTTS, pychromecast. Make sure you have these dependencies installed using pip install -r requirements.txt
from googlehomepush import GoogleHome
GoogleHome("LivingRoom").say("test")
GoogleHome("LivingRoom").play("http://www.hubharp.com/web_sound/BachGavotteShort.mp3")Create a new Google Home instance (a device name or host is mandatory).
devicenamecan be the google home name, or its IP (local).hostan ip of a Google Homeportport used to connect Google Hometts_builderthe tss engine to use. Available tts are:googleTTS_Builderimport withfrom googlehomepush.googletts import googleTTS_builder. Free TTS used by google translate. It's the default enginegooglecloudTTS_builderimport withfrom googlehomepush.googlecloudTTS import googlecloudTTS_builder. Google cloud TTS engine. See https://cloud.google.com/text-to-speech/docs/reference/libraries to create an account.
Push a message on Google home
textis the test message to saylangthe text language, default value is 'en'
Push a sond to Google home
urlan audio file URLcontentTypethe audi file content type
You can play a local file using http_server
from googlehomepush.http_server import serve_file
file_url = serve_file("/path/to/file", "audio/mp3")
GoogleHome("LivingRoom").play(file_url, "audio/mp3")- Thomas Deblock (@tdeblock)