-
Notifications
You must be signed in to change notification settings - Fork 6.6k
adding example for streaming audio #826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@gguuss can you take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yogeshg, @jonparrott and @gguuss are the maintainers/gatekeepers here(probably others as well?). They will have a few other suggestions as well.
@@ -0,0 +1,51 @@ | |||
#!/usr/bin/env python | |||
|
|||
# author: Yogesh Garg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yogeshg I think to be accepted you would need to add the Google copyright comment as can be seen here.
Your authorship should be in the commits. I don't see it displayed this way in the other files but @gguuss or @jonparrott would know for sure.
|
||
""" | ||
|
||
import logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure what this does but I imagine you would want to follow the style here with the # [START import_libraries]
.
def transcribe_stream(stream): | ||
logging.debug('{} is closed: {}'.format(str(stream), stream.closed)) | ||
|
||
sample = speech_client.sample( stream=stream, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space before stream=stream
here.
- sample( stream=stream)
+ sample(stream=stream)
encoding=speech.Encoding.LINEAR16, | ||
sample_rate=SAMPLE_RATE) | ||
results = list(sample.streaming_recognize()) | ||
print 'results len:{}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to have parentheses for Python 3 support.
- print 'results len:{}'
+ print('results len: {})
sample_rate=SAMPLE_RATE) | ||
results = list(sample.streaming_recognize()) | ||
print 'results len:{}' | ||
for r in results: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally one letter variable names are discouraged.
Simple enough to fix these... /r/result/ and /a/alternative/
|
||
if __name__ == '__main__': | ||
args = parse_args() | ||
main( args ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- main( args )
+ main(args)
old pull request: GoogleCloudPlatform#826 will add new pull request
@jonparrott and @gguuss, |
Adding an example for streaming audio. This usecase was missing from Google Cloud Speech API. The documentation was misleading and was updated in PR #3074 for google-cloud-python