-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (37 loc) · 932 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"flag"
"fmt"
"log"
"github.com/algo-boyz/snowgirl/pkg/hotword"
"github.com/algo-boyz/snowgirl/pkg/onnx"
"github.com/algo-boyz/snowgirl/pkg/state"
)
var (
ctx = state.NewContext()
hotwordEmbedPath, hotwordNetPath string
err error
)
func init() {
flag.StringVar(&hotwordNetPath, "hotword", hotword.OnnxModelPath(), "efficient-wordnet .onnx path")
flag.StringVar(&hotwordEmbedPath, "embedding", hotword.EmbeddingsPath(), "hotword embedding .json path")
}
func main() {
flag.Parse()
go func() {
if err = run(ctx); err != nil {
log.Fatal(err)
}
}()
ctx.AwaitExit()
}
func run(ctx state.Context) error {
if err = onnx.FetchRuntime(); err != nil {
return fmt.Errorf("path to onnx runtime is required: %w", err)
}
snowgirl, err := NewSnowGirl(ctx, DefaultConfig())
if err != nil {
return err
}
return snowgirl.Listen()
}