Skip to content

Commit 5f38078

Browse files
author
Jerjou Cheng
committed
No need for speech discovery doc any longer.
1 parent fe09e93 commit 5f38078

File tree

2 files changed

+9
-356
lines changed

2 files changed

+9
-356
lines changed

speech/api/speech-discovery_google_rest_v1.json

-342
This file was deleted.

speech/api/speech_rest.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,29 @@
1919
import argparse
2020
import base64
2121
import json
22-
import os
2322

2423
from googleapiclient import discovery
25-
2624
import httplib2
27-
2825
from oauth2client.client import GoogleCredentials
2926
# [END import_libraries]
3027

31-
# Path to local discovery file
32-
# [START discovery_doc]
33-
API_DISCOVERY_FILE = os.path.join(
34-
os.path.dirname(__file__), 'speech-discovery_google_rest_v1.json')
35-
# [END discovery_doc]
28+
29+
# [START authenticating]
30+
DISCOVERY_URL = ('https://{api}.googleapis.com/$discovery/rest?'
31+
'version={apiVersion}')
3632

3733

3834
# Application default credentials provided by env variable
3935
# GOOGLE_APPLICATION_CREDENTIALS
4036
def get_speech_service():
41-
# [START authenticating]
4237
credentials = GoogleCredentials.get_application_default().create_scoped(
4338
['https://www.googleapis.com/auth/cloud-platform'])
44-
with open(API_DISCOVERY_FILE, 'r') as f:
45-
doc = f.read()
39+
http = httplib2.Http()
40+
credentials.authorize(http)
4641

47-
return discovery.build_from_document(
48-
doc, credentials=credentials, http=httplib2.Http())
49-
# [END authenticating]
42+
return discovery.build(
43+
'speech', 'v1', http=http, discoveryServiceUrl=DISCOVERY_URL)
44+
# [END authenticating]
5045

5146

5247
def main(speech_file):

0 commit comments

Comments
 (0)