Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3de8240

Browse files
xinjiezJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
fixing async sample code (GoogleCloudPlatform#412)
1 parent 68251b0 commit 3de8240

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

speech/api/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ for more information.
7272

7373
You should see a response with the transcription result.
7474

75+
* To run the `speech_async_rest.py` sample:
76+
77+
```sh
78+
$ python speech_async_rest.py resources/audio.raw
79+
```
80+
81+
You should see a response with the transcription result.
82+
7583
* To run the `speech_streaming.py` sample:
7684

7785
```sh

speech/api/speech_async_rest.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,23 @@
2222
import time
2323

2424
from googleapiclient import discovery
25+
import httplib2
2526
from oauth2client.client import GoogleCredentials
2627
# [END import_libraries]
2728

2829

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

3332

3433
# Application default credentials provided by env variable
3534
# GOOGLE_APPLICATION_CREDENTIALS
3635
def get_speech_service():
3736
credentials = GoogleCredentials.get_application_default().create_scoped(
3837
['https://www.googleapis.com/auth/cloud-platform'])
38+
http = httplib2.Http()
39+
credentials.authorize(http)
3940

40-
return discovery.build(
41-
'speech', 'v1beta1', credentials=credentials,
42-
discoveryServiceUrl=DISCOVERY_URL)
41+
return discovery.build('speech', 'v1beta1', http=http)
4342
# [END authenticating]
4443

4544

0 commit comments

Comments
 (0)