8000 More verbose access to alternatives. · googleapis/google-cloud-python@5844cad · GitHub
[go: up one dir, main page]

Skip to content

Commit 5844cad

Browse files
committed
More verbose access to alternatives.
1 parent 89ff561 commit 5844cad

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

speech/google/cloud/speech/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,19 +405,19 @@ def _make_request_stream(sample, language_code=None, max_alternatives=None,
405405
will return a maximum of 1. Defaults to 1
406406
407407
:type profanity_filter: bool
408-
:param profanity_filter: If True, the server will attempt to filter
409-
out profanities, replacing all but the
408+
:param profanity_filter: (Optional) If True, the server will attempt to
409+
filter out profanities, replacing all but the
410410
initial character in each filtered word with
411411
asterisks, e.g. ``'f***'``. If False or
412412
omitted, profanities won't be filtered out.
413413
414414
:type speech_context: list
415-
:param speech_context: A list of strings (max 50) containing words and
416-
phrases "hints" so that the speech recognition
417-
is more likely to recognize them. This can be
418-
used to improve the accuracy for specific words
419-
and phrases. This can also be used to add new
420-
words to the vocabulary of the recognizer.
415+
:param speech_context: (Optional) A list of strings (max 50) containing
416+
words and phrases "hints" so that the speech
417+
recognition is more likely to recognize them.
418+
This can be used to improve the accuracy for
419+
specific words and phrases. This can also be used to
420+
add new words to the vocabulary of the recognizer.
421421
422422
:type single_utterance: bool
423423
:param single_utterance: (Optional) If false or omitted, the recognizer

speech/google/cloud/speech/streaming_response.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def confidence(self):
7171
:returns: Confidence score of recognized speech [0.0-1.0].
7272
"""
7373
if self.results and self.results[0].alternatives:
74-
return self.results[0].alternatives[0].confidence
74+
top_alternative = self.results[0].alternatives[0]
75+
return top_alternative.confidence
7576
else:
7677
return 0.0
7778

@@ -122,7 +123,8 @@ def transcript(self):
122123
:returns: Transcript text from response.
123124
"""
124125
if self.results and self.results[0].alternatives:
125-
return self.results[0].alternatives[0].transcript
126+
top_alternative = self.results[0].alternatives[0]
127+
return top_alternative.transcript
126128
else:
127129
return None
128130

0 commit comments

Comments
 (0)
0