Skip to content

Commit 2eee25a

Browse files
committed
Merge master updates in.
1 parent ab5ca64 commit 2eee25a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

speech/google/cloud/speech/_http.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from google.cloud._helpers import _bytes_to_unicode
2020
from google.cloud._helpers import _to_bytes
2121

22-
from google.cloud.speech.alternative import Alternative
22+
from google.cloud.speech.result import Result
2323
from google.cloud.speech.operation import Operation
2424

2525

@@ -140,12 +140,11 @@ def sync_recognize(self, sample, language_code=None, max_alternatives=None,
140140
api_response = self._connection.api_request(
141141
method='POST', path='speech:syncrecognize', data=data)
142142

143-
if len(api_response['results']) == 1:
144-
result = api_response['results'][0]
145-
return [Alternative.from_api_repr(alternative)
146-
for alternative in result['alternatives']]
143+
if len(api_response['results']) > 0:
144+
results = api_response['results']
145+
return [Result.from_api_repr(result) for result in results]
147146
else:
148-
raise ValueError('More than one result or none returned from API.')
147+
raise ValueError('No results were returned from the API')
149148

150149

151150
def _build_request_data(sample, language_code=None, max_alternatives=None,

0 commit comments

Comments
 (0)