Skip to content

evalphobia/google-home-client-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Google Home client for golang

GoDoc License: MIT Release Build Status Codecov Coverage Go Report Card Downloads

Quick Usage

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()

}

Environment variables

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.

Credit

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.

About

Google Home client for golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages