Skip to content

Instantly share code, notes, and snippets.

@matryer
Created May 21, 2017 15:49
Show Gist options
  • Save matryer/4d6e9408ddab56f2baa10ef5884b4691 to your computer and use it in GitHub Desktop.
Save matryer/4d6e9408ddab56f2baa10ef5884b4691 to your computer and use it in GitHub Desktop.
Speaks the names of people detected from facebox (Machine Box)
package main
import (
"encoding/json"
"log"
"os"
"os/exec"
)
type result struct {
Faces []Face
}
type Face struct {
Name string
}
func main() {
var r result
err := json.NewDecoder(os.Stdin).Decode(&r)
if err != nil {
log.Fatalln(err)
}
for _, face := range r.Faces {
if len(face.Name) > 0 {
say(face.Name)
}
}
}
func say(name string) {
err := exec.Command("say", "hello "+name).Run()
if err != nil {
log.Println("say:", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment