diff --git a/speech/api/README.md b/speech/api/README.md index 0998e67a493..a017e3276bf 100644 --- a/speech/api/README.md +++ b/speech/api/README.md @@ -72,6 +72,14 @@ for more information. You should see a response with the transcription result. +* To run the `speech_async_rest.py` sample: + + ```sh + $ python speech_async_rest.py resources/audio.raw + ``` + + You should see a response with the transcription result. + * To run the `speech_streaming.py` sample: ```sh diff --git a/speech/api/speech_async_rest.py b/speech/api/speech_async_rest.py index c0ddbdb4cd5..a06102e6903 100644 --- a/speech/api/speech_async_rest.py +++ b/speech/api/speech_async_rest.py @@ -22,13 +22,12 @@ import time from googleapiclient import discovery +import httplib2 from oauth2client.client import GoogleCredentials # [END import_libraries] # [START authenticating] -DISCOVERY_URL = ('https://{api}.googleapis.com/$discovery/rest?' - 'version={apiVersion}') # Application default credentials provided by env variable @@ -36,10 +35,10 @@ def get_speech_service(): credentials = GoogleCredentials.get_application_default().create_scoped( ['https://www.googleapis.com/auth/cloud-platform']) + http = httplib2.Http() + credentials.authorize(http) - return discovery.build( - 'speech', 'v1beta1', credentials=credentials, - discoveryServiceUrl=DISCOVERY_URL) + return discovery.build('speech', 'v1beta1', http=http) # [END authenticating]