Skip to content

Commit 7afb765

Browse files
committed
Move alternatives back up.
1 parent 4060a99 commit 7afb765

File tree

6 files changed

+9
-67
lines changed

6 files changed

+9
-67
lines changed

docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@
177177
speech-encoding
178178
speech-metadata
179179
speech-operation
180-
speech-result
181180
speech-sample
182181
speech-transcript
183182

docs/speech-result.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/speech-usage.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ See: `Speech Asynchronous Recognize`_
7070
>>> operation.complete
7171
True
7272
>>> for result in operation.results:
73-
... for alternative in result.alternatives:
74-
... print('=' * 20)
75-
... print(alternative.transcript)
76-
... print(alternative.confidence)
73+
... print('=' * 20)
74+
... print(result.transcript)
75+
... print(result.confidence)
7776
====================
7877
'how old is the Brooklyn Bridge'
7978
0.98267895

speech/google/cloud/speech/operation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Long running operation representation for Google Speech API"""
1616

1717
from google.cloud.speech.metadata import Metadata
18-
from google.cloud.speech.result import SpeechResult
18+
from google.cloud.speech.transcript import Transcript
1919
from google.cloud import operation
2020

2121

@@ -124,7 +124,8 @@ def _update(self, response):
124124
results = []
125125
if raw_results:
126126
for result in raw_results:
127-
results.append(SpeechResult.from_api_repr(result))
127+
for alternative in result['alternatives']:
128+
results.append(Transcript.from_api_repr(alternative))
128129
if metadata:
129130
self._metadata = Metadata.from_api_repr(metadata)
130131

speech/google/cloud/speech/result.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

speech/unit_tests/test_operation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ def test_from_api_repr(self):
4747
self.assertTrue(operation.complete)
4848

4949
self.assertIsInstance(operation.results, list)
50-
self.assertIsInstance(operation.results[0].alternatives, list)
51-
self.assertIsInstance(operation.results[0].alternatives[0], Transcript)
52-
self.assertEqual(operation.results[0].alternatives[0].transcript,
50+
self.assertIsInstance(operation.results[0], Transcript)
51+
self.assertEqual(operation.results[0].transcript,
5352
'how old is the Brooklyn Bridge')
54-
self.assertEqual(operation.results[0].alternatives[0].confidence,
53+
self.assertEqual(operation.results[0].confidence,
5554
0.98267895)
5655
self.assertTrue(operation.complete)
5756
self.assertIsInstance(operation.metadata, Metadata)

0 commit comments

Comments
 (0)