Skip to content

Commit

Permalink
More verbose access to alternatives.
Browse files Browse the repository at this point in the history
  • Loading branch information
daspecster committed Oct 19, 2016
1 parent 0a04d5f commit f6ff654
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 8 additions & 8 deletions speech/google/cloud/speech/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,19 +405,19 @@ def _make_request_stream(sample, language_code=None, max_alternatives=None,
will return a maximum of 1. Defaults to 1
:type profanity_filter: bool
:param profanity_filter: If True, the server will attempt to filter
out profanities, replacing all but the
:param profanity_filter: (Optional) If True, the server will attempt to
filter out profanities, replacing all but the
initial character in each filtered word with
asterisks, e.g. ``'f***'``. If False or
omitted, profanities won't be filtered out.
:type speech_context: list
:param speech_context: A list of strings (max 50) containing words and
phrases "hints" so that the speech recognition
is more likely to recognize them. This can be
used to improve the accuracy for specific words
and phrases. This can also be used to add new
words to the vocabulary of the recognizer.
:param speech_context: (Optional) A list of strings (max 50) containing
words and phrases "hints" so that the speech
recognition is more likely to recognize them.
This can be used to improve the accuracy for
specific words and phrases. This can also be used to
add new words to the vocabulary of the recognizer.
:type single_utterance: bool
:param single_utterance: (Optional) If false or omitted, the recognizer
Expand Down
6 changes: 4 additions & 2 deletions speech/google/cloud/speech/streaming_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def confidence(self):
:returns: Confidence score of recognized speech [0.0-1.0].
"""
if self.results and self.results[0].alternatives:
return self.results[0].alternatives[0].confidence
top_alternative = self.results[0].alternatives[0]
return top_alternative.confidence
else:
return 0.0

Expand Down Expand Up @@ -122,7 +123,8 @@ def transcript(self):
:returns: Transcript text from response.
"""
if self.results and self.results[0].alternatives:
return self.results[0].alternatives[0].transcript
top_alternative = self.results[0].alternatives[0]
return top_alternative.transcript
else:
return None

Expand Down

0 comments on commit f6ff654

Please sign in to comment.