Skip to content
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