Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5f38078

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

File tree

Expand file treeCollapse file tree

2 files changed

+9
-356
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-356
lines changed

‎speech/api/speech-discovery_google_rest_v1.json

Copy file name to clipboardExpand all lines: speech/api/speech-discovery_google_rest_v1.json
-342Lines changed: 0 additions & 342 deletions
This file was deleted.

‎speech/api/speech_rest.py

Copy file name to clipboardExpand all lines: speech/api/speech_rest.py
+9-14Lines changed: 9 additions & 14 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.