google-home-client-go

module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2020 License: MIT

README

Google Home client for golang

GoDoc 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL