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
fixing async sample code
  • Loading branch information
xinjie
xinjie committed Jul 11, 2016
commit 8c95d7be09e06e3a4b2a1dc5f3669c3315de4c25
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