-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Minute workaround #834
Conversation
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.
No tests?
@@ -0,0 +1,294 @@ | |||
#!/usr/bin/python | |||
# Copyright (C) 2016 Google Inc. |
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.
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) |
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.
You don't need to use the port anymore.
credentials, http_request, target) | ||
|
||
|
||
def _audio_data_generator(buff, overlap_buffer): |
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.
why not just use buffer
instead of buff
?
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 feel like we've had this conversation before :) buffer
turns out to be a reserved word.
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.
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. |
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.
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.""" |
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.
nit: unneeded comma here.
recognize_stream = service.StreamingRecognize( | ||
requests, DEADLINE_SECS) | ||
|
||
except grpc.RpcError, e: |
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.
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', |
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.
Indent too deep?
Oh right - tests. Good idea. Comments addressed - PTAL. |
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 still don't see tests?
@@ -0,0 +1,296 @@ | |||
#!/usr/bin/python | |||
|
|||
# Copyright (C) 2016 Google Inc. |
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.
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. |
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.
nit nit: I wanted a blank newline between the license and this too. :)
249e47f
to
5900d39
Compare
Doh. Forgot to |
Oh wait. travis is unhappy. Bide... |
5900d39
to
4d1755c
Compare
Placated travis. @dpebot would you mind merging if Travis approves? |
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