| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent facb62d commit 2e9f486
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,23 +15,22 @@ | |||
| 15 | 15 | """GAX/GAPIC module for managing Speech API requests.""" | |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | - from google.cloud._helpers import make_secure_stub | ||
| 19 | - from google.cloud.connection import DEFAULT_USER_AGENT | ||
| 20 | - | ||
| 21 | - from google.cloud.speech.alternative import Alternative | ||
| 22 | - from google.cloud.speech.operation import Operation | ||
| 23 | - | ||
| 24 | 18 | from google.cloud.gapic.speech.v1beta1.speech_api import SpeechApi | |
| 25 | - from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import SpeechContext | ||
| 26 | - from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import RecognitionConfig | ||
| 27 | 19 | from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import RecognitionAudio | |
| 20 | + from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import RecognitionConfig | ||
| 21 | + from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import SpeechContext | ||
| 28 | 22 | from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import ( | |
| 29 | 23 | StreamingRecognitionConfig) | |
| 30 | 24 | from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import ( | |
| 31 | 25 | StreamingRecognizeRequest) | |
| 32 | - | ||
| 33 | 26 | from google.longrunning import operations_grpc | |
| 34 | 27 | ||
| 28 | + from google.cloud._helpers import make_secure_stub | ||
| 29 | + from google.cloud.connection import DEFAULT_USER_AGENT | ||
| 30 | + | ||
| 31 | + from google.cloud.speech.alternative import Alternative | ||
| 32 | + from google.cloud.speech.operation import Operation | ||
| 33 | + | ||
| 35 | 34 | OPERATIONS_API_HOST = 'speech.googleapis.com' | |
| 36 | 35 | ||
| 37 | 36 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,17 +17,17 @@ | |||
| 17 | 17 | from base64 import b64encode | |
| 18 | 18 | import os | |
| 19 | 19 | ||
| 20 | - from google.cloud._helpers import _to_bytes | ||
| 21 | 20 | from google.cloud._helpers import _bytes_to_unicode | |
| 21 | + from google.cloud._helpers import _to_bytes | ||
| 22 | 22 | from google.cloud.client import Client as BaseClient | |
| 23 | 23 | from google.cloud.environment_vars import DISABLE_GRPC | |
| 24 | 24 | ||
| 25 | 25 | from google.cloud.speech._gax import GAPICSpeechAPI | |
| 26 | + from google.cloud.speech.alternative import Alternative | ||
| 26 | 27 | from google.cloud.speech.connection import Connection | |
| 27 | 28 | from google.cloud.speech.encoding import Encoding | |
| 28 | 29 | from google.cloud.speech.operation import Operation | |
| 29 | 30 | from google.cloud.speech.sample import Sample | |
| 30 | - from google.cloud.speech.alternative import Alternative | ||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | 33 | _USE_GAX = not os.getenv(DISABLE_GRPC, False) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,15 +89,15 @@ def test_create_sample_from_client(self): | |||
| 89 | 89 | ||
| 90 | 90 | def test_sync_recognize_content_with_optional_params_no_gax(self): | |
| 91 | 91 | from base64 import b64encode | |
| 92 | - from google.cloud._helpers import _to_bytes | ||
| 93 | - from google.cloud._helpers import _bytes_to_unicode | ||
| 94 | 92 | ||
| 93 | + from google.cloud._helpers import _bytes_to_unicode | ||
| 94 | + from google.cloud._helpers import _to_bytes | ||
| 95 | 95 | from google.cloud._testing import _Monkey | |
| 96 | - from google.cloud.speech import client as MUT | ||
| 96 | + | ||
| 97 | 97 | from google.cloud import speech | |
| 98 | + from google.cloud.speech import client as MUT | ||
| 98 | 99 | from google.cloud.speech.alternative import Alternative | |
| 99 | 100 | from google.cloud.speech.sample import Sample | |
| 100 | - | ||
| 101 | 101 | from unit_tests._fixtures import SYNC_RECOGNIZE_RESPONSE | |
| 102 | 102 | ||
| 103 | 103 | _AUDIO_CONTENT = _to_bytes(self.AUDIO_CONTENT) | |
@@ -151,8 +151,9 @@ def test_sync_recognize_content_with_optional_params_no_gax(self): | |||
| 151 | 151 | ||
| 152 | 152 | def test_sync_recognize_source_uri_without_optional_params_no_gax(self): | |
| 153 | 153 | from google.cloud._testing import _Monkey | |
| 154 | - from google.cloud.speech import client as MUT | ||
| 154 | + | ||
| 155 | 155 | from google.cloud import speech | |
| 156 | + from google.cloud.speech import client as MUT | ||
| 156 | 157 | from google.cloud.speech.alternative import Alternative | |
| 157 | 158 | from google.cloud.speech.sample import Sample | |
| 158 | 159 | from unit_tests._fixtures import SYNC_RECOGNIZE_RESPONSE | |
@@ -194,8 +195,9 @@ def test_sync_recognize_source_uri_without_optional_params_no_gax(self): | |||
| 194 | 195 | ||
| 195 | 196 | def test_sync_recognize_with_empty_results_no_gax(self): | |
| 196 | 197 | from google.cloud._testing import _Monkey | |
| 197 | - from google.cloud.speech import client as MUT | ||
| 198 | + | ||
| 198 | 199 | from google.cloud import speech | |
| 200 | + from google.cloud.speech import client as MUT | ||
| 199 | 201 | from google.cloud.speech.sample import Sample | |
| 200 | 202 | from unit_tests._fixtures import SYNC_RECOGNIZE_EMPTY_RESPONSE | |
| 201 | 203 | ||
@@ -212,8 +214,9 @@ def test_sync_recognize_with_empty_results_no_gax(self): | |||
| 212 | 214 | ||
| 213 | 215 | def test_sync_recognize_with_empty_results_gax(self): | |
| 214 | 216 | from google.cloud._testing import _Monkey | |
| 215 | - from google.cloud.speech import _gax as MUT | ||
| 217 | + | ||
| 216 | 218 | from google.cloud import speech | |
| 219 | + from google.cloud.speech import _gax as MUT | ||
| 217 | 220 | from google.cloud.speech.sample import Sample | |
| 218 | 221 | ||
| 219 | 222 | credentials = _Credentials() | |
@@ -231,9 +234,10 @@ def test_sync_recognize_with_empty_results_gax(self): | |||
| 231 | 234 | client.sync_recognize(sample) | |
| 232 | 235 | ||
| 233 | 236 | def test_sync_recognize_with_gax(self): | |
| 237 | + from google.cloud._testing import _Monkey | ||
| 238 | + | ||
| 234 | 239 | from google.cloud import speech | |
| 235 | 240 | from google.cloud.speech import _gax as MUT | |
| 236 | - from google.cloud._testing import _Monkey | ||
| 237 | 241 | ||
| 238 | 242 | creds = _Credentials() | |
| 239 | 243 | client = self._makeOne(credentials=creds, use_gax=True) | |
@@ -268,10 +272,10 @@ def test_async_supported_encodings(self): | |||
| 268 | 272 | client.async_recognize(sample) | |
| 269 | 273 | ||
| 270 | 274 | def test_async_recognize_no_gax(self): | |
| 271 | - from unit_tests._fixtures import ASYNC_RECOGNIZE_RESPONSE | ||
| 272 | 275 | from google.cloud import speech | |
| 273 | 276 | from google.cloud.speech.operation import Operation | |
| 274 | 277 | from google.cloud.speech.sample import Sample | |
| 278 | + from unit_tests._fixtures import ASYNC_RECOGNIZE_RESPONSE | ||
| 275 | 279 | ||
| 276 | 280 | RETURNED = ASYNC_RECOGNIZE_RESPONSE | |
| 277 | 281 | ||
@@ -291,9 +295,10 @@ def test_async_recognize_no_gax(self): | |||
| 291 | 295 | self.assertIsNone(operation.metadata) | |
| 292 | 296 | ||
| 293 | 297 | def test_async_recognize_with_gax(self): | |
| 294 | - from google.cloud.speech import _gax as MUT | ||
| 295 | 298 | from google.cloud._testing import _Monkey | |
| 299 | + | ||
| 296 | 300 | from google.cloud import speech | |
| 301 | + from google.cloud.speech import _gax as MUT | ||
| 297 | 302 | from google.cloud.speech.operation import Operation | |
| 298 | 303 | ||
| 299 | 304 | credentials = _Credentials() | |
@@ -312,8 +317,9 @@ def test_async_recognize_with_gax(self): | |||
| 312 | 317 | self.assertIsNone(operation.response) | |
| 313 | 318 | ||
| 314 | 319 | def test_speech_api_with_gax(self): | |
| 315 | - from google.cloud.speech import _gax as MUT | ||
| 316 | 320 | from google.cloud._testing import _Monkey | |
| 321 | + | ||
| 322 | + from google.cloud.speech import _gax as MUT | ||
| 317 | 323 | from google.cloud.speech.client import GAPICSpeechAPI | |
| 318 | 324 | ||
| 319 | 325 | creds = _Credentials() | |
@@ -342,24 +348,6 @@ def test_speech_api_preset(self): | |||
| 342 | 348 | self.assertIs(client.speech_api, fake_api) | |
| 343 | 349 | ||
| 344 | 350 | ||
| 345 | - # class _MockGAPICAlternative(object): | ||
| 346 | - # transcript = 'testing 1 2 3' | ||
| 347 | - # confidence = 0.95234356 | ||
| 348 | - # | ||
| 349 | - # | ||
| 350 | - # class _MockGAPICSyncResult(object): | ||
| 351 | - # alternatives = [_MockGAPICAlternative()] | ||
| 352 | - # | ||
| 353 | - # | ||
| 354 | - # class _MockGAPICSpeechResponse(object): | ||
| 355 | - # error = None | ||
| 356 | - # endpointer_type = None | ||
| 357 | - # name = None | ||
| 358 | - # metadata = _MockGAPICMetadata() | ||
| 359 | - # results = [] | ||
| 360 | - # result_index = 0 | ||
| 361 | - | ||
| 362 | - | ||
| 363 | 351 | class _MockGAPICSpeechAPI(object): | |
| 364 | 352 | _requests = None | |
| 365 | 353 | _response = None | |
| Back | FazBrowse Home | New Git URL |
0 commit comments