File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919import argparse
2020import base64
2121import json
22+ import os
2223
2324from googleapiclient import discovery
2425
2930
3031# Path to local discovery file
3132# [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' )
3335# [END discovery_doc]
3436
3537
@@ -67,7 +69,7 @@ def main(speech_file):
6769 'sampleRate' : 16000
6870 },
6971 'audioRequest' : {
70- 'content' : speech_content
72+ 'content' : speech_content . decode ( 'UTF-8' )
7173 }
7274 })
7375 # [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