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).
devicename
can be the google home name, or its IP (local).host
an ip of a Google Homeport
port used to connect Google Hometts_builder
the tss engine to use. Available tts are:googleTTS_Builder
import withfrom googlehomepush.googletts import googleTTS_builder
. Free TTS used by google translate. It's the default enginegooglecloudTTS_builder
import 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
text
is the test message to saylang
the text language, default value is 'en'
Push a sond to Google home
url
an audio file URLcontentType
the 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)