-
Notifications
You must be signed in to change notification settings - Fork 1
/
transcriber_test.go
39 lines (33 loc) · 834 Bytes
/
transcriber_test.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
package transcriber
import (
"github.com/xlab/pocketsphinx-go/sphinx"
"os"
"testing"
)
func TestTranscribe(t *testing.T) {
want := "this is a test"
cfg := sphinx.NewConfig(
sphinx.HMMDirOption("/usr/local/share/pocketsphinx/model/en-us/en-us"),
sphinx.DictFileOption("/usr/local/share/pocketsphinx/model/en-us/cmudict-en-us.dict"),
sphinx.LMFileOption("/usr/local/share/pocketsphinx/model/en-us/en-us.lm.bin"),
sphinx.SampleRateOption(16000),
sphinx.LogFileOption("sphinx.log"),
)
dec, err := sphinx.NewDecoder(cfg)
if err != nil {
t.Error(err)
}
file, err := os.Open("example.wav")
if err != nil {
t.Error(err)
}
defer file.Close()
c := Read(file)
got, _, err := Transcribe(dec, c)
if err != nil {
t.Error(err)
}
if got != want {
t.Errorf("Transcribe(dec, c) = %q, want %q", got, want)
}
}