-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
45 lines (39 loc) · 860 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
45
package main
import (
"context"
"flag"
"fmt"
"os"
"runtime"
"time"
)
var (
// flagDumpWAVFile is a flag to dump the audio to a WAV file.
flagDumpWAVFile = flag.Bool("dump-wav", false, "dump the audio to a WAV file")
// defaultTimeout is the default timeout for listening.
defaultTimeout = 30 * time.Second
)
// main is the entrypoint.
func main() {
runtime.LockOSThread()
flag.Parse()
ctx := context.Background()
// load config
cfg, err := loadConfig()
if err != nil {
fmt.Fprintf(os.Stderr, "error loading config: %v\n", err)
}
// process flags
cfg.DumpWAVFile = *flagDumpWAVFile
// create app
app, err := newApp(cfg)
if err != nil {
fmt.Fprintln(os.Stderr, "error initializing app:", err)
os.Exit(1)
}
// run app
if err := app.run(ctx); err != nil {
fmt.Fprintln(os.Stderr, "error running app:", err)
os.Exit(2)
}
}