multi model, custom output support
parent
0345cf00e6
commit
0027ce8fa9
|
|
@ -12,6 +12,8 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/brentnd/go-snowboy"
|
"github.com/brentnd/go-snowboy"
|
||||||
|
|
@ -76,12 +78,12 @@ func (s *Sound) Read(p []byte) (int, error) {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
resources := flag.String("r", "", "path to the .res file")
|
resources := flag.String("r", "", "path to the .res file")
|
||||||
model := flag.String("m", "", "path to the .?mdl file")
|
models := flag.String("ms", "", "comma delimited path to the .?mdl file/output")
|
||||||
sensitivity := flag.Float64("s", 0.45, "0..1")
|
sensitivity := flag.Float64("s", 0.45, "0..1")
|
||||||
quiet := flag.Bool("q", false, "emit '1' on detect else silent")
|
quiet := flag.Bool("q", false, "emit '1' on detect else silent")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *resources == "" || *model == "" {
|
if *resources == "" || *models == "" {
|
||||||
panic("all flags must be set")
|
panic("all flags must be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,13 +97,14 @@ func main() {
|
||||||
defer d.Close()
|
defer d.Close()
|
||||||
|
|
||||||
// set the handlers
|
// set the handlers
|
||||||
d.HandleFunc(snowboy.NewHotword(*model, float32(*sensitivity)), func(string) {
|
for _, modelStr := range strings.Split(*models, ",") {
|
||||||
|
d.HandleFunc(snowboy.NewHotword(path.Dir(modelStr), float32(*sensitivity)), func(string) {
|
||||||
if !*quiet {
|
if !*quiet {
|
||||||
log.Println("GOTCHA!")
|
log.Println("GOTCHA!")
|
||||||
} else {
|
|
||||||
fmt.Printf("1")
|
|
||||||
}
|
}
|
||||||
|
fmt.Println(path.Base(modelStr))
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
d.HandleSilenceFunc(1*time.Second, func(string) {
|
d.HandleSilenceFunc(1*time.Second, func(string) {
|
||||||
if !*quiet {
|
if !*quiet {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue