File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 19
19
import argparse
20
20
import base64
21
21
import json
22
+ import os
22
23
23
24
from googleapiclient import discovery
24
25
29
30
30
31
# Path to local discovery file
31
32
# [START discovery_doc]
32
- API_DISCOVERY_FILE = 'speech-discovery_google_rest_v1.json'
33
+ API_DISCOVERY_FILE = os .path .join (
34
+ os .path .dirname (__file__ ), 'speech-discovery_google_rest_v1.json' )
33
35
# [END discovery_doc]
34
36
35
37
@@ -67,7 +69,7 @@ def main(speech_file):
67
69
'sampleRate' : 16000
68
70
},
69
71
'audioRequest' : {
70
- 'content' : speech_content
72
+ 'content' : speech_content . decode ( 'UTF-8' )
71
73
}
72
74
})
73
75
# [END construct_request]
Original file line number Diff line number Diff line change
1
+ # Copyright 2016, Google, Inc.
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ import re
15
+
16
+ from speechrest import main
17
+
18
+
19
+ def test_main (resource , capsys ):
20
+ main (resource ('audio.raw' ))
21
+ out , err = capsys .readouterr ()
22
+
23
+ assert re .search (r'how old is the Brooklyn Bridge' , out , re .DOTALL | re .I )
You can’t perform that action at this time.
0 commit comments