-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (36 loc) · 1.36 KB
/
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
46
47
48
49
package main
import (
"flag"
"fmt"
"github.com/asticode/go-astideepspeech"
"html"
"log"
"net/http"
)
var configDir = flag.String("configDir", "", "Path to config directory for the DeepSpeech Model files")
var model = flag.String("model", "output_graph.pbmm", "File name of the model (protocol buffer binary file)")
var alphabet = flag.String("alphabet", "alphabet.txt", "File name of the configuration file specifying the alphabet used by the network")
var lm = flag.String("lm", "lm.binary", "File name of the language model binary file")
var trie = flag.String("trie", "trie", "File name of the language model trie file created with native_client/generate_trie")
var runTime = flag.Int("rt", 0, "Length of time in seconds to listen for audio in before processing")
var M *astideepspeech.Model
func errCheck(err error) {
if err != nil {
panic(err)
}
}
func main() {
configureFlags()
// Initialize DeepSpeech
M = astideepspeech.New(*model, nCep, nContext, *alphabet, beamWidth)
defer M.Close()
if *lm != "" {
M.EnableDecoderWithLM(*alphabet, *lm, *trie, lmWeight, validWordCountWeight)
}
http.HandleFunc("/rec", ReceiveFile)
http.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, Firend ", html.EscapeString(r.URL.Path))
})
http.HandleFunc("/stream", socketHandler)
log.Fatal(http.ListenAndServe(":8080", nil))
}