@@ -234,6 +234,9 @@ def stream_recognize(self, sample, language_code=None,
234234
235235 See: https://cloud.google.com/speech/limits#content
236236
237+ Yields :class:`~streaming_response.StreamingSpeechResponse` containing
238+ results and metadata from the streaming request.
239+
237240 :type sample: :class:`~google.cloud.speech.sample.Sample`
238241 :param sample: Instance of ``Sample`` containing audio information.
239242
@@ -264,8 +267,8 @@ def stream_recognize(self, sample, language_code=None,
264267 and phrases. This can also be used to add new
265268 words to the vocabulary of the recognizer.
266269
267- :type single_utterance: boolean
268- :param single_utterance: [ Optional] If false or omitted, the recognizer
270+ :type single_utterance: bool
271+ :param single_utterance: ( Optional) If false or omitted, the recognizer
269272 will perform continuous recognition
270273 (continuing to process audio even if the user
271274 pauses speaking) until the client closes the
@@ -282,13 +285,15 @@ def stream_recognize(self, sample, language_code=None,
282285 SpeechRecognitionResult with the is_final flag
283286 set to true.
284287
285- :type interim_results: boolean
286- :param interim_results: [ Optional] If true, interim results (tentative
288+ :type interim_results: bool
289+ :param interim_results: ( Optional) If true, interim results (tentative
287290 hypotheses) may be returned as they become
288291 available (these interim results are indicated
289292 with the is_final=false flag). If false or
290293 omitted, only is_final=true result(s) are
291294 returned.
295+
296+ :raises: :class:`EnvironmentError` if gRPC is not enabled.
292297 """
293298 if not _USE_GAX :
294299 raise EnvironmentError ('gRPC is required to use this API.' )
@@ -301,7 +306,7 @@ def stream_recognize(self, sample, language_code=None,
301306 interim_results = interim_results )
302307
303308 for response in self .speech_api .streaming_recognize (requests ):
304- if hasattr (response , 'results' ) or interim_results :
309+ if getattr (response , 'results' , None ) or interim_results :
305310 yield StreamingSpeechResponse .from_pb (response )
306311
307312 @property
@@ -414,8 +419,8 @@ def _make_request_stream(sample, language_code=None, max_alternatives=None,
414419 and phrases. This can also be used to add new
415420 words to the vocabulary of the recognizer.
416421
417- :type single_utterance: boolean
418- :param single_utterance: [ Optional] If false or omitted, the recognizer
422+ :type single_utterance: bool
423+ :param single_utterance: ( Optional) If false or omitted, the recognizer
419424 will perform continuous recognition
420425 (continuing to process audio even if the user
421426 pauses speaking) until the client closes the
@@ -432,8 +437,8 @@ def _make_request_stream(sample, language_code=None, max_alternatives=None,
432437 SpeechRecognitionResult with the is_final flag
433438 set to true.
434439
435- :type interim_results: boolean
436- :param interim_results: [ Optional] If true, interim results (tentative
440+ :type interim_results: bool
441+ :param interim_results: ( Optional) If true, interim results (tentative
437442 hypotheses) may be returned as they become
438443 available (these interim results are indicated
439444 with the is_final=false flag). If false or
@@ -452,7 +457,6 @@ def _make_request_stream(sample, language_code=None, max_alternatives=None,
452457 data = sample .stream .read (sample .chunk_size )
453458 if not data :
454459 break
455- # Optimize the request data size to around 100ms.
456460 yield StreamingRecognizeRequest (audio_content = data )
457461
458462
@@ -466,12 +470,12 @@ def _make_streaming_config(sample, language_code,
466470 :param sample: Instance of ``Sample`` containing audio information.
467471
468472 :type language_code: str
469- :param language_code: (Optional) The language of the supplied audio as
473+ :param language_code: The language of the supplied audio as
470474 BCP-47 language tag. Example: ``'en-GB'``.
471475 If omitted, defaults to ``'en-US'``.
472476
473477 :type max_alternatives: int
474- :param max_alternatives: (Optional) Maximum number of recognition
478+ :param max_alternatives: Maximum number of recognition
475479 hypotheses to be returned. The server may
476480 return fewer than maxAlternatives.
477481 Valid values are 0-30. A value of 0 or 1
@@ -492,8 +496,8 @@ def _make_streaming_config(sample, language_code,
492496 and phrases. This can also be used to add new
493497 words to the vocabulary of the recognizer.
494498
495- :type single_utterance: boolean
496- :param single_utterance: [Optional] If false or omitted, the recognizer
499+ :type single_utterance: bool
500+ :param single_utterance: If false or omitted, the recognizer
497501 will perform continuous recognition
498502 (continuing to process audio even if the user
499503 pauses speaking) until the client closes the
@@ -510,8 +514,8 @@ def _make_streaming_config(sample, language_code,
510514 SpeechRecognitionResult with the is_final flag
511515 set to true.
512516
513- :type interim_results: boolean
514- :param interim_results: [Optional] If true, interim results (tentative
517+ :type interim_results: bool
518+ :param interim_results: If true, interim results (tentative
515519 hypotheses) may be returned as they become
516520 available (these interim results are indicated
517521 with the is_final=false flag). If false or
0 commit comments