Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No need for speech discovery doc any longer. #353

Merged
merged 1 commit into from
May 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
342 changes: 0 additions & 342 deletions speech/api/speech-discovery_google_rest_v1.json

This file was deleted.

23 changes: 9 additions & 14 deletions speech/api/speech_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,29 @@
import argparse
import base64
import json
import os

from googleapiclient import discovery

import httplib2

from oauth2client.client import GoogleCredentials
# [END import_libraries]

# Path to local discovery file
# [START discovery_doc]
API_DISCOVERY_FILE = os.path.join(
os.path.dirname(__file__), 'speech-discovery_google_rest_v1.json')
# [END discovery_doc]

# [START authenticating]
DISCOVERY_URL = ('https://{api}.googleapis.com/$discovery/rest?'
'version={apiVersion}')


# Application default credentials provided by env variable
# GOOGLE_APPLICATION_CREDENTIALS
def get_speech_service():
# [START authenticating]
credentials = GoogleCredentials.get_application_default().create_scoped(
['https://www.googleapis.com/auth/cloud-platform'])
with open(API_DISCOVERY_FILE, 'r') as f:
doc = f.read()
http = httplib2.Http()
credentials.authorize(http)

return discovery.build_from_document(
doc, credentials=credentials, http=httplib2.Http())
# [END authenticating]
return discovery.build(
'speech', 'v1', http=http, discoveryServiceUrl=DISCOVERY_URL)
# [END authenticating]


def main(speech_file):
Expand Down