Created
May 21, 2017 15:49
-
-
Save matryer/4d6e9408ddab56f2baa10ef5884b4691 to your computer and use it in GitHub Desktop.
Speaks the names of people detected from facebox (Machine Box)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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