Skip to content

Commit

Permalink
fixing async sample code (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
xinjiez authored and Jon Wayne Parrott committed Jul 11, 2016
1 parent 68251b0 commit 3de8240
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 8 additions & 0 deletions speech/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions speech/api/speech_async_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,23 @@
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
# GOOGLE_APPLICATION_CREDENTIALS
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]


Expand Down

0 comments on commit 3de8240

Please sign in to comment.