Skip to content

adding example for streaming audio#826

Closed
yogeshg wants to merge 6 commits into
GoogleCloudPlatform:masterfrom
yogeshg:streaming-demo
Closed

adding example for streaming audio#826
yogeshg wants to merge 6 commits into
GoogleCloudPlatform:masterfrom
yogeshg:streaming-demo

Conversation

@yogeshg

@yogeshg yogeshg commented Feb 26, 2017

Copy link
Copy Markdown

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

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 26, 2017
@theacodes

Copy link
Copy Markdown
Contributor

@gguuss can you take a look?

@daspecster daspecster left a comment

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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,

Copy link
Copy Markdown

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:{}'

Copy link
Copy Markdown

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:

Copy link
Copy Markdown

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 )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- main( args )
+ main(args)

yogeshg added a commit to yogeshg/python-docs-samples that referenced this pull request Mar 2, 2017
old pull request: GoogleCloudPlatform#826
will add new pull request
@yogeshg

yogeshg commented Mar 2, 2017

Copy link
Copy Markdown
Author

@jonparrott and @gguuss,
I was working on another file that I do not wish to merge, and I also renamed this file.
Please let me know if the updated version is fine or if I should raise another request with just one relevant commit.

@theacodes theacodes closed this Apr 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants