Skip to content

Minute workaround #834

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

Merged
merged 9 commits into from
Mar 2, 2017
Merged

Minute workaround #834

merged 9 commits into from
Mar 2, 2017

Conversation

jerjou
Copy link
Contributor

@jerjou jerjou commented Feb 28, 2017

A sample for reopening a streaming connection to the speech api, to get around the 1-minute time limit for streaming speech requests.

Addresses #517

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 28, 2017
Copy link
Contributor

@theacodes theacodes left a comment

Choose a reason for hiding this comment

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

No tests?

@@ -0,0 +1,294 @@
#!/usr/bin/python
# Copyright (C) 2016 Google Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: blank new lines between shebang and license and license and docstring.


# Create a secure channel using the credentials.
http_request = google.auth.transport.requests.Request()
target = '{}:{}'.format(host, port)
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to use the port anymore.

credentials, http_request, target)


def _audio_data_generator(buff, overlap_buffer):
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just use buffer instead of buff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like we've had this conversation before :) buffer turns out to be a reserved word.

https://docs.python.org/2/library/functions.html#buffer

Copy link
Contributor

Choose a reason for hiding this comment

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

oh my god we totally have. Thanks.

"""A generator that yields all available data in the given buffer.

Args:
buff - a Queue object, where each element is a chunk of data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Napoleon style is:

Args:
    buff (Queue): ...
    overlap_buffer (type): ...

Yields:
    bytes: A chunk of data ...



def _fill_buffer(buff, in_data, frame_count, time_info, status_flags):
"""Continuously collect data from the audio stream, into the buffer."""
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: unneeded comma here.

recognize_stream = service.StreamingRecognize(
requests, DEADLINE_SECS)

except grpc.RpcError, e:
Copy link
Contributor

Choose a reason for hiding this comment

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

as e, but if you're not going to use it just do except grpc.RpcError:

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'-v', '--verbose', help='increase output verbosity',
Copy link
Contributor

Choose a reason for hiding this comment

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

Indent too deep?

@jerjou
Copy link
Contributor Author

jerjou commented Mar 1, 2017

Oh right - tests. Good idea.

Comments addressed - PTAL.

Copy link
Contributor

@theacodes theacodes left a comment

Choose a reason for hiding this comment

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

I still don't see tests?

@@ -0,0 +1,296 @@
#!/usr/bin/python

# Copyright (C) 2016 Google Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

2017

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Sample that streams audio to the Google Cloud Speech API via GRPC.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit nit: I wanted a blank newline between the license and this too. :)

@jerjou jerjou force-pushed the minute_workaround branch 3 times, most recently from 249e47f to 5900d39 Compare March 1, 2017 05:00
@jerjou
Copy link
Contributor Author

jerjou commented Mar 1, 2017

Doh. Forgot to git add -_-
Updated.

@jerjou
Copy link
Contributor Author

jerjou commented Mar 1, 2017

Oh wait. travis is unhappy. Bide...

@jerjou jerjou force-pushed the minute_workaround branch from 5900d39 to 4d1755c Compare March 1, 2017 18:42
@jerjou
Copy link
Contributor Author

jerjou commented Mar 1, 2017

Placated travis. @dpebot would you mind merging if Travis approves?

@jerjou jerjou added the automerge Merge the pull request once unit tests and other checks pass. label Mar 1, 2017
@dpebot dpebot merged commit 776cef0 into master Mar 2, 2017
@dpebot dpebot deleted the minute_workaround branch March 2, 2017 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge the pull request once unit tests and other checks pass. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants