Skip to content

It makes Google Home speak something by both command line and web server and is same to google-home-notifier.

License

Notifications You must be signed in to change notification settings

hiromaily/go-google-home

Repository files navigation

go-google-home

Build Status Go Report Card codebeat badge Codacy Badge MIT License

It makes Google Home spoken something and is inspired by google-home-notifier.
There are 3 modes.

  • speak message
  • play sound data
  • run as server mode then http request with messages can be handled to speak

Note

  • Google Home device should be in same local network with installed machine
  • Google Home device IP address would be detected automatically. So it's not necessarily to specify device IP address.

Requirements

  • Golang 1.15+
  • direnv for MacOS user under development
  • Ngrok if you want to access installed machine from outside

Installation

for MacOS user

$ brew install hiromaily/tap/go-google-home
 
# config file is installed in /usr/local/etc/google-home/gh.toml
# modify `gh.toml` if settings wanna be changed

# run
$ gh speak -msg "Hi guys, thank you for using. Have fun."

subcommand

subcommand example
speak speak message on google home gh speak -msg "hello guys"
play play sound data on google home gh play -url xxxxx.mp3
server run web server to handle http request with message gh server -port 8888

basic command line option

options type example
toml TOML file path string -toml ./configs/default.toml
addr specify address of Google Homee string -addr xxx.xxx.xxx.xxx:8009
lang spoken language, default is english string -lang en
v show version bool -v

environment variable for development

environment variable GO_GOOGLE_HOME_CONF is used as default config path

example

# saying something in English
$ gh speak -msg "Thank you."

# saying something in Japanese
$ gh -lang ja speak -msg "ありがとうございます"

# saying something in Dutch
$ gh -lang nl speak -msg "Dank je" 

# saying something in German
$ gh -lang de speak -msg "Danke."

# saying something in French
$ gh -lang fr speak -msg "Merci."

# playing music
$ gh play -url "https://github.com/hiromaily/go-google-home/raw/master/assets/music/bensound-dubstep.mp3"

# using specific IP address of Google Home.
$ gh -addr "10.0.0.1:8009" -msg "It reaches to specific IP address."

example as server

# server mode
$ gh server -port 8888

# then post message to server by HTTPie
$ http POST http://localhost:8080/speak text="It's sunny day today."

[WIP] send messages from Slack channel by integration

setup Google Apps Script

  1. create http endpoint from Slack using Google Apps Script
  2. deploy it and get endpoint URL

setup Slack

  1. create new App google-home from slack apps on your slack workspace
  2. use Slack Events API

How to access to local server from outside easily?

Use Ngrok

Install on Mac

$ brew install --cask ngrok
# If you use 8080 port for that local server.
$ ngrok http 8080

About

It makes Google Home speak something by both command line and web server and is same to google-home-notifier.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published