forked from xinyunh0929/golang-samples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcaption_test.go
51 lines (42 loc) · 1.24 KB
/
caption_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
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"testing"
"github.com/GoogleCloudPlatform/golang-samples/internal/testutil"
)
func TestRecognize(t *testing.T) {
testutil.SystemTest(t)
resp, err := recognize("../testdata/quit.raw")
if err != nil {
t.Fatal(err)
}
if len(resp.Results) == 0 {
t.Fatal("got no results; want at least one")
}
result := resp.Results[0]
if len(result.Alternatives) < 1 {
t.Fatal("got no alternatives; want at least one")
}
if got, want := result.Alternatives[0].Transcript, "quit"; got != want {
t.Errorf("Transcript: got %q; want %q", got, want)
}
}
func TestRecognizeGCS(t *testing.T) {
testutil.SystemTest(t)
resp, err := recognizeGCS("gs://python-docs-samples-tests/speech/audio.raw")
if err != nil {
t.Fatal(err)
}
if len(resp.Results) == 0 {
t.Fatal("got no results; want at least one")
}
result := resp.Results[0]
if len(result.Alternatives) < 1 {
t.Fatal("got no alternatives; want at least one")
}
if got, want := result.Alternatives[0].Transcript, "how old is the Brooklyn Bridge"; got != want {
t.Errorf("Transcript: got %q; want %q", got, want)
}
}