package main
import (
"github.com/evalphobia/google-home-client-go/googlehome"
)
func main() {
cli, err := googlehome.NewClientWithConfig(googlehome.Config{
Hostname: "192.168.0.1",
Lang: "en",
Accent: "GB",
})
if err != nil {
panic(err)
}
// Speak text on Google Home.
cli.Notify("Hello")
// Change language
cli.SetLang("ja")
cli.Notify("こんにちは、グーグル。")
// Or set language in Notify()
cli.Notify("你好、Google。", "zh")
//Play Audio
cli.Play("http://127.0.0.1/night.mp3")
//Stop Audio
cli.StopMedia()
//Min of 0.0 Max of 1.0 (Must be of type Float)
cli.SetVolume(0.5)
//Get Volume Google Home is running at
cli.GetVolume()
//Kills the running Application (Disconnects from Google Home)
cli.QuitApp()
}
Name | Description |
---|---|
GOOGLE_HOME_HOST |
Hostname or IP address of Google Home for speech feature. |
GOOGLE_HOME_PORT |
Port number of Google Home. Default is 8009 . |
GOOGLE_HOME_LANG |
Speaking language of Google Home. Default is en . |
GOOGLE_HOME_ACCENT |
Speaking accent of Google Home. Default is us . |
This library is based on github.com/kunihiko-t/google-home-notifier-go by kunihiko-t and heavily depends on github.com/barnybug/go-cast.
This port version supports environment value config and some feature.