Add loan-advisor-agent (part 7)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/__init__.py +36 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/base.py +340 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/grpc.py +649 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/grpc_asyncio.py +739 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/rest.py +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/rest_base.py +653 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/__init__.py +22 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/async_client.py +860 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/client.py +1324 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/__init__.py +36 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/base.py +265 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/grpc.py +479 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/grpc_asyncio.py +546 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/rest.py +1023 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/rest_base.py +260 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/types/__init__.py +94 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/types/cloud_speech.py +1560 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/types/cloud_speech_adaptation.py +422 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/types/resource.py +282 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/__init__.py +223 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/gapic_metadata.json +242 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/gapic_version.py +16 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/py.typed +2 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/__init__.py +15 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/__init__.py +22 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py +1749 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/client.py +2234 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/pagers.py +359 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/__init__.py +36 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/base.py +340 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py +649 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py +739 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/rest.py +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/rest_base.py +653 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/__init__.py +22 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/async_client.py +866 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/client.py +1374 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/__init__.py +36 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/base.py +265 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py +479 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py +546 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/rest.py +1023 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/rest_base.py +260 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/types/__init__.py +94 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/types/cloud_speech.py +1609 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/types/cloud_speech_adaptation.py +422 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/types/resource.py +497 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v2/__init__.py +277 -0
- loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v2/gapic_metadata.json +373 -0
.gitattributes
CHANGED
|
@@ -424,3 +424,7 @@ loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/servi
|
|
| 424 |
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/types/__pycache__/evaluation_service.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 425 |
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/resourcemanager_v3/services/folders/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 426 |
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/resourcemanager_v3/services/projects/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/aiplatform_v1beta1/types/__pycache__/evaluation_service.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 425 |
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/resourcemanager_v3/services/folders/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 426 |
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/resourcemanager_v3/services/projects/transports/__pycache__/rest.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 427 |
+
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/storage/__pycache__/blob.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 428 |
+
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/storage/__pycache__/bucket.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 429 |
+
loan-advisor-agent/.venv/Lib/site-packages/google/genai/__pycache__/models.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 430 |
+
loan-advisor-agent/.venv/Lib/site-packages/google/genai/__pycache__/types.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from collections import OrderedDict
|
| 17 |
+
from typing import Dict, Type
|
| 18 |
+
|
| 19 |
+
from .base import AdaptationTransport
|
| 20 |
+
from .grpc import AdaptationGrpcTransport
|
| 21 |
+
from .grpc_asyncio import AdaptationGrpcAsyncIOTransport
|
| 22 |
+
from .rest import AdaptationRestInterceptor, AdaptationRestTransport
|
| 23 |
+
|
| 24 |
+
# Compile a registry of transports.
|
| 25 |
+
_transport_registry = OrderedDict() # type: Dict[str, Type[AdaptationTransport]]
|
| 26 |
+
_transport_registry["grpc"] = AdaptationGrpcTransport
|
| 27 |
+
_transport_registry["grpc_asyncio"] = AdaptationGrpcAsyncIOTransport
|
| 28 |
+
_transport_registry["rest"] = AdaptationRestTransport
|
| 29 |
+
|
| 30 |
+
__all__ = (
|
| 31 |
+
"AdaptationTransport",
|
| 32 |
+
"AdaptationGrpcTransport",
|
| 33 |
+
"AdaptationGrpcAsyncIOTransport",
|
| 34 |
+
"AdaptationRestTransport",
|
| 35 |
+
"AdaptationRestInterceptor",
|
| 36 |
+
)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/base.py
ADDED
|
@@ -0,0 +1,340 @@
|
|
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|
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import abc
|
| 17 |
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
|
| 18 |
+
|
| 19 |
+
import google.api_core
|
| 20 |
+
import google.auth # type: ignore
|
| 21 |
+
import google.protobuf
|
| 22 |
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
| 23 |
+
from google.api_core import exceptions as core_exceptions
|
| 24 |
+
from google.api_core import gapic_v1
|
| 25 |
+
from google.api_core import retry as retries
|
| 26 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 27 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 28 |
+
from google.oauth2 import service_account # type: ignore
|
| 29 |
+
|
| 30 |
+
from google.cloud.speech_v1 import gapic_version as package_version
|
| 31 |
+
from google.cloud.speech_v1.types import cloud_speech_adaptation, resource
|
| 32 |
+
|
| 33 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 34 |
+
gapic_version=package_version.__version__
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 38 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class AdaptationTransport(abc.ABC):
|
| 42 |
+
"""Abstract transport class for Adaptation."""
|
| 43 |
+
|
| 44 |
+
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
|
| 45 |
+
|
| 46 |
+
DEFAULT_HOST: str = "speech.googleapis.com"
|
| 47 |
+
|
| 48 |
+
def __init__(
|
| 49 |
+
self,
|
| 50 |
+
*,
|
| 51 |
+
host: str = DEFAULT_HOST,
|
| 52 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 53 |
+
credentials_file: Optional[str] = None,
|
| 54 |
+
scopes: Optional[Sequence[str]] = None,
|
| 55 |
+
quota_project_id: Optional[str] = None,
|
| 56 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 57 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 58 |
+
api_audience: Optional[str] = None,
|
| 59 |
+
**kwargs,
|
| 60 |
+
) -> None:
|
| 61 |
+
"""Instantiate the transport.
|
| 62 |
+
|
| 63 |
+
Args:
|
| 64 |
+
host (Optional[str]):
|
| 65 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 66 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 67 |
+
authorization credentials to attach to requests. These
|
| 68 |
+
credentials identify the application to the service; if none
|
| 69 |
+
are specified, the client will attempt to ascertain the
|
| 70 |
+
credentials from the environment.
|
| 71 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 72 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 73 |
+
This argument is mutually exclusive with credentials. This argument will be
|
| 74 |
+
removed in the next major version of this library.
|
| 75 |
+
scopes (Optional[Sequence[str]]): A list of scopes.
|
| 76 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 77 |
+
and quota.
|
| 78 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 79 |
+
The client info used to send a user-agent string along with
|
| 80 |
+
API requests. If ``None``, then default info will be used.
|
| 81 |
+
Generally, you only need to set this if you're developing
|
| 82 |
+
your own client library.
|
| 83 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 84 |
+
be used for service account credentials.
|
| 85 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 86 |
+
to the service that will be set when using certain 3rd party
|
| 87 |
+
authentication flows. Audience is typically a resource identifier.
|
| 88 |
+
If not set, the host value will be used as a default.
|
| 89 |
+
"""
|
| 90 |
+
|
| 91 |
+
# Save the scopes.
|
| 92 |
+
self._scopes = scopes
|
| 93 |
+
if not hasattr(self, "_ignore_credentials"):
|
| 94 |
+
self._ignore_credentials: bool = False
|
| 95 |
+
|
| 96 |
+
# If no credentials are provided, then determine the appropriate
|
| 97 |
+
# defaults.
|
| 98 |
+
if credentials and credentials_file:
|
| 99 |
+
raise core_exceptions.DuplicateCredentialArgs(
|
| 100 |
+
"'credentials_file' and 'credentials' are mutually exclusive"
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
if credentials_file is not None:
|
| 104 |
+
credentials, _ = google.auth.load_credentials_from_file(
|
| 105 |
+
credentials_file,
|
| 106 |
+
scopes=scopes,
|
| 107 |
+
quota_project_id=quota_project_id,
|
| 108 |
+
default_scopes=self.AUTH_SCOPES,
|
| 109 |
+
)
|
| 110 |
+
elif credentials is None and not self._ignore_credentials:
|
| 111 |
+
credentials, _ = google.auth.default(
|
| 112 |
+
scopes=scopes,
|
| 113 |
+
quota_project_id=quota_project_id,
|
| 114 |
+
default_scopes=self.AUTH_SCOPES,
|
| 115 |
+
)
|
| 116 |
+
# Don't apply audience if the credentials file passed from user.
|
| 117 |
+
if hasattr(credentials, "with_gdch_audience"):
|
| 118 |
+
credentials = credentials.with_gdch_audience(
|
| 119 |
+
api_audience if api_audience else host
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
# If the credentials are service account credentials, then always try to use self signed JWT.
|
| 123 |
+
if (
|
| 124 |
+
always_use_jwt_access
|
| 125 |
+
and isinstance(credentials, service_account.Credentials)
|
| 126 |
+
and hasattr(service_account.Credentials, "with_always_use_jwt_access")
|
| 127 |
+
):
|
| 128 |
+
credentials = credentials.with_always_use_jwt_access(True)
|
| 129 |
+
|
| 130 |
+
# Save the credentials.
|
| 131 |
+
self._credentials = credentials
|
| 132 |
+
|
| 133 |
+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
|
| 134 |
+
if ":" not in host:
|
| 135 |
+
host += ":443"
|
| 136 |
+
self._host = host
|
| 137 |
+
|
| 138 |
+
self._wrapped_methods: Dict[Callable, Callable] = {}
|
| 139 |
+
|
| 140 |
+
@property
|
| 141 |
+
def host(self):
|
| 142 |
+
return self._host
|
| 143 |
+
|
| 144 |
+
def _prep_wrapped_messages(self, client_info):
|
| 145 |
+
# Precompute the wrapped methods.
|
| 146 |
+
self._wrapped_methods = {
|
| 147 |
+
self.create_phrase_set: gapic_v1.method.wrap_method(
|
| 148 |
+
self.create_phrase_set,
|
| 149 |
+
default_timeout=None,
|
| 150 |
+
client_info=client_info,
|
| 151 |
+
),
|
| 152 |
+
self.get_phrase_set: gapic_v1.method.wrap_method(
|
| 153 |
+
self.get_phrase_set,
|
| 154 |
+
default_timeout=None,
|
| 155 |
+
client_info=client_info,
|
| 156 |
+
),
|
| 157 |
+
self.list_phrase_set: gapic_v1.method.wrap_method(
|
| 158 |
+
self.list_phrase_set,
|
| 159 |
+
default_timeout=None,
|
| 160 |
+
client_info=client_info,
|
| 161 |
+
),
|
| 162 |
+
self.update_phrase_set: gapic_v1.method.wrap_method(
|
| 163 |
+
self.update_phrase_set,
|
| 164 |
+
default_timeout=None,
|
| 165 |
+
client_info=client_info,
|
| 166 |
+
),
|
| 167 |
+
self.delete_phrase_set: gapic_v1.method.wrap_method(
|
| 168 |
+
self.delete_phrase_set,
|
| 169 |
+
default_timeout=None,
|
| 170 |
+
client_info=client_info,
|
| 171 |
+
),
|
| 172 |
+
self.create_custom_class: gapic_v1.method.wrap_method(
|
| 173 |
+
self.create_custom_class,
|
| 174 |
+
default_timeout=None,
|
| 175 |
+
client_info=client_info,
|
| 176 |
+
),
|
| 177 |
+
self.get_custom_class: gapic_v1.method.wrap_method(
|
| 178 |
+
self.get_custom_class,
|
| 179 |
+
default_timeout=None,
|
| 180 |
+
client_info=client_info,
|
| 181 |
+
),
|
| 182 |
+
self.list_custom_classes: gapic_v1.method.wrap_method(
|
| 183 |
+
self.list_custom_classes,
|
| 184 |
+
default_timeout=None,
|
| 185 |
+
client_info=client_info,
|
| 186 |
+
),
|
| 187 |
+
self.update_custom_class: gapic_v1.method.wrap_method(
|
| 188 |
+
self.update_custom_class,
|
| 189 |
+
default_timeout=None,
|
| 190 |
+
client_info=client_info,
|
| 191 |
+
),
|
| 192 |
+
self.delete_custom_class: gapic_v1.method.wrap_method(
|
| 193 |
+
self.delete_custom_class,
|
| 194 |
+
default_timeout=None,
|
| 195 |
+
client_info=client_info,
|
| 196 |
+
),
|
| 197 |
+
self.get_operation: gapic_v1.method.wrap_method(
|
| 198 |
+
self.get_operation,
|
| 199 |
+
default_timeout=None,
|
| 200 |
+
client_info=client_info,
|
| 201 |
+
),
|
| 202 |
+
self.list_operations: gapic_v1.method.wrap_method(
|
| 203 |
+
self.list_operations,
|
| 204 |
+
default_timeout=None,
|
| 205 |
+
client_info=client_info,
|
| 206 |
+
),
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
def close(self):
|
| 210 |
+
"""Closes resources associated with the transport.
|
| 211 |
+
|
| 212 |
+
.. warning::
|
| 213 |
+
Only call this method if the transport is NOT shared
|
| 214 |
+
with other clients - this may cause errors in other clients!
|
| 215 |
+
"""
|
| 216 |
+
raise NotImplementedError()
|
| 217 |
+
|
| 218 |
+
@property
|
| 219 |
+
def create_phrase_set(
|
| 220 |
+
self,
|
| 221 |
+
) -> Callable[
|
| 222 |
+
[cloud_speech_adaptation.CreatePhraseSetRequest],
|
| 223 |
+
Union[resource.PhraseSet, Awaitable[resource.PhraseSet]],
|
| 224 |
+
]:
|
| 225 |
+
raise NotImplementedError()
|
| 226 |
+
|
| 227 |
+
@property
|
| 228 |
+
def get_phrase_set(
|
| 229 |
+
self,
|
| 230 |
+
) -> Callable[
|
| 231 |
+
[cloud_speech_adaptation.GetPhraseSetRequest],
|
| 232 |
+
Union[resource.PhraseSet, Awaitable[resource.PhraseSet]],
|
| 233 |
+
]:
|
| 234 |
+
raise NotImplementedError()
|
| 235 |
+
|
| 236 |
+
@property
|
| 237 |
+
def list_phrase_set(
|
| 238 |
+
self,
|
| 239 |
+
) -> Callable[
|
| 240 |
+
[cloud_speech_adaptation.ListPhraseSetRequest],
|
| 241 |
+
Union[
|
| 242 |
+
cloud_speech_adaptation.ListPhraseSetResponse,
|
| 243 |
+
Awaitable[cloud_speech_adaptation.ListPhraseSetResponse],
|
| 244 |
+
],
|
| 245 |
+
]:
|
| 246 |
+
raise NotImplementedError()
|
| 247 |
+
|
| 248 |
+
@property
|
| 249 |
+
def update_phrase_set(
|
| 250 |
+
self,
|
| 251 |
+
) -> Callable[
|
| 252 |
+
[cloud_speech_adaptation.UpdatePhraseSetRequest],
|
| 253 |
+
Union[resource.PhraseSet, Awaitable[resource.PhraseSet]],
|
| 254 |
+
]:
|
| 255 |
+
raise NotImplementedError()
|
| 256 |
+
|
| 257 |
+
@property
|
| 258 |
+
def delete_phrase_set(
|
| 259 |
+
self,
|
| 260 |
+
) -> Callable[
|
| 261 |
+
[cloud_speech_adaptation.DeletePhraseSetRequest],
|
| 262 |
+
Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]],
|
| 263 |
+
]:
|
| 264 |
+
raise NotImplementedError()
|
| 265 |
+
|
| 266 |
+
@property
|
| 267 |
+
def create_custom_class(
|
| 268 |
+
self,
|
| 269 |
+
) -> Callable[
|
| 270 |
+
[cloud_speech_adaptation.CreateCustomClassRequest],
|
| 271 |
+
Union[resource.CustomClass, Awaitable[resource.CustomClass]],
|
| 272 |
+
]:
|
| 273 |
+
raise NotImplementedError()
|
| 274 |
+
|
| 275 |
+
@property
|
| 276 |
+
def get_custom_class(
|
| 277 |
+
self,
|
| 278 |
+
) -> Callable[
|
| 279 |
+
[cloud_speech_adaptation.GetCustomClassRequest],
|
| 280 |
+
Union[resource.CustomClass, Awaitable[resource.CustomClass]],
|
| 281 |
+
]:
|
| 282 |
+
raise NotImplementedError()
|
| 283 |
+
|
| 284 |
+
@property
|
| 285 |
+
def list_custom_classes(
|
| 286 |
+
self,
|
| 287 |
+
) -> Callable[
|
| 288 |
+
[cloud_speech_adaptation.ListCustomClassesRequest],
|
| 289 |
+
Union[
|
| 290 |
+
cloud_speech_adaptation.ListCustomClassesResponse,
|
| 291 |
+
Awaitable[cloud_speech_adaptation.ListCustomClassesResponse],
|
| 292 |
+
],
|
| 293 |
+
]:
|
| 294 |
+
raise NotImplementedError()
|
| 295 |
+
|
| 296 |
+
@property
|
| 297 |
+
def update_custom_class(
|
| 298 |
+
self,
|
| 299 |
+
) -> Callable[
|
| 300 |
+
[cloud_speech_adaptation.UpdateCustomClassRequest],
|
| 301 |
+
Union[resource.CustomClass, Awaitable[resource.CustomClass]],
|
| 302 |
+
]:
|
| 303 |
+
raise NotImplementedError()
|
| 304 |
+
|
| 305 |
+
@property
|
| 306 |
+
def delete_custom_class(
|
| 307 |
+
self,
|
| 308 |
+
) -> Callable[
|
| 309 |
+
[cloud_speech_adaptation.DeleteCustomClassRequest],
|
| 310 |
+
Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]],
|
| 311 |
+
]:
|
| 312 |
+
raise NotImplementedError()
|
| 313 |
+
|
| 314 |
+
@property
|
| 315 |
+
def list_operations(
|
| 316 |
+
self,
|
| 317 |
+
) -> Callable[
|
| 318 |
+
[operations_pb2.ListOperationsRequest],
|
| 319 |
+
Union[
|
| 320 |
+
operations_pb2.ListOperationsResponse,
|
| 321 |
+
Awaitable[operations_pb2.ListOperationsResponse],
|
| 322 |
+
],
|
| 323 |
+
]:
|
| 324 |
+
raise NotImplementedError()
|
| 325 |
+
|
| 326 |
+
@property
|
| 327 |
+
def get_operation(
|
| 328 |
+
self,
|
| 329 |
+
) -> Callable[
|
| 330 |
+
[operations_pb2.GetOperationRequest],
|
| 331 |
+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
|
| 332 |
+
]:
|
| 333 |
+
raise NotImplementedError()
|
| 334 |
+
|
| 335 |
+
@property
|
| 336 |
+
def kind(self) -> str:
|
| 337 |
+
raise NotImplementedError()
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
__all__ = ("AdaptationTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/grpc.py
ADDED
|
@@ -0,0 +1,649 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json
|
| 17 |
+
import logging as std_logging
|
| 18 |
+
import pickle
|
| 19 |
+
import warnings
|
| 20 |
+
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
|
| 21 |
+
|
| 22 |
+
import google.auth # type: ignore
|
| 23 |
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
| 24 |
+
import google.protobuf.message
|
| 25 |
+
import grpc # type: ignore
|
| 26 |
+
import proto # type: ignore
|
| 27 |
+
from google.api_core import gapic_v1, grpc_helpers
|
| 28 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 29 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 30 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 31 |
+
from google.protobuf.json_format import MessageToJson
|
| 32 |
+
|
| 33 |
+
from google.cloud.speech_v1.types import cloud_speech_adaptation, resource
|
| 34 |
+
|
| 35 |
+
from .base import DEFAULT_CLIENT_INFO, AdaptationTransport
|
| 36 |
+
|
| 37 |
+
try:
|
| 38 |
+
from google.api_core import client_logging # type: ignore
|
| 39 |
+
|
| 40 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 41 |
+
except ImportError: # pragma: NO COVER
|
| 42 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 43 |
+
|
| 44 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
|
| 48 |
+
def intercept_unary_unary(self, continuation, client_call_details, request):
|
| 49 |
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 50 |
+
std_logging.DEBUG
|
| 51 |
+
)
|
| 52 |
+
if logging_enabled: # pragma: NO COVER
|
| 53 |
+
request_metadata = client_call_details.metadata
|
| 54 |
+
if isinstance(request, proto.Message):
|
| 55 |
+
request_payload = type(request).to_json(request)
|
| 56 |
+
elif isinstance(request, google.protobuf.message.Message):
|
| 57 |
+
request_payload = MessageToJson(request)
|
| 58 |
+
else:
|
| 59 |
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
|
| 60 |
+
|
| 61 |
+
request_metadata = {
|
| 62 |
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
| 63 |
+
for key, value in request_metadata
|
| 64 |
+
}
|
| 65 |
+
grpc_request = {
|
| 66 |
+
"payload": request_payload,
|
| 67 |
+
"requestMethod": "grpc",
|
| 68 |
+
"metadata": dict(request_metadata),
|
| 69 |
+
}
|
| 70 |
+
_LOGGER.debug(
|
| 71 |
+
f"Sending request for {client_call_details.method}",
|
| 72 |
+
extra={
|
| 73 |
+
"serviceName": "google.cloud.speech.v1.Adaptation",
|
| 74 |
+
"rpcName": str(client_call_details.method),
|
| 75 |
+
"request": grpc_request,
|
| 76 |
+
"metadata": grpc_request["metadata"],
|
| 77 |
+
},
|
| 78 |
+
)
|
| 79 |
+
response = continuation(client_call_details, request)
|
| 80 |
+
if logging_enabled: # pragma: NO COVER
|
| 81 |
+
response_metadata = response.trailing_metadata()
|
| 82 |
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
| 83 |
+
metadata = (
|
| 84 |
+
dict([(k, str(v)) for k, v in response_metadata])
|
| 85 |
+
if response_metadata
|
| 86 |
+
else None
|
| 87 |
+
)
|
| 88 |
+
result = response.result()
|
| 89 |
+
if isinstance(result, proto.Message):
|
| 90 |
+
response_payload = type(result).to_json(result)
|
| 91 |
+
elif isinstance(result, google.protobuf.message.Message):
|
| 92 |
+
response_payload = MessageToJson(result)
|
| 93 |
+
else:
|
| 94 |
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
|
| 95 |
+
grpc_response = {
|
| 96 |
+
"payload": response_payload,
|
| 97 |
+
"metadata": metadata,
|
| 98 |
+
"status": "OK",
|
| 99 |
+
}
|
| 100 |
+
_LOGGER.debug(
|
| 101 |
+
f"Received response for {client_call_details.method}.",
|
| 102 |
+
extra={
|
| 103 |
+
"serviceName": "google.cloud.speech.v1.Adaptation",
|
| 104 |
+
"rpcName": client_call_details.method,
|
| 105 |
+
"response": grpc_response,
|
| 106 |
+
"metadata": grpc_response["metadata"],
|
| 107 |
+
},
|
| 108 |
+
)
|
| 109 |
+
return response
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class AdaptationGrpcTransport(AdaptationTransport):
|
| 113 |
+
"""gRPC backend transport for Adaptation.
|
| 114 |
+
|
| 115 |
+
Service that implements Google Cloud Speech Adaptation API.
|
| 116 |
+
|
| 117 |
+
This class defines the same methods as the primary client, so the
|
| 118 |
+
primary client can load the underlying transport implementation
|
| 119 |
+
and call it.
|
| 120 |
+
|
| 121 |
+
It sends protocol buffers over the wire using gRPC (which is built on
|
| 122 |
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
| 123 |
+
"""
|
| 124 |
+
|
| 125 |
+
_stubs: Dict[str, Callable]
|
| 126 |
+
|
| 127 |
+
def __init__(
|
| 128 |
+
self,
|
| 129 |
+
*,
|
| 130 |
+
host: str = "speech.googleapis.com",
|
| 131 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 132 |
+
credentials_file: Optional[str] = None,
|
| 133 |
+
scopes: Optional[Sequence[str]] = None,
|
| 134 |
+
channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
|
| 135 |
+
api_mtls_endpoint: Optional[str] = None,
|
| 136 |
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 137 |
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
| 138 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 139 |
+
quota_project_id: Optional[str] = None,
|
| 140 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 141 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 142 |
+
api_audience: Optional[str] = None,
|
| 143 |
+
) -> None:
|
| 144 |
+
"""Instantiate the transport.
|
| 145 |
+
|
| 146 |
+
Args:
|
| 147 |
+
host (Optional[str]):
|
| 148 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 149 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 150 |
+
authorization credentials to attach to requests. These
|
| 151 |
+
credentials identify the application to the service; if none
|
| 152 |
+
are specified, the client will attempt to ascertain the
|
| 153 |
+
credentials from the environment.
|
| 154 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 155 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 156 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 157 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 158 |
+
This argument will be removed in the next major version of this library.
|
| 159 |
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
| 160 |
+
ignored if a ``channel`` instance is provided.
|
| 161 |
+
channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
|
| 162 |
+
A ``Channel`` instance through which to make calls, or a Callable
|
| 163 |
+
that constructs and returns one. If set to None, ``self.create_channel``
|
| 164 |
+
is used to create the channel. If a Callable is given, it will be called
|
| 165 |
+
with the same arguments as used in ``self.create_channel``.
|
| 166 |
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
| 167 |
+
If provided, it overrides the ``host`` argument and tries to create
|
| 168 |
+
a mutual TLS channel with client SSL credentials from
|
| 169 |
+
``client_cert_source`` or application default SSL credentials.
|
| 170 |
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 171 |
+
Deprecated. A callback to provide client SSL certificate bytes and
|
| 172 |
+
private key bytes, both in PEM format. It is ignored if
|
| 173 |
+
``api_mtls_endpoint`` is None.
|
| 174 |
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
| 175 |
+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
|
| 176 |
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 177 |
+
A callback to provide client certificate bytes and private key bytes,
|
| 178 |
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
| 179 |
+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
|
| 180 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 181 |
+
and quota.
|
| 182 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 183 |
+
The client info used to send a user-agent string along with
|
| 184 |
+
API requests. If ``None``, then default info will be used.
|
| 185 |
+
Generally, you only need to set this if you're developing
|
| 186 |
+
your own client library.
|
| 187 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 188 |
+
be used for service account credentials.
|
| 189 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 190 |
+
to the service that will be set when using certain 3rd party
|
| 191 |
+
authentication flows. Audience is typically a resource identifier.
|
| 192 |
+
If not set, the host value will be used as a default.
|
| 193 |
+
|
| 194 |
+
Raises:
|
| 195 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 196 |
+
creation failed for any reason.
|
| 197 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 198 |
+
and ``credentials_file`` are passed.
|
| 199 |
+
"""
|
| 200 |
+
self._grpc_channel = None
|
| 201 |
+
self._ssl_channel_credentials = ssl_channel_credentials
|
| 202 |
+
self._stubs: Dict[str, Callable] = {}
|
| 203 |
+
|
| 204 |
+
if api_mtls_endpoint:
|
| 205 |
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
| 206 |
+
if client_cert_source:
|
| 207 |
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
| 208 |
+
|
| 209 |
+
if isinstance(channel, grpc.Channel):
|
| 210 |
+
# Ignore credentials if a channel was passed.
|
| 211 |
+
credentials = None
|
| 212 |
+
self._ignore_credentials = True
|
| 213 |
+
# If a channel was explicitly provided, set it.
|
| 214 |
+
self._grpc_channel = channel
|
| 215 |
+
self._ssl_channel_credentials = None
|
| 216 |
+
|
| 217 |
+
else:
|
| 218 |
+
if api_mtls_endpoint:
|
| 219 |
+
host = api_mtls_endpoint
|
| 220 |
+
|
| 221 |
+
# Create SSL credentials with client_cert_source or application
|
| 222 |
+
# default SSL credentials.
|
| 223 |
+
if client_cert_source:
|
| 224 |
+
cert, key = client_cert_source()
|
| 225 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 226 |
+
certificate_chain=cert, private_key=key
|
| 227 |
+
)
|
| 228 |
+
else:
|
| 229 |
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
| 230 |
+
|
| 231 |
+
else:
|
| 232 |
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
| 233 |
+
cert, key = client_cert_source_for_mtls()
|
| 234 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 235 |
+
certificate_chain=cert, private_key=key
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
# The base transport sets the host, credentials and scopes
|
| 239 |
+
super().__init__(
|
| 240 |
+
host=host,
|
| 241 |
+
credentials=credentials,
|
| 242 |
+
credentials_file=credentials_file,
|
| 243 |
+
scopes=scopes,
|
| 244 |
+
quota_project_id=quota_project_id,
|
| 245 |
+
client_info=client_info,
|
| 246 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 247 |
+
api_audience=api_audience,
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
if not self._grpc_channel:
|
| 251 |
+
# initialize with the provided callable or the default channel
|
| 252 |
+
channel_init = channel or type(self).create_channel
|
| 253 |
+
self._grpc_channel = channel_init(
|
| 254 |
+
self._host,
|
| 255 |
+
# use the credentials which are saved
|
| 256 |
+
credentials=self._credentials,
|
| 257 |
+
# Set ``credentials_file`` to ``None`` here as
|
| 258 |
+
# the credentials that we saved earlier should be used.
|
| 259 |
+
credentials_file=None,
|
| 260 |
+
scopes=self._scopes,
|
| 261 |
+
ssl_credentials=self._ssl_channel_credentials,
|
| 262 |
+
quota_project_id=quota_project_id,
|
| 263 |
+
options=[
|
| 264 |
+
("grpc.max_send_message_length", -1),
|
| 265 |
+
("grpc.max_receive_message_length", -1),
|
| 266 |
+
],
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
self._interceptor = _LoggingClientInterceptor()
|
| 270 |
+
self._logged_channel = grpc.intercept_channel(
|
| 271 |
+
self._grpc_channel, self._interceptor
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
# Wrap messages. This must be done after self._logged_channel exists
|
| 275 |
+
self._prep_wrapped_messages(client_info)
|
| 276 |
+
|
| 277 |
+
@classmethod
|
| 278 |
+
def create_channel(
|
| 279 |
+
cls,
|
| 280 |
+
host: str = "speech.googleapis.com",
|
| 281 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 282 |
+
credentials_file: Optional[str] = None,
|
| 283 |
+
scopes: Optional[Sequence[str]] = None,
|
| 284 |
+
quota_project_id: Optional[str] = None,
|
| 285 |
+
**kwargs,
|
| 286 |
+
) -> grpc.Channel:
|
| 287 |
+
"""Create and return a gRPC channel object.
|
| 288 |
+
Args:
|
| 289 |
+
host (Optional[str]): The host for the channel to use.
|
| 290 |
+
credentials (Optional[~.Credentials]): The
|
| 291 |
+
authorization credentials to attach to requests. These
|
| 292 |
+
credentials identify this application to the service. If
|
| 293 |
+
none are specified, the client will attempt to ascertain
|
| 294 |
+
the credentials from the environment.
|
| 295 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 296 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 297 |
+
This argument is mutually exclusive with credentials. This argument will be
|
| 298 |
+
removed in the next major version of this library.
|
| 299 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 300 |
+
service. These are only used when credentials are not specified and
|
| 301 |
+
are passed to :func:`google.auth.default`.
|
| 302 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 303 |
+
and quota.
|
| 304 |
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
| 305 |
+
channel creation.
|
| 306 |
+
Returns:
|
| 307 |
+
grpc.Channel: A gRPC channel object.
|
| 308 |
+
|
| 309 |
+
Raises:
|
| 310 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 311 |
+
and ``credentials_file`` are passed.
|
| 312 |
+
"""
|
| 313 |
+
|
| 314 |
+
return grpc_helpers.create_channel(
|
| 315 |
+
host,
|
| 316 |
+
credentials=credentials,
|
| 317 |
+
credentials_file=credentials_file,
|
| 318 |
+
quota_project_id=quota_project_id,
|
| 319 |
+
default_scopes=cls.AUTH_SCOPES,
|
| 320 |
+
scopes=scopes,
|
| 321 |
+
default_host=cls.DEFAULT_HOST,
|
| 322 |
+
**kwargs,
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
@property
|
| 326 |
+
def grpc_channel(self) -> grpc.Channel:
|
| 327 |
+
"""Return the channel designed to connect to this service."""
|
| 328 |
+
return self._grpc_channel
|
| 329 |
+
|
| 330 |
+
@property
|
| 331 |
+
def create_phrase_set(
|
| 332 |
+
self,
|
| 333 |
+
) -> Callable[[cloud_speech_adaptation.CreatePhraseSetRequest], resource.PhraseSet]:
|
| 334 |
+
r"""Return a callable for the create phrase set method over gRPC.
|
| 335 |
+
|
| 336 |
+
Create a set of phrase hints. Each item in the set
|
| 337 |
+
can be a single word or a multi-word phrase. The items
|
| 338 |
+
in the PhraseSet are favored by the recognition model
|
| 339 |
+
when you send a call that includes the PhraseSet.
|
| 340 |
+
|
| 341 |
+
Returns:
|
| 342 |
+
Callable[[~.CreatePhraseSetRequest],
|
| 343 |
+
~.PhraseSet]:
|
| 344 |
+
A function that, when called, will call the underlying RPC
|
| 345 |
+
on the server.
|
| 346 |
+
"""
|
| 347 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 348 |
+
# the request.
|
| 349 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 350 |
+
# to pass in the functions for each.
|
| 351 |
+
if "create_phrase_set" not in self._stubs:
|
| 352 |
+
self._stubs["create_phrase_set"] = self._logged_channel.unary_unary(
|
| 353 |
+
"/google.cloud.speech.v1.Adaptation/CreatePhraseSet",
|
| 354 |
+
request_serializer=cloud_speech_adaptation.CreatePhraseSetRequest.serialize,
|
| 355 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 356 |
+
)
|
| 357 |
+
return self._stubs["create_phrase_set"]
|
| 358 |
+
|
| 359 |
+
@property
|
| 360 |
+
def get_phrase_set(
|
| 361 |
+
self,
|
| 362 |
+
) -> Callable[[cloud_speech_adaptation.GetPhraseSetRequest], resource.PhraseSet]:
|
| 363 |
+
r"""Return a callable for the get phrase set method over gRPC.
|
| 364 |
+
|
| 365 |
+
Get a phrase set.
|
| 366 |
+
|
| 367 |
+
Returns:
|
| 368 |
+
Callable[[~.GetPhraseSetRequest],
|
| 369 |
+
~.PhraseSet]:
|
| 370 |
+
A function that, when called, will call the underlying RPC
|
| 371 |
+
on the server.
|
| 372 |
+
"""
|
| 373 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 374 |
+
# the request.
|
| 375 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 376 |
+
# to pass in the functions for each.
|
| 377 |
+
if "get_phrase_set" not in self._stubs:
|
| 378 |
+
self._stubs["get_phrase_set"] = self._logged_channel.unary_unary(
|
| 379 |
+
"/google.cloud.speech.v1.Adaptation/GetPhraseSet",
|
| 380 |
+
request_serializer=cloud_speech_adaptation.GetPhraseSetRequest.serialize,
|
| 381 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 382 |
+
)
|
| 383 |
+
return self._stubs["get_phrase_set"]
|
| 384 |
+
|
| 385 |
+
@property
|
| 386 |
+
def list_phrase_set(
|
| 387 |
+
self,
|
| 388 |
+
) -> Callable[
|
| 389 |
+
[cloud_speech_adaptation.ListPhraseSetRequest],
|
| 390 |
+
cloud_speech_adaptation.ListPhraseSetResponse,
|
| 391 |
+
]:
|
| 392 |
+
r"""Return a callable for the list phrase set method over gRPC.
|
| 393 |
+
|
| 394 |
+
List phrase sets.
|
| 395 |
+
|
| 396 |
+
Returns:
|
| 397 |
+
Callable[[~.ListPhraseSetRequest],
|
| 398 |
+
~.ListPhraseSetResponse]:
|
| 399 |
+
A function that, when called, will call the underlying RPC
|
| 400 |
+
on the server.
|
| 401 |
+
"""
|
| 402 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 403 |
+
# the request.
|
| 404 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 405 |
+
# to pass in the functions for each.
|
| 406 |
+
if "list_phrase_set" not in self._stubs:
|
| 407 |
+
self._stubs["list_phrase_set"] = self._logged_channel.unary_unary(
|
| 408 |
+
"/google.cloud.speech.v1.Adaptation/ListPhraseSet",
|
| 409 |
+
request_serializer=cloud_speech_adaptation.ListPhraseSetRequest.serialize,
|
| 410 |
+
response_deserializer=cloud_speech_adaptation.ListPhraseSetResponse.deserialize,
|
| 411 |
+
)
|
| 412 |
+
return self._stubs["list_phrase_set"]
|
| 413 |
+
|
| 414 |
+
@property
|
| 415 |
+
def update_phrase_set(
|
| 416 |
+
self,
|
| 417 |
+
) -> Callable[[cloud_speech_adaptation.UpdatePhraseSetRequest], resource.PhraseSet]:
|
| 418 |
+
r"""Return a callable for the update phrase set method over gRPC.
|
| 419 |
+
|
| 420 |
+
Update a phrase set.
|
| 421 |
+
|
| 422 |
+
Returns:
|
| 423 |
+
Callable[[~.UpdatePhraseSetRequest],
|
| 424 |
+
~.PhraseSet]:
|
| 425 |
+
A function that, when called, will call the underlying RPC
|
| 426 |
+
on the server.
|
| 427 |
+
"""
|
| 428 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 429 |
+
# the request.
|
| 430 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 431 |
+
# to pass in the functions for each.
|
| 432 |
+
if "update_phrase_set" not in self._stubs:
|
| 433 |
+
self._stubs["update_phrase_set"] = self._logged_channel.unary_unary(
|
| 434 |
+
"/google.cloud.speech.v1.Adaptation/UpdatePhraseSet",
|
| 435 |
+
request_serializer=cloud_speech_adaptation.UpdatePhraseSetRequest.serialize,
|
| 436 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 437 |
+
)
|
| 438 |
+
return self._stubs["update_phrase_set"]
|
| 439 |
+
|
| 440 |
+
@property
|
| 441 |
+
def delete_phrase_set(
|
| 442 |
+
self,
|
| 443 |
+
) -> Callable[[cloud_speech_adaptation.DeletePhraseSetRequest], empty_pb2.Empty]:
|
| 444 |
+
r"""Return a callable for the delete phrase set method over gRPC.
|
| 445 |
+
|
| 446 |
+
Delete a phrase set.
|
| 447 |
+
|
| 448 |
+
Returns:
|
| 449 |
+
Callable[[~.DeletePhraseSetRequest],
|
| 450 |
+
~.Empty]:
|
| 451 |
+
A function that, when called, will call the underlying RPC
|
| 452 |
+
on the server.
|
| 453 |
+
"""
|
| 454 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 455 |
+
# the request.
|
| 456 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 457 |
+
# to pass in the functions for each.
|
| 458 |
+
if "delete_phrase_set" not in self._stubs:
|
| 459 |
+
self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary(
|
| 460 |
+
"/google.cloud.speech.v1.Adaptation/DeletePhraseSet",
|
| 461 |
+
request_serializer=cloud_speech_adaptation.DeletePhraseSetRequest.serialize,
|
| 462 |
+
response_deserializer=empty_pb2.Empty.FromString,
|
| 463 |
+
)
|
| 464 |
+
return self._stubs["delete_phrase_set"]
|
| 465 |
+
|
| 466 |
+
@property
|
| 467 |
+
def create_custom_class(
|
| 468 |
+
self,
|
| 469 |
+
) -> Callable[
|
| 470 |
+
[cloud_speech_adaptation.CreateCustomClassRequest], resource.CustomClass
|
| 471 |
+
]:
|
| 472 |
+
r"""Return a callable for the create custom class method over gRPC.
|
| 473 |
+
|
| 474 |
+
Create a custom class.
|
| 475 |
+
|
| 476 |
+
Returns:
|
| 477 |
+
Callable[[~.CreateCustomClassRequest],
|
| 478 |
+
~.CustomClass]:
|
| 479 |
+
A function that, when called, will call the underlying RPC
|
| 480 |
+
on the server.
|
| 481 |
+
"""
|
| 482 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 483 |
+
# the request.
|
| 484 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 485 |
+
# to pass in the functions for each.
|
| 486 |
+
if "create_custom_class" not in self._stubs:
|
| 487 |
+
self._stubs["create_custom_class"] = self._logged_channel.unary_unary(
|
| 488 |
+
"/google.cloud.speech.v1.Adaptation/CreateCustomClass",
|
| 489 |
+
request_serializer=cloud_speech_adaptation.CreateCustomClassRequest.serialize,
|
| 490 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 491 |
+
)
|
| 492 |
+
return self._stubs["create_custom_class"]
|
| 493 |
+
|
| 494 |
+
@property
|
| 495 |
+
def get_custom_class(
|
| 496 |
+
self,
|
| 497 |
+
) -> Callable[
|
| 498 |
+
[cloud_speech_adaptation.GetCustomClassRequest], resource.CustomClass
|
| 499 |
+
]:
|
| 500 |
+
r"""Return a callable for the get custom class method over gRPC.
|
| 501 |
+
|
| 502 |
+
Get a custom class.
|
| 503 |
+
|
| 504 |
+
Returns:
|
| 505 |
+
Callable[[~.GetCustomClassRequest],
|
| 506 |
+
~.CustomClass]:
|
| 507 |
+
A function that, when called, will call the underlying RPC
|
| 508 |
+
on the server.
|
| 509 |
+
"""
|
| 510 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 511 |
+
# the request.
|
| 512 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 513 |
+
# to pass in the functions for each.
|
| 514 |
+
if "get_custom_class" not in self._stubs:
|
| 515 |
+
self._stubs["get_custom_class"] = self._logged_channel.unary_unary(
|
| 516 |
+
"/google.cloud.speech.v1.Adaptation/GetCustomClass",
|
| 517 |
+
request_serializer=cloud_speech_adaptation.GetCustomClassRequest.serialize,
|
| 518 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 519 |
+
)
|
| 520 |
+
return self._stubs["get_custom_class"]
|
| 521 |
+
|
| 522 |
+
@property
|
| 523 |
+
def list_custom_classes(
|
| 524 |
+
self,
|
| 525 |
+
) -> Callable[
|
| 526 |
+
[cloud_speech_adaptation.ListCustomClassesRequest],
|
| 527 |
+
cloud_speech_adaptation.ListCustomClassesResponse,
|
| 528 |
+
]:
|
| 529 |
+
r"""Return a callable for the list custom classes method over gRPC.
|
| 530 |
+
|
| 531 |
+
List custom classes.
|
| 532 |
+
|
| 533 |
+
Returns:
|
| 534 |
+
Callable[[~.ListCustomClassesRequest],
|
| 535 |
+
~.ListCustomClassesResponse]:
|
| 536 |
+
A function that, when called, will call the underlying RPC
|
| 537 |
+
on the server.
|
| 538 |
+
"""
|
| 539 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 540 |
+
# the request.
|
| 541 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 542 |
+
# to pass in the functions for each.
|
| 543 |
+
if "list_custom_classes" not in self._stubs:
|
| 544 |
+
self._stubs["list_custom_classes"] = self._logged_channel.unary_unary(
|
| 545 |
+
"/google.cloud.speech.v1.Adaptation/ListCustomClasses",
|
| 546 |
+
request_serializer=cloud_speech_adaptation.ListCustomClassesRequest.serialize,
|
| 547 |
+
response_deserializer=cloud_speech_adaptation.ListCustomClassesResponse.deserialize,
|
| 548 |
+
)
|
| 549 |
+
return self._stubs["list_custom_classes"]
|
| 550 |
+
|
| 551 |
+
@property
|
| 552 |
+
def update_custom_class(
|
| 553 |
+
self,
|
| 554 |
+
) -> Callable[
|
| 555 |
+
[cloud_speech_adaptation.UpdateCustomClassRequest], resource.CustomClass
|
| 556 |
+
]:
|
| 557 |
+
r"""Return a callable for the update custom class method over gRPC.
|
| 558 |
+
|
| 559 |
+
Update a custom class.
|
| 560 |
+
|
| 561 |
+
Returns:
|
| 562 |
+
Callable[[~.UpdateCustomClassRequest],
|
| 563 |
+
~.CustomClass]:
|
| 564 |
+
A function that, when called, will call the underlying RPC
|
| 565 |
+
on the server.
|
| 566 |
+
"""
|
| 567 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 568 |
+
# the request.
|
| 569 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 570 |
+
# to pass in the functions for each.
|
| 571 |
+
if "update_custom_class" not in self._stubs:
|
| 572 |
+
self._stubs["update_custom_class"] = self._logged_channel.unary_unary(
|
| 573 |
+
"/google.cloud.speech.v1.Adaptation/UpdateCustomClass",
|
| 574 |
+
request_serializer=cloud_speech_adaptation.UpdateCustomClassRequest.serialize,
|
| 575 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 576 |
+
)
|
| 577 |
+
return self._stubs["update_custom_class"]
|
| 578 |
+
|
| 579 |
+
@property
|
| 580 |
+
def delete_custom_class(
|
| 581 |
+
self,
|
| 582 |
+
) -> Callable[[cloud_speech_adaptation.DeleteCustomClassRequest], empty_pb2.Empty]:
|
| 583 |
+
r"""Return a callable for the delete custom class method over gRPC.
|
| 584 |
+
|
| 585 |
+
Delete a custom class.
|
| 586 |
+
|
| 587 |
+
Returns:
|
| 588 |
+
Callable[[~.DeleteCustomClassRequest],
|
| 589 |
+
~.Empty]:
|
| 590 |
+
A function that, when called, will call the underlying RPC
|
| 591 |
+
on the server.
|
| 592 |
+
"""
|
| 593 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 594 |
+
# the request.
|
| 595 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 596 |
+
# to pass in the functions for each.
|
| 597 |
+
if "delete_custom_class" not in self._stubs:
|
| 598 |
+
self._stubs["delete_custom_class"] = self._logged_channel.unary_unary(
|
| 599 |
+
"/google.cloud.speech.v1.Adaptation/DeleteCustomClass",
|
| 600 |
+
request_serializer=cloud_speech_adaptation.DeleteCustomClassRequest.serialize,
|
| 601 |
+
response_deserializer=empty_pb2.Empty.FromString,
|
| 602 |
+
)
|
| 603 |
+
return self._stubs["delete_custom_class"]
|
| 604 |
+
|
| 605 |
+
def close(self):
|
| 606 |
+
self._logged_channel.close()
|
| 607 |
+
|
| 608 |
+
@property
|
| 609 |
+
def get_operation(
|
| 610 |
+
self,
|
| 611 |
+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
|
| 612 |
+
r"""Return a callable for the get_operation method over gRPC."""
|
| 613 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 614 |
+
# the request.
|
| 615 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 616 |
+
# to pass in the functions for each.
|
| 617 |
+
if "get_operation" not in self._stubs:
|
| 618 |
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
| 619 |
+
"/google.longrunning.Operations/GetOperation",
|
| 620 |
+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
| 621 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 622 |
+
)
|
| 623 |
+
return self._stubs["get_operation"]
|
| 624 |
+
|
| 625 |
+
@property
|
| 626 |
+
def list_operations(
|
| 627 |
+
self,
|
| 628 |
+
) -> Callable[
|
| 629 |
+
[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
|
| 630 |
+
]:
|
| 631 |
+
r"""Return a callable for the list_operations method over gRPC."""
|
| 632 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 633 |
+
# the request.
|
| 634 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 635 |
+
# to pass in the functions for each.
|
| 636 |
+
if "list_operations" not in self._stubs:
|
| 637 |
+
self._stubs["list_operations"] = self._logged_channel.unary_unary(
|
| 638 |
+
"/google.longrunning.Operations/ListOperations",
|
| 639 |
+
request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
|
| 640 |
+
response_deserializer=operations_pb2.ListOperationsResponse.FromString,
|
| 641 |
+
)
|
| 642 |
+
return self._stubs["list_operations"]
|
| 643 |
+
|
| 644 |
+
@property
|
| 645 |
+
def kind(self) -> str:
|
| 646 |
+
return "grpc"
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
__all__ = ("AdaptationGrpcTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/grpc_asyncio.py
ADDED
|
@@ -0,0 +1,739 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import inspect
|
| 17 |
+
import json
|
| 18 |
+
import logging as std_logging
|
| 19 |
+
import pickle
|
| 20 |
+
import warnings
|
| 21 |
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
|
| 22 |
+
|
| 23 |
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
| 24 |
+
import google.protobuf.message
|
| 25 |
+
import grpc # type: ignore
|
| 26 |
+
import proto # type: ignore
|
| 27 |
+
from google.api_core import exceptions as core_exceptions
|
| 28 |
+
from google.api_core import gapic_v1, grpc_helpers_async
|
| 29 |
+
from google.api_core import retry_async as retries
|
| 30 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 31 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 32 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 33 |
+
from google.protobuf.json_format import MessageToJson
|
| 34 |
+
from grpc.experimental import aio # type: ignore
|
| 35 |
+
|
| 36 |
+
from google.cloud.speech_v1.types import cloud_speech_adaptation, resource
|
| 37 |
+
|
| 38 |
+
from .base import DEFAULT_CLIENT_INFO, AdaptationTransport
|
| 39 |
+
from .grpc import AdaptationGrpcTransport
|
| 40 |
+
|
| 41 |
+
try:
|
| 42 |
+
from google.api_core import client_logging # type: ignore
|
| 43 |
+
|
| 44 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 45 |
+
except ImportError: # pragma: NO COVER
|
| 46 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 47 |
+
|
| 48 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class _LoggingClientAIOInterceptor(
|
| 52 |
+
grpc.aio.UnaryUnaryClientInterceptor
|
| 53 |
+
): # pragma: NO COVER
|
| 54 |
+
async def intercept_unary_unary(self, continuation, client_call_details, request):
|
| 55 |
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 56 |
+
std_logging.DEBUG
|
| 57 |
+
)
|
| 58 |
+
if logging_enabled: # pragma: NO COVER
|
| 59 |
+
request_metadata = client_call_details.metadata
|
| 60 |
+
if isinstance(request, proto.Message):
|
| 61 |
+
request_payload = type(request).to_json(request)
|
| 62 |
+
elif isinstance(request, google.protobuf.message.Message):
|
| 63 |
+
request_payload = MessageToJson(request)
|
| 64 |
+
else:
|
| 65 |
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
|
| 66 |
+
|
| 67 |
+
request_metadata = {
|
| 68 |
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
| 69 |
+
for key, value in request_metadata
|
| 70 |
+
}
|
| 71 |
+
grpc_request = {
|
| 72 |
+
"payload": request_payload,
|
| 73 |
+
"requestMethod": "grpc",
|
| 74 |
+
"metadata": dict(request_metadata),
|
| 75 |
+
}
|
| 76 |
+
_LOGGER.debug(
|
| 77 |
+
f"Sending request for {client_call_details.method}",
|
| 78 |
+
extra={
|
| 79 |
+
"serviceName": "google.cloud.speech.v1.Adaptation",
|
| 80 |
+
"rpcName": str(client_call_details.method),
|
| 81 |
+
"request": grpc_request,
|
| 82 |
+
"metadata": grpc_request["metadata"],
|
| 83 |
+
},
|
| 84 |
+
)
|
| 85 |
+
response = await continuation(client_call_details, request)
|
| 86 |
+
if logging_enabled: # pragma: NO COVER
|
| 87 |
+
response_metadata = await response.trailing_metadata()
|
| 88 |
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
| 89 |
+
metadata = (
|
| 90 |
+
dict([(k, str(v)) for k, v in response_metadata])
|
| 91 |
+
if response_metadata
|
| 92 |
+
else None
|
| 93 |
+
)
|
| 94 |
+
result = await response
|
| 95 |
+
if isinstance(result, proto.Message):
|
| 96 |
+
response_payload = type(result).to_json(result)
|
| 97 |
+
elif isinstance(result, google.protobuf.message.Message):
|
| 98 |
+
response_payload = MessageToJson(result)
|
| 99 |
+
else:
|
| 100 |
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
|
| 101 |
+
grpc_response = {
|
| 102 |
+
"payload": response_payload,
|
| 103 |
+
"metadata": metadata,
|
| 104 |
+
"status": "OK",
|
| 105 |
+
}
|
| 106 |
+
_LOGGER.debug(
|
| 107 |
+
f"Received response to rpc {client_call_details.method}.",
|
| 108 |
+
extra={
|
| 109 |
+
"serviceName": "google.cloud.speech.v1.Adaptation",
|
| 110 |
+
"rpcName": str(client_call_details.method),
|
| 111 |
+
"response": grpc_response,
|
| 112 |
+
"metadata": grpc_response["metadata"],
|
| 113 |
+
},
|
| 114 |
+
)
|
| 115 |
+
return response
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
class AdaptationGrpcAsyncIOTransport(AdaptationTransport):
|
| 119 |
+
"""gRPC AsyncIO backend transport for Adaptation.
|
| 120 |
+
|
| 121 |
+
Service that implements Google Cloud Speech Adaptation API.
|
| 122 |
+
|
| 123 |
+
This class defines the same methods as the primary client, so the
|
| 124 |
+
primary client can load the underlying transport implementation
|
| 125 |
+
and call it.
|
| 126 |
+
|
| 127 |
+
It sends protocol buffers over the wire using gRPC (which is built on
|
| 128 |
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
| 129 |
+
"""
|
| 130 |
+
|
| 131 |
+
_grpc_channel: aio.Channel
|
| 132 |
+
_stubs: Dict[str, Callable] = {}
|
| 133 |
+
|
| 134 |
+
@classmethod
|
| 135 |
+
def create_channel(
|
| 136 |
+
cls,
|
| 137 |
+
host: str = "speech.googleapis.com",
|
| 138 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 139 |
+
credentials_file: Optional[str] = None,
|
| 140 |
+
scopes: Optional[Sequence[str]] = None,
|
| 141 |
+
quota_project_id: Optional[str] = None,
|
| 142 |
+
**kwargs,
|
| 143 |
+
) -> aio.Channel:
|
| 144 |
+
"""Create and return a gRPC AsyncIO channel object.
|
| 145 |
+
Args:
|
| 146 |
+
host (Optional[str]): The host for the channel to use.
|
| 147 |
+
credentials (Optional[~.Credentials]): The
|
| 148 |
+
authorization credentials to attach to requests. These
|
| 149 |
+
credentials identify this application to the service. If
|
| 150 |
+
none are specified, the client will attempt to ascertain
|
| 151 |
+
the credentials from the environment.
|
| 152 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 153 |
+
be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be
|
| 154 |
+
removed in the next major version of this library.
|
| 155 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 156 |
+
service. These are only used when credentials are not specified and
|
| 157 |
+
are passed to :func:`google.auth.default`.
|
| 158 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 159 |
+
and quota.
|
| 160 |
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
| 161 |
+
channel creation.
|
| 162 |
+
Returns:
|
| 163 |
+
aio.Channel: A gRPC AsyncIO channel object.
|
| 164 |
+
"""
|
| 165 |
+
|
| 166 |
+
return grpc_helpers_async.create_channel(
|
| 167 |
+
host,
|
| 168 |
+
credentials=credentials,
|
| 169 |
+
credentials_file=credentials_file,
|
| 170 |
+
quota_project_id=quota_project_id,
|
| 171 |
+
default_scopes=cls.AUTH_SCOPES,
|
| 172 |
+
scopes=scopes,
|
| 173 |
+
default_host=cls.DEFAULT_HOST,
|
| 174 |
+
**kwargs,
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
def __init__(
|
| 178 |
+
self,
|
| 179 |
+
*,
|
| 180 |
+
host: str = "speech.googleapis.com",
|
| 181 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 182 |
+
credentials_file: Optional[str] = None,
|
| 183 |
+
scopes: Optional[Sequence[str]] = None,
|
| 184 |
+
channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
|
| 185 |
+
api_mtls_endpoint: Optional[str] = None,
|
| 186 |
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 187 |
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
| 188 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 189 |
+
quota_project_id: Optional[str] = None,
|
| 190 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 191 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 192 |
+
api_audience: Optional[str] = None,
|
| 193 |
+
) -> None:
|
| 194 |
+
"""Instantiate the transport.
|
| 195 |
+
|
| 196 |
+
Args:
|
| 197 |
+
host (Optional[str]):
|
| 198 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 199 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 200 |
+
authorization credentials to attach to requests. These
|
| 201 |
+
credentials identify the application to the service; if none
|
| 202 |
+
are specified, the client will attempt to ascertain the
|
| 203 |
+
credentials from the environment.
|
| 204 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 205 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 206 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 207 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 208 |
+
This argument will be removed in the next major version of this library.
|
| 209 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 210 |
+
service. These are only used when credentials are not specified and
|
| 211 |
+
are passed to :func:`google.auth.default`.
|
| 212 |
+
channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
|
| 213 |
+
A ``Channel`` instance through which to make calls, or a Callable
|
| 214 |
+
that constructs and returns one. If set to None, ``self.create_channel``
|
| 215 |
+
is used to create the channel. If a Callable is given, it will be called
|
| 216 |
+
with the same arguments as used in ``self.create_channel``.
|
| 217 |
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
| 218 |
+
If provided, it overrides the ``host`` argument and tries to create
|
| 219 |
+
a mutual TLS channel with client SSL credentials from
|
| 220 |
+
``client_cert_source`` or application default SSL credentials.
|
| 221 |
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 222 |
+
Deprecated. A callback to provide client SSL certificate bytes and
|
| 223 |
+
private key bytes, both in PEM format. It is ignored if
|
| 224 |
+
``api_mtls_endpoint`` is None.
|
| 225 |
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
| 226 |
+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
|
| 227 |
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 228 |
+
A callback to provide client certificate bytes and private key bytes,
|
| 229 |
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
| 230 |
+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
|
| 231 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 232 |
+
and quota.
|
| 233 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 234 |
+
The client info used to send a user-agent string along with
|
| 235 |
+
API requests. If ``None``, then default info will be used.
|
| 236 |
+
Generally, you only need to set this if you're developing
|
| 237 |
+
your own client library.
|
| 238 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 239 |
+
be used for service account credentials.
|
| 240 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 241 |
+
to the service that will be set when using certain 3rd party
|
| 242 |
+
authentication flows. Audience is typically a resource identifier.
|
| 243 |
+
If not set, the host value will be used as a default.
|
| 244 |
+
|
| 245 |
+
Raises:
|
| 246 |
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
| 247 |
+
creation failed for any reason.
|
| 248 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 249 |
+
and ``credentials_file`` are passed.
|
| 250 |
+
"""
|
| 251 |
+
self._grpc_channel = None
|
| 252 |
+
self._ssl_channel_credentials = ssl_channel_credentials
|
| 253 |
+
self._stubs: Dict[str, Callable] = {}
|
| 254 |
+
|
| 255 |
+
if api_mtls_endpoint:
|
| 256 |
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
| 257 |
+
if client_cert_source:
|
| 258 |
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
| 259 |
+
|
| 260 |
+
if isinstance(channel, aio.Channel):
|
| 261 |
+
# Ignore credentials if a channel was passed.
|
| 262 |
+
credentials = None
|
| 263 |
+
self._ignore_credentials = True
|
| 264 |
+
# If a channel was explicitly provided, set it.
|
| 265 |
+
self._grpc_channel = channel
|
| 266 |
+
self._ssl_channel_credentials = None
|
| 267 |
+
else:
|
| 268 |
+
if api_mtls_endpoint:
|
| 269 |
+
host = api_mtls_endpoint
|
| 270 |
+
|
| 271 |
+
# Create SSL credentials with client_cert_source or application
|
| 272 |
+
# default SSL credentials.
|
| 273 |
+
if client_cert_source:
|
| 274 |
+
cert, key = client_cert_source()
|
| 275 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 276 |
+
certificate_chain=cert, private_key=key
|
| 277 |
+
)
|
| 278 |
+
else:
|
| 279 |
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
| 280 |
+
|
| 281 |
+
else:
|
| 282 |
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
| 283 |
+
cert, key = client_cert_source_for_mtls()
|
| 284 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 285 |
+
certificate_chain=cert, private_key=key
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
# The base transport sets the host, credentials and scopes
|
| 289 |
+
super().__init__(
|
| 290 |
+
host=host,
|
| 291 |
+
credentials=credentials,
|
| 292 |
+
credentials_file=credentials_file,
|
| 293 |
+
scopes=scopes,
|
| 294 |
+
quota_project_id=quota_project_id,
|
| 295 |
+
client_info=client_info,
|
| 296 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 297 |
+
api_audience=api_audience,
|
| 298 |
+
)
|
| 299 |
+
|
| 300 |
+
if not self._grpc_channel:
|
| 301 |
+
# initialize with the provided callable or the default channel
|
| 302 |
+
channel_init = channel or type(self).create_channel
|
| 303 |
+
self._grpc_channel = channel_init(
|
| 304 |
+
self._host,
|
| 305 |
+
# use the credentials which are saved
|
| 306 |
+
credentials=self._credentials,
|
| 307 |
+
# Set ``credentials_file`` to ``None`` here as
|
| 308 |
+
# the credentials that we saved earlier should be used.
|
| 309 |
+
credentials_file=None,
|
| 310 |
+
scopes=self._scopes,
|
| 311 |
+
ssl_credentials=self._ssl_channel_credentials,
|
| 312 |
+
quota_project_id=quota_project_id,
|
| 313 |
+
options=[
|
| 314 |
+
("grpc.max_send_message_length", -1),
|
| 315 |
+
("grpc.max_receive_message_length", -1),
|
| 316 |
+
],
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
+
self._interceptor = _LoggingClientAIOInterceptor()
|
| 320 |
+
self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
|
| 321 |
+
self._logged_channel = self._grpc_channel
|
| 322 |
+
self._wrap_with_kind = (
|
| 323 |
+
"kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
|
| 324 |
+
)
|
| 325 |
+
# Wrap messages. This must be done after self._logged_channel exists
|
| 326 |
+
self._prep_wrapped_messages(client_info)
|
| 327 |
+
|
| 328 |
+
@property
|
| 329 |
+
def grpc_channel(self) -> aio.Channel:
|
| 330 |
+
"""Create the channel designed to connect to this service.
|
| 331 |
+
|
| 332 |
+
This property caches on the instance; repeated calls return
|
| 333 |
+
the same channel.
|
| 334 |
+
"""
|
| 335 |
+
# Return the channel from cache.
|
| 336 |
+
return self._grpc_channel
|
| 337 |
+
|
| 338 |
+
@property
|
| 339 |
+
def create_phrase_set(
|
| 340 |
+
self,
|
| 341 |
+
) -> Callable[
|
| 342 |
+
[cloud_speech_adaptation.CreatePhraseSetRequest], Awaitable[resource.PhraseSet]
|
| 343 |
+
]:
|
| 344 |
+
r"""Return a callable for the create phrase set method over gRPC.
|
| 345 |
+
|
| 346 |
+
Create a set of phrase hints. Each item in the set
|
| 347 |
+
can be a single word or a multi-word phrase. The items
|
| 348 |
+
in the PhraseSet are favored by the recognition model
|
| 349 |
+
when you send a call that includes the PhraseSet.
|
| 350 |
+
|
| 351 |
+
Returns:
|
| 352 |
+
Callable[[~.CreatePhraseSetRequest],
|
| 353 |
+
Awaitable[~.PhraseSet]]:
|
| 354 |
+
A function that, when called, will call the underlying RPC
|
| 355 |
+
on the server.
|
| 356 |
+
"""
|
| 357 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 358 |
+
# the request.
|
| 359 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 360 |
+
# to pass in the functions for each.
|
| 361 |
+
if "create_phrase_set" not in self._stubs:
|
| 362 |
+
self._stubs["create_phrase_set"] = self._logged_channel.unary_unary(
|
| 363 |
+
"/google.cloud.speech.v1.Adaptation/CreatePhraseSet",
|
| 364 |
+
request_serializer=cloud_speech_adaptation.CreatePhraseSetRequest.serialize,
|
| 365 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 366 |
+
)
|
| 367 |
+
return self._stubs["create_phrase_set"]
|
| 368 |
+
|
| 369 |
+
@property
|
| 370 |
+
def get_phrase_set(
|
| 371 |
+
self,
|
| 372 |
+
) -> Callable[
|
| 373 |
+
[cloud_speech_adaptation.GetPhraseSetRequest], Awaitable[resource.PhraseSet]
|
| 374 |
+
]:
|
| 375 |
+
r"""Return a callable for the get phrase set method over gRPC.
|
| 376 |
+
|
| 377 |
+
Get a phrase set.
|
| 378 |
+
|
| 379 |
+
Returns:
|
| 380 |
+
Callable[[~.GetPhraseSetRequest],
|
| 381 |
+
Awaitable[~.PhraseSet]]:
|
| 382 |
+
A function that, when called, will call the underlying RPC
|
| 383 |
+
on the server.
|
| 384 |
+
"""
|
| 385 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 386 |
+
# the request.
|
| 387 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 388 |
+
# to pass in the functions for each.
|
| 389 |
+
if "get_phrase_set" not in self._stubs:
|
| 390 |
+
self._stubs["get_phrase_set"] = self._logged_channel.unary_unary(
|
| 391 |
+
"/google.cloud.speech.v1.Adaptation/GetPhraseSet",
|
| 392 |
+
request_serializer=cloud_speech_adaptation.GetPhraseSetRequest.serialize,
|
| 393 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 394 |
+
)
|
| 395 |
+
return self._stubs["get_phrase_set"]
|
| 396 |
+
|
| 397 |
+
@property
|
| 398 |
+
def list_phrase_set(
|
| 399 |
+
self,
|
| 400 |
+
) -> Callable[
|
| 401 |
+
[cloud_speech_adaptation.ListPhraseSetRequest],
|
| 402 |
+
Awaitable[cloud_speech_adaptation.ListPhraseSetResponse],
|
| 403 |
+
]:
|
| 404 |
+
r"""Return a callable for the list phrase set method over gRPC.
|
| 405 |
+
|
| 406 |
+
List phrase sets.
|
| 407 |
+
|
| 408 |
+
Returns:
|
| 409 |
+
Callable[[~.ListPhraseSetRequest],
|
| 410 |
+
Awaitable[~.ListPhraseSetResponse]]:
|
| 411 |
+
A function that, when called, will call the underlying RPC
|
| 412 |
+
on the server.
|
| 413 |
+
"""
|
| 414 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 415 |
+
# the request.
|
| 416 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 417 |
+
# to pass in the functions for each.
|
| 418 |
+
if "list_phrase_set" not in self._stubs:
|
| 419 |
+
self._stubs["list_phrase_set"] = self._logged_channel.unary_unary(
|
| 420 |
+
"/google.cloud.speech.v1.Adaptation/ListPhraseSet",
|
| 421 |
+
request_serializer=cloud_speech_adaptation.ListPhraseSetRequest.serialize,
|
| 422 |
+
response_deserializer=cloud_speech_adaptation.ListPhraseSetResponse.deserialize,
|
| 423 |
+
)
|
| 424 |
+
return self._stubs["list_phrase_set"]
|
| 425 |
+
|
| 426 |
+
@property
|
| 427 |
+
def update_phrase_set(
|
| 428 |
+
self,
|
| 429 |
+
) -> Callable[
|
| 430 |
+
[cloud_speech_adaptation.UpdatePhraseSetRequest], Awaitable[resource.PhraseSet]
|
| 431 |
+
]:
|
| 432 |
+
r"""Return a callable for the update phrase set method over gRPC.
|
| 433 |
+
|
| 434 |
+
Update a phrase set.
|
| 435 |
+
|
| 436 |
+
Returns:
|
| 437 |
+
Callable[[~.UpdatePhraseSetRequest],
|
| 438 |
+
Awaitable[~.PhraseSet]]:
|
| 439 |
+
A function that, when called, will call the underlying RPC
|
| 440 |
+
on the server.
|
| 441 |
+
"""
|
| 442 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 443 |
+
# the request.
|
| 444 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 445 |
+
# to pass in the functions for each.
|
| 446 |
+
if "update_phrase_set" not in self._stubs:
|
| 447 |
+
self._stubs["update_phrase_set"] = self._logged_channel.unary_unary(
|
| 448 |
+
"/google.cloud.speech.v1.Adaptation/UpdatePhraseSet",
|
| 449 |
+
request_serializer=cloud_speech_adaptation.UpdatePhraseSetRequest.serialize,
|
| 450 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 451 |
+
)
|
| 452 |
+
return self._stubs["update_phrase_set"]
|
| 453 |
+
|
| 454 |
+
@property
|
| 455 |
+
def delete_phrase_set(
|
| 456 |
+
self,
|
| 457 |
+
) -> Callable[
|
| 458 |
+
[cloud_speech_adaptation.DeletePhraseSetRequest], Awaitable[empty_pb2.Empty]
|
| 459 |
+
]:
|
| 460 |
+
r"""Return a callable for the delete phrase set method over gRPC.
|
| 461 |
+
|
| 462 |
+
Delete a phrase set.
|
| 463 |
+
|
| 464 |
+
Returns:
|
| 465 |
+
Callable[[~.DeletePhraseSetRequest],
|
| 466 |
+
Awaitable[~.Empty]]:
|
| 467 |
+
A function that, when called, will call the underlying RPC
|
| 468 |
+
on the server.
|
| 469 |
+
"""
|
| 470 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 471 |
+
# the request.
|
| 472 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 473 |
+
# to pass in the functions for each.
|
| 474 |
+
if "delete_phrase_set" not in self._stubs:
|
| 475 |
+
self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary(
|
| 476 |
+
"/google.cloud.speech.v1.Adaptation/DeletePhraseSet",
|
| 477 |
+
request_serializer=cloud_speech_adaptation.DeletePhraseSetRequest.serialize,
|
| 478 |
+
response_deserializer=empty_pb2.Empty.FromString,
|
| 479 |
+
)
|
| 480 |
+
return self._stubs["delete_phrase_set"]
|
| 481 |
+
|
| 482 |
+
@property
|
| 483 |
+
def create_custom_class(
|
| 484 |
+
self,
|
| 485 |
+
) -> Callable[
|
| 486 |
+
[cloud_speech_adaptation.CreateCustomClassRequest],
|
| 487 |
+
Awaitable[resource.CustomClass],
|
| 488 |
+
]:
|
| 489 |
+
r"""Return a callable for the create custom class method over gRPC.
|
| 490 |
+
|
| 491 |
+
Create a custom class.
|
| 492 |
+
|
| 493 |
+
Returns:
|
| 494 |
+
Callable[[~.CreateCustomClassRequest],
|
| 495 |
+
Awaitable[~.CustomClass]]:
|
| 496 |
+
A function that, when called, will call the underlying RPC
|
| 497 |
+
on the server.
|
| 498 |
+
"""
|
| 499 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 500 |
+
# the request.
|
| 501 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 502 |
+
# to pass in the functions for each.
|
| 503 |
+
if "create_custom_class" not in self._stubs:
|
| 504 |
+
self._stubs["create_custom_class"] = self._logged_channel.unary_unary(
|
| 505 |
+
"/google.cloud.speech.v1.Adaptation/CreateCustomClass",
|
| 506 |
+
request_serializer=cloud_speech_adaptation.CreateCustomClassRequest.serialize,
|
| 507 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 508 |
+
)
|
| 509 |
+
return self._stubs["create_custom_class"]
|
| 510 |
+
|
| 511 |
+
@property
|
| 512 |
+
def get_custom_class(
|
| 513 |
+
self,
|
| 514 |
+
) -> Callable[
|
| 515 |
+
[cloud_speech_adaptation.GetCustomClassRequest], Awaitable[resource.CustomClass]
|
| 516 |
+
]:
|
| 517 |
+
r"""Return a callable for the get custom class method over gRPC.
|
| 518 |
+
|
| 519 |
+
Get a custom class.
|
| 520 |
+
|
| 521 |
+
Returns:
|
| 522 |
+
Callable[[~.GetCustomClassRequest],
|
| 523 |
+
Awaitable[~.CustomClass]]:
|
| 524 |
+
A function that, when called, will call the underlying RPC
|
| 525 |
+
on the server.
|
| 526 |
+
"""
|
| 527 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 528 |
+
# the request.
|
| 529 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 530 |
+
# to pass in the functions for each.
|
| 531 |
+
if "get_custom_class" not in self._stubs:
|
| 532 |
+
self._stubs["get_custom_class"] = self._logged_channel.unary_unary(
|
| 533 |
+
"/google.cloud.speech.v1.Adaptation/GetCustomClass",
|
| 534 |
+
request_serializer=cloud_speech_adaptation.GetCustomClassRequest.serialize,
|
| 535 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 536 |
+
)
|
| 537 |
+
return self._stubs["get_custom_class"]
|
| 538 |
+
|
| 539 |
+
@property
|
| 540 |
+
def list_custom_classes(
|
| 541 |
+
self,
|
| 542 |
+
) -> Callable[
|
| 543 |
+
[cloud_speech_adaptation.ListCustomClassesRequest],
|
| 544 |
+
Awaitable[cloud_speech_adaptation.ListCustomClassesResponse],
|
| 545 |
+
]:
|
| 546 |
+
r"""Return a callable for the list custom classes method over gRPC.
|
| 547 |
+
|
| 548 |
+
List custom classes.
|
| 549 |
+
|
| 550 |
+
Returns:
|
| 551 |
+
Callable[[~.ListCustomClassesRequest],
|
| 552 |
+
Awaitable[~.ListCustomClassesResponse]]:
|
| 553 |
+
A function that, when called, will call the underlying RPC
|
| 554 |
+
on the server.
|
| 555 |
+
"""
|
| 556 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 557 |
+
# the request.
|
| 558 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 559 |
+
# to pass in the functions for each.
|
| 560 |
+
if "list_custom_classes" not in self._stubs:
|
| 561 |
+
self._stubs["list_custom_classes"] = self._logged_channel.unary_unary(
|
| 562 |
+
"/google.cloud.speech.v1.Adaptation/ListCustomClasses",
|
| 563 |
+
request_serializer=cloud_speech_adaptation.ListCustomClassesRequest.serialize,
|
| 564 |
+
response_deserializer=cloud_speech_adaptation.ListCustomClassesResponse.deserialize,
|
| 565 |
+
)
|
| 566 |
+
return self._stubs["list_custom_classes"]
|
| 567 |
+
|
| 568 |
+
@property
|
| 569 |
+
def update_custom_class(
|
| 570 |
+
self,
|
| 571 |
+
) -> Callable[
|
| 572 |
+
[cloud_speech_adaptation.UpdateCustomClassRequest],
|
| 573 |
+
Awaitable[resource.CustomClass],
|
| 574 |
+
]:
|
| 575 |
+
r"""Return a callable for the update custom class method over gRPC.
|
| 576 |
+
|
| 577 |
+
Update a custom class.
|
| 578 |
+
|
| 579 |
+
Returns:
|
| 580 |
+
Callable[[~.UpdateCustomClassRequest],
|
| 581 |
+
Awaitable[~.CustomClass]]:
|
| 582 |
+
A function that, when called, will call the underlying RPC
|
| 583 |
+
on the server.
|
| 584 |
+
"""
|
| 585 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 586 |
+
# the request.
|
| 587 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 588 |
+
# to pass in the functions for each.
|
| 589 |
+
if "update_custom_class" not in self._stubs:
|
| 590 |
+
self._stubs["update_custom_class"] = self._logged_channel.unary_unary(
|
| 591 |
+
"/google.cloud.speech.v1.Adaptation/UpdateCustomClass",
|
| 592 |
+
request_serializer=cloud_speech_adaptation.UpdateCustomClassRequest.serialize,
|
| 593 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 594 |
+
)
|
| 595 |
+
return self._stubs["update_custom_class"]
|
| 596 |
+
|
| 597 |
+
@property
|
| 598 |
+
def delete_custom_class(
|
| 599 |
+
self,
|
| 600 |
+
) -> Callable[
|
| 601 |
+
[cloud_speech_adaptation.DeleteCustomClassRequest], Awaitable[empty_pb2.Empty]
|
| 602 |
+
]:
|
| 603 |
+
r"""Return a callable for the delete custom class method over gRPC.
|
| 604 |
+
|
| 605 |
+
Delete a custom class.
|
| 606 |
+
|
| 607 |
+
Returns:
|
| 608 |
+
Callable[[~.DeleteCustomClassRequest],
|
| 609 |
+
Awaitable[~.Empty]]:
|
| 610 |
+
A function that, when called, will call the underlying RPC
|
| 611 |
+
on the server.
|
| 612 |
+
"""
|
| 613 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 614 |
+
# the request.
|
| 615 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 616 |
+
# to pass in the functions for each.
|
| 617 |
+
if "delete_custom_class" not in self._stubs:
|
| 618 |
+
self._stubs["delete_custom_class"] = self._logged_channel.unary_unary(
|
| 619 |
+
"/google.cloud.speech.v1.Adaptation/DeleteCustomClass",
|
| 620 |
+
request_serializer=cloud_speech_adaptation.DeleteCustomClassRequest.serialize,
|
| 621 |
+
response_deserializer=empty_pb2.Empty.FromString,
|
| 622 |
+
)
|
| 623 |
+
return self._stubs["delete_custom_class"]
|
| 624 |
+
|
| 625 |
+
def _prep_wrapped_messages(self, client_info):
|
| 626 |
+
"""Precompute the wrapped methods, overriding the base class method to use async wrappers."""
|
| 627 |
+
self._wrapped_methods = {
|
| 628 |
+
self.create_phrase_set: self._wrap_method(
|
| 629 |
+
self.create_phrase_set,
|
| 630 |
+
default_timeout=None,
|
| 631 |
+
client_info=client_info,
|
| 632 |
+
),
|
| 633 |
+
self.get_phrase_set: self._wrap_method(
|
| 634 |
+
self.get_phrase_set,
|
| 635 |
+
default_timeout=None,
|
| 636 |
+
client_info=client_info,
|
| 637 |
+
),
|
| 638 |
+
self.list_phrase_set: self._wrap_method(
|
| 639 |
+
self.list_phrase_set,
|
| 640 |
+
default_timeout=None,
|
| 641 |
+
client_info=client_info,
|
| 642 |
+
),
|
| 643 |
+
self.update_phrase_set: self._wrap_method(
|
| 644 |
+
self.update_phrase_set,
|
| 645 |
+
default_timeout=None,
|
| 646 |
+
client_info=client_info,
|
| 647 |
+
),
|
| 648 |
+
self.delete_phrase_set: self._wrap_method(
|
| 649 |
+
self.delete_phrase_set,
|
| 650 |
+
default_timeout=None,
|
| 651 |
+
client_info=client_info,
|
| 652 |
+
),
|
| 653 |
+
self.create_custom_class: self._wrap_method(
|
| 654 |
+
self.create_custom_class,
|
| 655 |
+
default_timeout=None,
|
| 656 |
+
client_info=client_info,
|
| 657 |
+
),
|
| 658 |
+
self.get_custom_class: self._wrap_method(
|
| 659 |
+
self.get_custom_class,
|
| 660 |
+
default_timeout=None,
|
| 661 |
+
client_info=client_info,
|
| 662 |
+
),
|
| 663 |
+
self.list_custom_classes: self._wrap_method(
|
| 664 |
+
self.list_custom_classes,
|
| 665 |
+
default_timeout=None,
|
| 666 |
+
client_info=client_info,
|
| 667 |
+
),
|
| 668 |
+
self.update_custom_class: self._wrap_method(
|
| 669 |
+
self.update_custom_class,
|
| 670 |
+
default_timeout=None,
|
| 671 |
+
client_info=client_info,
|
| 672 |
+
),
|
| 673 |
+
self.delete_custom_class: self._wrap_method(
|
| 674 |
+
self.delete_custom_class,
|
| 675 |
+
default_timeout=None,
|
| 676 |
+
client_info=client_info,
|
| 677 |
+
),
|
| 678 |
+
self.get_operation: self._wrap_method(
|
| 679 |
+
self.get_operation,
|
| 680 |
+
default_timeout=None,
|
| 681 |
+
client_info=client_info,
|
| 682 |
+
),
|
| 683 |
+
self.list_operations: self._wrap_method(
|
| 684 |
+
self.list_operations,
|
| 685 |
+
default_timeout=None,
|
| 686 |
+
client_info=client_info,
|
| 687 |
+
),
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
def _wrap_method(self, func, *args, **kwargs):
|
| 691 |
+
if self._wrap_with_kind: # pragma: NO COVER
|
| 692 |
+
kwargs["kind"] = self.kind
|
| 693 |
+
return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
|
| 694 |
+
|
| 695 |
+
def close(self):
|
| 696 |
+
return self._logged_channel.close()
|
| 697 |
+
|
| 698 |
+
@property
|
| 699 |
+
def kind(self) -> str:
|
| 700 |
+
return "grpc_asyncio"
|
| 701 |
+
|
| 702 |
+
@property
|
| 703 |
+
def get_operation(
|
| 704 |
+
self,
|
| 705 |
+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
|
| 706 |
+
r"""Return a callable for the get_operation method over gRPC."""
|
| 707 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 708 |
+
# the request.
|
| 709 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 710 |
+
# to pass in the functions for each.
|
| 711 |
+
if "get_operation" not in self._stubs:
|
| 712 |
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
| 713 |
+
"/google.longrunning.Operations/GetOperation",
|
| 714 |
+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
| 715 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 716 |
+
)
|
| 717 |
+
return self._stubs["get_operation"]
|
| 718 |
+
|
| 719 |
+
@property
|
| 720 |
+
def list_operations(
|
| 721 |
+
self,
|
| 722 |
+
) -> Callable[
|
| 723 |
+
[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
|
| 724 |
+
]:
|
| 725 |
+
r"""Return a callable for the list_operations method over gRPC."""
|
| 726 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 727 |
+
# the request.
|
| 728 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 729 |
+
# to pass in the functions for each.
|
| 730 |
+
if "list_operations" not in self._stubs:
|
| 731 |
+
self._stubs["list_operations"] = self._logged_channel.unary_unary(
|
| 732 |
+
"/google.longrunning.Operations/ListOperations",
|
| 733 |
+
request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
|
| 734 |
+
response_deserializer=operations_pb2.ListOperationsResponse.FromString,
|
| 735 |
+
)
|
| 736 |
+
return self._stubs["list_operations"]
|
| 737 |
+
|
| 738 |
+
|
| 739 |
+
__all__ = ("AdaptationGrpcAsyncIOTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/rest.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/adaptation/transports/rest_base.py
ADDED
|
@@ -0,0 +1,653 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json # type: ignore
|
| 17 |
+
import re
|
| 18 |
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
| 19 |
+
|
| 20 |
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
| 21 |
+
from google.api_core import gapic_v1, path_template
|
| 22 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 23 |
+
from google.protobuf import json_format
|
| 24 |
+
|
| 25 |
+
from google.cloud.speech_v1.types import cloud_speech_adaptation, resource
|
| 26 |
+
|
| 27 |
+
from .base import DEFAULT_CLIENT_INFO, AdaptationTransport
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class _BaseAdaptationRestTransport(AdaptationTransport):
|
| 31 |
+
"""Base REST backend transport for Adaptation.
|
| 32 |
+
|
| 33 |
+
Note: This class is not meant to be used directly. Use its sync and
|
| 34 |
+
async sub-classes instead.
|
| 35 |
+
|
| 36 |
+
This class defines the same methods as the primary client, so the
|
| 37 |
+
primary client can load the underlying transport implementation
|
| 38 |
+
and call it.
|
| 39 |
+
|
| 40 |
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
def __init__(
|
| 44 |
+
self,
|
| 45 |
+
*,
|
| 46 |
+
host: str = "speech.googleapis.com",
|
| 47 |
+
credentials: Optional[Any] = None,
|
| 48 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 49 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 50 |
+
url_scheme: str = "https",
|
| 51 |
+
api_audience: Optional[str] = None,
|
| 52 |
+
) -> None:
|
| 53 |
+
"""Instantiate the transport.
|
| 54 |
+
Args:
|
| 55 |
+
host (Optional[str]):
|
| 56 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 57 |
+
credentials (Optional[Any]): The
|
| 58 |
+
authorization credentials to attach to requests. These
|
| 59 |
+
credentials identify the application to the service; if none
|
| 60 |
+
are specified, the client will attempt to ascertain the
|
| 61 |
+
credentials from the environment.
|
| 62 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 63 |
+
The client info used to send a user-agent string along with
|
| 64 |
+
API requests. If ``None``, then default info will be used.
|
| 65 |
+
Generally, you only need to set this if you are developing
|
| 66 |
+
your own client library.
|
| 67 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 68 |
+
be used for service account credentials.
|
| 69 |
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
| 70 |
+
"https", but for testing or local servers,
|
| 71 |
+
"http" can be specified.
|
| 72 |
+
"""
|
| 73 |
+
# Run the base constructor
|
| 74 |
+
maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
|
| 75 |
+
if maybe_url_match is None:
|
| 76 |
+
raise ValueError(
|
| 77 |
+
f"Unexpected hostname structure: {host}"
|
| 78 |
+
) # pragma: NO COVER
|
| 79 |
+
|
| 80 |
+
url_match_items = maybe_url_match.groupdict()
|
| 81 |
+
|
| 82 |
+
host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host
|
| 83 |
+
|
| 84 |
+
super().__init__(
|
| 85 |
+
host=host,
|
| 86 |
+
credentials=credentials,
|
| 87 |
+
client_info=client_info,
|
| 88 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 89 |
+
api_audience=api_audience,
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
class _BaseCreateCustomClass:
|
| 93 |
+
def __hash__(self): # pragma: NO COVER
|
| 94 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 95 |
+
|
| 96 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 97 |
+
|
| 98 |
+
@classmethod
|
| 99 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 100 |
+
return {
|
| 101 |
+
k: v
|
| 102 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 103 |
+
if k not in message_dict
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
@staticmethod
|
| 107 |
+
def _get_http_options():
|
| 108 |
+
http_options: List[Dict[str, str]] = [
|
| 109 |
+
{
|
| 110 |
+
"method": "post",
|
| 111 |
+
"uri": "/v1/{parent=projects/*/locations/*}/customClasses",
|
| 112 |
+
"body": "*",
|
| 113 |
+
},
|
| 114 |
+
]
|
| 115 |
+
return http_options
|
| 116 |
+
|
| 117 |
+
@staticmethod
|
| 118 |
+
def _get_transcoded_request(http_options, request):
|
| 119 |
+
pb_request = cloud_speech_adaptation.CreateCustomClassRequest.pb(request)
|
| 120 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 121 |
+
return transcoded_request
|
| 122 |
+
|
| 123 |
+
@staticmethod
|
| 124 |
+
def _get_request_body_json(transcoded_request):
|
| 125 |
+
# Jsonify the request body
|
| 126 |
+
|
| 127 |
+
body = json_format.MessageToJson(
|
| 128 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 129 |
+
)
|
| 130 |
+
return body
|
| 131 |
+
|
| 132 |
+
@staticmethod
|
| 133 |
+
def _get_query_params_json(transcoded_request):
|
| 134 |
+
query_params = json.loads(
|
| 135 |
+
json_format.MessageToJson(
|
| 136 |
+
transcoded_request["query_params"],
|
| 137 |
+
use_integers_for_enums=True,
|
| 138 |
+
)
|
| 139 |
+
)
|
| 140 |
+
query_params.update(
|
| 141 |
+
_BaseAdaptationRestTransport._BaseCreateCustomClass._get_unset_required_fields(
|
| 142 |
+
query_params
|
| 143 |
+
)
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 147 |
+
return query_params
|
| 148 |
+
|
| 149 |
+
class _BaseCreatePhraseSet:
|
| 150 |
+
def __hash__(self): # pragma: NO COVER
|
| 151 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 152 |
+
|
| 153 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 154 |
+
|
| 155 |
+
@classmethod
|
| 156 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 157 |
+
return {
|
| 158 |
+
k: v
|
| 159 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 160 |
+
if k not in message_dict
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
@staticmethod
|
| 164 |
+
def _get_http_options():
|
| 165 |
+
http_options: List[Dict[str, str]] = [
|
| 166 |
+
{
|
| 167 |
+
"method": "post",
|
| 168 |
+
"uri": "/v1/{parent=projects/*/locations/*}/phraseSets",
|
| 169 |
+
"body": "*",
|
| 170 |
+
},
|
| 171 |
+
]
|
| 172 |
+
return http_options
|
| 173 |
+
|
| 174 |
+
@staticmethod
|
| 175 |
+
def _get_transcoded_request(http_options, request):
|
| 176 |
+
pb_request = cloud_speech_adaptation.CreatePhraseSetRequest.pb(request)
|
| 177 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 178 |
+
return transcoded_request
|
| 179 |
+
|
| 180 |
+
@staticmethod
|
| 181 |
+
def _get_request_body_json(transcoded_request):
|
| 182 |
+
# Jsonify the request body
|
| 183 |
+
|
| 184 |
+
body = json_format.MessageToJson(
|
| 185 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 186 |
+
)
|
| 187 |
+
return body
|
| 188 |
+
|
| 189 |
+
@staticmethod
|
| 190 |
+
def _get_query_params_json(transcoded_request):
|
| 191 |
+
query_params = json.loads(
|
| 192 |
+
json_format.MessageToJson(
|
| 193 |
+
transcoded_request["query_params"],
|
| 194 |
+
use_integers_for_enums=True,
|
| 195 |
+
)
|
| 196 |
+
)
|
| 197 |
+
query_params.update(
|
| 198 |
+
_BaseAdaptationRestTransport._BaseCreatePhraseSet._get_unset_required_fields(
|
| 199 |
+
query_params
|
| 200 |
+
)
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 204 |
+
return query_params
|
| 205 |
+
|
| 206 |
+
class _BaseDeleteCustomClass:
|
| 207 |
+
def __hash__(self): # pragma: NO COVER
|
| 208 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 209 |
+
|
| 210 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 211 |
+
|
| 212 |
+
@classmethod
|
| 213 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 214 |
+
return {
|
| 215 |
+
k: v
|
| 216 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 217 |
+
if k not in message_dict
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
@staticmethod
|
| 221 |
+
def _get_http_options():
|
| 222 |
+
http_options: List[Dict[str, str]] = [
|
| 223 |
+
{
|
| 224 |
+
"method": "delete",
|
| 225 |
+
"uri": "/v1/{name=projects/*/locations/*/customClasses/*}",
|
| 226 |
+
},
|
| 227 |
+
]
|
| 228 |
+
return http_options
|
| 229 |
+
|
| 230 |
+
@staticmethod
|
| 231 |
+
def _get_transcoded_request(http_options, request):
|
| 232 |
+
pb_request = cloud_speech_adaptation.DeleteCustomClassRequest.pb(request)
|
| 233 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 234 |
+
return transcoded_request
|
| 235 |
+
|
| 236 |
+
@staticmethod
|
| 237 |
+
def _get_query_params_json(transcoded_request):
|
| 238 |
+
query_params = json.loads(
|
| 239 |
+
json_format.MessageToJson(
|
| 240 |
+
transcoded_request["query_params"],
|
| 241 |
+
use_integers_for_enums=True,
|
| 242 |
+
)
|
| 243 |
+
)
|
| 244 |
+
query_params.update(
|
| 245 |
+
_BaseAdaptationRestTransport._BaseDeleteCustomClass._get_unset_required_fields(
|
| 246 |
+
query_params
|
| 247 |
+
)
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 251 |
+
return query_params
|
| 252 |
+
|
| 253 |
+
class _BaseDeletePhraseSet:
|
| 254 |
+
def __hash__(self): # pragma: NO COVER
|
| 255 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 256 |
+
|
| 257 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 258 |
+
|
| 259 |
+
@classmethod
|
| 260 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 261 |
+
return {
|
| 262 |
+
k: v
|
| 263 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 264 |
+
if k not in message_dict
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
@staticmethod
|
| 268 |
+
def _get_http_options():
|
| 269 |
+
http_options: List[Dict[str, str]] = [
|
| 270 |
+
{
|
| 271 |
+
"method": "delete",
|
| 272 |
+
"uri": "/v1/{name=projects/*/locations/*/phraseSets/*}",
|
| 273 |
+
},
|
| 274 |
+
]
|
| 275 |
+
return http_options
|
| 276 |
+
|
| 277 |
+
@staticmethod
|
| 278 |
+
def _get_transcoded_request(http_options, request):
|
| 279 |
+
pb_request = cloud_speech_adaptation.DeletePhraseSetRequest.pb(request)
|
| 280 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 281 |
+
return transcoded_request
|
| 282 |
+
|
| 283 |
+
@staticmethod
|
| 284 |
+
def _get_query_params_json(transcoded_request):
|
| 285 |
+
query_params = json.loads(
|
| 286 |
+
json_format.MessageToJson(
|
| 287 |
+
transcoded_request["query_params"],
|
| 288 |
+
use_integers_for_enums=True,
|
| 289 |
+
)
|
| 290 |
+
)
|
| 291 |
+
query_params.update(
|
| 292 |
+
_BaseAdaptationRestTransport._BaseDeletePhraseSet._get_unset_required_fields(
|
| 293 |
+
query_params
|
| 294 |
+
)
|
| 295 |
+
)
|
| 296 |
+
|
| 297 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 298 |
+
return query_params
|
| 299 |
+
|
| 300 |
+
class _BaseGetCustomClass:
|
| 301 |
+
def __hash__(self): # pragma: NO COVER
|
| 302 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 303 |
+
|
| 304 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 305 |
+
|
| 306 |
+
@classmethod
|
| 307 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 308 |
+
return {
|
| 309 |
+
k: v
|
| 310 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 311 |
+
if k not in message_dict
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
@staticmethod
|
| 315 |
+
def _get_http_options():
|
| 316 |
+
http_options: List[Dict[str, str]] = [
|
| 317 |
+
{
|
| 318 |
+
"method": "get",
|
| 319 |
+
"uri": "/v1/{name=projects/*/locations/*/customClasses/*}",
|
| 320 |
+
},
|
| 321 |
+
]
|
| 322 |
+
return http_options
|
| 323 |
+
|
| 324 |
+
@staticmethod
|
| 325 |
+
def _get_transcoded_request(http_options, request):
|
| 326 |
+
pb_request = cloud_speech_adaptation.GetCustomClassRequest.pb(request)
|
| 327 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 328 |
+
return transcoded_request
|
| 329 |
+
|
| 330 |
+
@staticmethod
|
| 331 |
+
def _get_query_params_json(transcoded_request):
|
| 332 |
+
query_params = json.loads(
|
| 333 |
+
json_format.MessageToJson(
|
| 334 |
+
transcoded_request["query_params"],
|
| 335 |
+
use_integers_for_enums=True,
|
| 336 |
+
)
|
| 337 |
+
)
|
| 338 |
+
query_params.update(
|
| 339 |
+
_BaseAdaptationRestTransport._BaseGetCustomClass._get_unset_required_fields(
|
| 340 |
+
query_params
|
| 341 |
+
)
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 345 |
+
return query_params
|
| 346 |
+
|
| 347 |
+
class _BaseGetPhraseSet:
|
| 348 |
+
def __hash__(self): # pragma: NO COVER
|
| 349 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 350 |
+
|
| 351 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 352 |
+
|
| 353 |
+
@classmethod
|
| 354 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 355 |
+
return {
|
| 356 |
+
k: v
|
| 357 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 358 |
+
if k not in message_dict
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
@staticmethod
|
| 362 |
+
def _get_http_options():
|
| 363 |
+
http_options: List[Dict[str, str]] = [
|
| 364 |
+
{
|
| 365 |
+
"method": "get",
|
| 366 |
+
"uri": "/v1/{name=projects/*/locations/*/phraseSets/*}",
|
| 367 |
+
},
|
| 368 |
+
]
|
| 369 |
+
return http_options
|
| 370 |
+
|
| 371 |
+
@staticmethod
|
| 372 |
+
def _get_transcoded_request(http_options, request):
|
| 373 |
+
pb_request = cloud_speech_adaptation.GetPhraseSetRequest.pb(request)
|
| 374 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 375 |
+
return transcoded_request
|
| 376 |
+
|
| 377 |
+
@staticmethod
|
| 378 |
+
def _get_query_params_json(transcoded_request):
|
| 379 |
+
query_params = json.loads(
|
| 380 |
+
json_format.MessageToJson(
|
| 381 |
+
transcoded_request["query_params"],
|
| 382 |
+
use_integers_for_enums=True,
|
| 383 |
+
)
|
| 384 |
+
)
|
| 385 |
+
query_params.update(
|
| 386 |
+
_BaseAdaptationRestTransport._BaseGetPhraseSet._get_unset_required_fields(
|
| 387 |
+
query_params
|
| 388 |
+
)
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 392 |
+
return query_params
|
| 393 |
+
|
| 394 |
+
class _BaseListCustomClasses:
|
| 395 |
+
def __hash__(self): # pragma: NO COVER
|
| 396 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 397 |
+
|
| 398 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 399 |
+
|
| 400 |
+
@classmethod
|
| 401 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 402 |
+
return {
|
| 403 |
+
k: v
|
| 404 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 405 |
+
if k not in message_dict
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
@staticmethod
|
| 409 |
+
def _get_http_options():
|
| 410 |
+
http_options: List[Dict[str, str]] = [
|
| 411 |
+
{
|
| 412 |
+
"method": "get",
|
| 413 |
+
"uri": "/v1/{parent=projects/*/locations/*}/customClasses",
|
| 414 |
+
},
|
| 415 |
+
]
|
| 416 |
+
return http_options
|
| 417 |
+
|
| 418 |
+
@staticmethod
|
| 419 |
+
def _get_transcoded_request(http_options, request):
|
| 420 |
+
pb_request = cloud_speech_adaptation.ListCustomClassesRequest.pb(request)
|
| 421 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 422 |
+
return transcoded_request
|
| 423 |
+
|
| 424 |
+
@staticmethod
|
| 425 |
+
def _get_query_params_json(transcoded_request):
|
| 426 |
+
query_params = json.loads(
|
| 427 |
+
json_format.MessageToJson(
|
| 428 |
+
transcoded_request["query_params"],
|
| 429 |
+
use_integers_for_enums=True,
|
| 430 |
+
)
|
| 431 |
+
)
|
| 432 |
+
query_params.update(
|
| 433 |
+
_BaseAdaptationRestTransport._BaseListCustomClasses._get_unset_required_fields(
|
| 434 |
+
query_params
|
| 435 |
+
)
|
| 436 |
+
)
|
| 437 |
+
|
| 438 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 439 |
+
return query_params
|
| 440 |
+
|
| 441 |
+
class _BaseListPhraseSet:
|
| 442 |
+
def __hash__(self): # pragma: NO COVER
|
| 443 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 444 |
+
|
| 445 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 446 |
+
|
| 447 |
+
@classmethod
|
| 448 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 449 |
+
return {
|
| 450 |
+
k: v
|
| 451 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 452 |
+
if k not in message_dict
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
@staticmethod
|
| 456 |
+
def _get_http_options():
|
| 457 |
+
http_options: List[Dict[str, str]] = [
|
| 458 |
+
{
|
| 459 |
+
"method": "get",
|
| 460 |
+
"uri": "/v1/{parent=projects/*/locations/*}/phraseSets",
|
| 461 |
+
},
|
| 462 |
+
]
|
| 463 |
+
return http_options
|
| 464 |
+
|
| 465 |
+
@staticmethod
|
| 466 |
+
def _get_transcoded_request(http_options, request):
|
| 467 |
+
pb_request = cloud_speech_adaptation.ListPhraseSetRequest.pb(request)
|
| 468 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 469 |
+
return transcoded_request
|
| 470 |
+
|
| 471 |
+
@staticmethod
|
| 472 |
+
def _get_query_params_json(transcoded_request):
|
| 473 |
+
query_params = json.loads(
|
| 474 |
+
json_format.MessageToJson(
|
| 475 |
+
transcoded_request["query_params"],
|
| 476 |
+
use_integers_for_enums=True,
|
| 477 |
+
)
|
| 478 |
+
)
|
| 479 |
+
query_params.update(
|
| 480 |
+
_BaseAdaptationRestTransport._BaseListPhraseSet._get_unset_required_fields(
|
| 481 |
+
query_params
|
| 482 |
+
)
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 486 |
+
return query_params
|
| 487 |
+
|
| 488 |
+
class _BaseUpdateCustomClass:
|
| 489 |
+
def __hash__(self): # pragma: NO COVER
|
| 490 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 491 |
+
|
| 492 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 493 |
+
|
| 494 |
+
@classmethod
|
| 495 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 496 |
+
return {
|
| 497 |
+
k: v
|
| 498 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 499 |
+
if k not in message_dict
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
@staticmethod
|
| 503 |
+
def _get_http_options():
|
| 504 |
+
http_options: List[Dict[str, str]] = [
|
| 505 |
+
{
|
| 506 |
+
"method": "patch",
|
| 507 |
+
"uri": "/v1/{custom_class.name=projects/*/locations/*/customClasses/*}",
|
| 508 |
+
"body": "custom_class",
|
| 509 |
+
},
|
| 510 |
+
]
|
| 511 |
+
return http_options
|
| 512 |
+
|
| 513 |
+
@staticmethod
|
| 514 |
+
def _get_transcoded_request(http_options, request):
|
| 515 |
+
pb_request = cloud_speech_adaptation.UpdateCustomClassRequest.pb(request)
|
| 516 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 517 |
+
return transcoded_request
|
| 518 |
+
|
| 519 |
+
@staticmethod
|
| 520 |
+
def _get_request_body_json(transcoded_request):
|
| 521 |
+
# Jsonify the request body
|
| 522 |
+
|
| 523 |
+
body = json_format.MessageToJson(
|
| 524 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 525 |
+
)
|
| 526 |
+
return body
|
| 527 |
+
|
| 528 |
+
@staticmethod
|
| 529 |
+
def _get_query_params_json(transcoded_request):
|
| 530 |
+
query_params = json.loads(
|
| 531 |
+
json_format.MessageToJson(
|
| 532 |
+
transcoded_request["query_params"],
|
| 533 |
+
use_integers_for_enums=True,
|
| 534 |
+
)
|
| 535 |
+
)
|
| 536 |
+
query_params.update(
|
| 537 |
+
_BaseAdaptationRestTransport._BaseUpdateCustomClass._get_unset_required_fields(
|
| 538 |
+
query_params
|
| 539 |
+
)
|
| 540 |
+
)
|
| 541 |
+
|
| 542 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 543 |
+
return query_params
|
| 544 |
+
|
| 545 |
+
class _BaseUpdatePhraseSet:
|
| 546 |
+
def __hash__(self): # pragma: NO COVER
|
| 547 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 548 |
+
|
| 549 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 550 |
+
|
| 551 |
+
@classmethod
|
| 552 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 553 |
+
return {
|
| 554 |
+
k: v
|
| 555 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 556 |
+
if k not in message_dict
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
@staticmethod
|
| 560 |
+
def _get_http_options():
|
| 561 |
+
http_options: List[Dict[str, str]] = [
|
| 562 |
+
{
|
| 563 |
+
"method": "patch",
|
| 564 |
+
"uri": "/v1/{phrase_set.name=projects/*/locations/*/phraseSets/*}",
|
| 565 |
+
"body": "phrase_set",
|
| 566 |
+
},
|
| 567 |
+
]
|
| 568 |
+
return http_options
|
| 569 |
+
|
| 570 |
+
@staticmethod
|
| 571 |
+
def _get_transcoded_request(http_options, request):
|
| 572 |
+
pb_request = cloud_speech_adaptation.UpdatePhraseSetRequest.pb(request)
|
| 573 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 574 |
+
return transcoded_request
|
| 575 |
+
|
| 576 |
+
@staticmethod
|
| 577 |
+
def _get_request_body_json(transcoded_request):
|
| 578 |
+
# Jsonify the request body
|
| 579 |
+
|
| 580 |
+
body = json_format.MessageToJson(
|
| 581 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 582 |
+
)
|
| 583 |
+
return body
|
| 584 |
+
|
| 585 |
+
@staticmethod
|
| 586 |
+
def _get_query_params_json(transcoded_request):
|
| 587 |
+
query_params = json.loads(
|
| 588 |
+
json_format.MessageToJson(
|
| 589 |
+
transcoded_request["query_params"],
|
| 590 |
+
use_integers_for_enums=True,
|
| 591 |
+
)
|
| 592 |
+
)
|
| 593 |
+
query_params.update(
|
| 594 |
+
_BaseAdaptationRestTransport._BaseUpdatePhraseSet._get_unset_required_fields(
|
| 595 |
+
query_params
|
| 596 |
+
)
|
| 597 |
+
)
|
| 598 |
+
|
| 599 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 600 |
+
return query_params
|
| 601 |
+
|
| 602 |
+
class _BaseGetOperation:
|
| 603 |
+
def __hash__(self): # pragma: NO COVER
|
| 604 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 605 |
+
|
| 606 |
+
@staticmethod
|
| 607 |
+
def _get_http_options():
|
| 608 |
+
http_options: List[Dict[str, str]] = [
|
| 609 |
+
{
|
| 610 |
+
"method": "get",
|
| 611 |
+
"uri": "/v1/operations/{name=**}",
|
| 612 |
+
},
|
| 613 |
+
]
|
| 614 |
+
return http_options
|
| 615 |
+
|
| 616 |
+
@staticmethod
|
| 617 |
+
def _get_transcoded_request(http_options, request):
|
| 618 |
+
request_kwargs = json_format.MessageToDict(request)
|
| 619 |
+
transcoded_request = path_template.transcode(http_options, **request_kwargs)
|
| 620 |
+
return transcoded_request
|
| 621 |
+
|
| 622 |
+
@staticmethod
|
| 623 |
+
def _get_query_params_json(transcoded_request):
|
| 624 |
+
query_params = json.loads(json.dumps(transcoded_request["query_params"]))
|
| 625 |
+
return query_params
|
| 626 |
+
|
| 627 |
+
class _BaseListOperations:
|
| 628 |
+
def __hash__(self): # pragma: NO COVER
|
| 629 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 630 |
+
|
| 631 |
+
@staticmethod
|
| 632 |
+
def _get_http_options():
|
| 633 |
+
http_options: List[Dict[str, str]] = [
|
| 634 |
+
{
|
| 635 |
+
"method": "get",
|
| 636 |
+
"uri": "/v1/operations",
|
| 637 |
+
},
|
| 638 |
+
]
|
| 639 |
+
return http_options
|
| 640 |
+
|
| 641 |
+
@staticmethod
|
| 642 |
+
def _get_transcoded_request(http_options, request):
|
| 643 |
+
request_kwargs = json_format.MessageToDict(request)
|
| 644 |
+
transcoded_request = path_template.transcode(http_options, **request_kwargs)
|
| 645 |
+
return transcoded_request
|
| 646 |
+
|
| 647 |
+
@staticmethod
|
| 648 |
+
def _get_query_params_json(transcoded_request):
|
| 649 |
+
query_params = json.loads(json.dumps(transcoded_request["query_params"]))
|
| 650 |
+
return query_params
|
| 651 |
+
|
| 652 |
+
|
| 653 |
+
__all__ = ("_BaseAdaptationRestTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from .async_client import SpeechAsyncClient
|
| 17 |
+
from .client import SpeechClient
|
| 18 |
+
|
| 19 |
+
__all__ = (
|
| 20 |
+
"SpeechClient",
|
| 21 |
+
"SpeechAsyncClient",
|
| 22 |
+
)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/async_client.py
ADDED
|
@@ -0,0 +1,860 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import logging as std_logging
|
| 17 |
+
import re
|
| 18 |
+
from collections import OrderedDict
|
| 19 |
+
from typing import (
|
| 20 |
+
AsyncIterable,
|
| 21 |
+
AsyncIterator,
|
| 22 |
+
Awaitable,
|
| 23 |
+
Callable,
|
| 24 |
+
Dict,
|
| 25 |
+
Mapping,
|
| 26 |
+
MutableMapping,
|
| 27 |
+
MutableSequence,
|
| 28 |
+
Optional,
|
| 29 |
+
Sequence,
|
| 30 |
+
Tuple,
|
| 31 |
+
Type,
|
| 32 |
+
Union,
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
import google.protobuf
|
| 36 |
+
from google.api_core import exceptions as core_exceptions
|
| 37 |
+
from google.api_core import gapic_v1
|
| 38 |
+
from google.api_core import retry_async as retries
|
| 39 |
+
from google.api_core.client_options import ClientOptions
|
| 40 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 41 |
+
from google.oauth2 import service_account # type: ignore
|
| 42 |
+
|
| 43 |
+
from google.cloud.speech_v1 import gapic_version as package_version
|
| 44 |
+
|
| 45 |
+
try:
|
| 46 |
+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
|
| 47 |
+
except AttributeError: # pragma: NO COVER
|
| 48 |
+
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
| 49 |
+
|
| 50 |
+
import google.api_core.operation as operation # type: ignore
|
| 51 |
+
import google.api_core.operation_async as operation_async # type: ignore
|
| 52 |
+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
|
| 53 |
+
import google.rpc.status_pb2 as status_pb2 # type: ignore
|
| 54 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 55 |
+
|
| 56 |
+
from google.cloud.speech_v1.types import cloud_speech
|
| 57 |
+
|
| 58 |
+
from .client import SpeechClient
|
| 59 |
+
from .transports.base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 60 |
+
from .transports.grpc_asyncio import SpeechGrpcAsyncIOTransport
|
| 61 |
+
|
| 62 |
+
try:
|
| 63 |
+
from google.api_core import client_logging # type: ignore
|
| 64 |
+
|
| 65 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 66 |
+
except ImportError: # pragma: NO COVER
|
| 67 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 68 |
+
|
| 69 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class SpeechAsyncClient:
|
| 73 |
+
"""Service that implements Google Cloud Speech API."""
|
| 74 |
+
|
| 75 |
+
_client: SpeechClient
|
| 76 |
+
|
| 77 |
+
# Copy defaults from the synchronous client for use here.
|
| 78 |
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
| 79 |
+
DEFAULT_ENDPOINT = SpeechClient.DEFAULT_ENDPOINT
|
| 80 |
+
DEFAULT_MTLS_ENDPOINT = SpeechClient.DEFAULT_MTLS_ENDPOINT
|
| 81 |
+
_DEFAULT_ENDPOINT_TEMPLATE = SpeechClient._DEFAULT_ENDPOINT_TEMPLATE
|
| 82 |
+
_DEFAULT_UNIVERSE = SpeechClient._DEFAULT_UNIVERSE
|
| 83 |
+
|
| 84 |
+
custom_class_path = staticmethod(SpeechClient.custom_class_path)
|
| 85 |
+
parse_custom_class_path = staticmethod(SpeechClient.parse_custom_class_path)
|
| 86 |
+
phrase_set_path = staticmethod(SpeechClient.phrase_set_path)
|
| 87 |
+
parse_phrase_set_path = staticmethod(SpeechClient.parse_phrase_set_path)
|
| 88 |
+
common_billing_account_path = staticmethod(SpeechClient.common_billing_account_path)
|
| 89 |
+
parse_common_billing_account_path = staticmethod(
|
| 90 |
+
SpeechClient.parse_common_billing_account_path
|
| 91 |
+
)
|
| 92 |
+
common_folder_path = staticmethod(SpeechClient.common_folder_path)
|
| 93 |
+
parse_common_folder_path = staticmethod(SpeechClient.parse_common_folder_path)
|
| 94 |
+
common_organization_path = staticmethod(SpeechClient.common_organization_path)
|
| 95 |
+
parse_common_organization_path = staticmethod(
|
| 96 |
+
SpeechClient.parse_common_organization_path
|
| 97 |
+
)
|
| 98 |
+
common_project_path = staticmethod(SpeechClient.common_project_path)
|
| 99 |
+
parse_common_project_path = staticmethod(SpeechClient.parse_common_project_path)
|
| 100 |
+
common_location_path = staticmethod(SpeechClient.common_location_path)
|
| 101 |
+
parse_common_location_path = staticmethod(SpeechClient.parse_common_location_path)
|
| 102 |
+
|
| 103 |
+
@classmethod
|
| 104 |
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
| 105 |
+
"""Creates an instance of this client using the provided credentials
|
| 106 |
+
info.
|
| 107 |
+
|
| 108 |
+
Args:
|
| 109 |
+
info (dict): The service account private key info.
|
| 110 |
+
args: Additional arguments to pass to the constructor.
|
| 111 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 112 |
+
|
| 113 |
+
Returns:
|
| 114 |
+
SpeechAsyncClient: The constructed client.
|
| 115 |
+
"""
|
| 116 |
+
sa_info_func = (
|
| 117 |
+
SpeechClient.from_service_account_info.__func__ # type: ignore
|
| 118 |
+
)
|
| 119 |
+
return sa_info_func(SpeechAsyncClient, info, *args, **kwargs)
|
| 120 |
+
|
| 121 |
+
@classmethod
|
| 122 |
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
| 123 |
+
"""Creates an instance of this client using the provided credentials
|
| 124 |
+
file.
|
| 125 |
+
|
| 126 |
+
Args:
|
| 127 |
+
filename (str): The path to the service account private key json
|
| 128 |
+
file.
|
| 129 |
+
args: Additional arguments to pass to the constructor.
|
| 130 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 131 |
+
|
| 132 |
+
Returns:
|
| 133 |
+
SpeechAsyncClient: The constructed client.
|
| 134 |
+
"""
|
| 135 |
+
sa_file_func = (
|
| 136 |
+
SpeechClient.from_service_account_file.__func__ # type: ignore
|
| 137 |
+
)
|
| 138 |
+
return sa_file_func(SpeechAsyncClient, filename, *args, **kwargs)
|
| 139 |
+
|
| 140 |
+
from_service_account_json = from_service_account_file
|
| 141 |
+
|
| 142 |
+
@classmethod
|
| 143 |
+
def get_mtls_endpoint_and_cert_source(
|
| 144 |
+
cls, client_options: Optional[ClientOptions] = None
|
| 145 |
+
):
|
| 146 |
+
"""Return the API endpoint and client cert source for mutual TLS.
|
| 147 |
+
|
| 148 |
+
The client cert source is determined in the following order:
|
| 149 |
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
| 150 |
+
client cert source is None.
|
| 151 |
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
| 152 |
+
default client cert source exists, use the default one; otherwise the client cert
|
| 153 |
+
source is None.
|
| 154 |
+
|
| 155 |
+
The API endpoint is determined in the following order:
|
| 156 |
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
| 157 |
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
| 158 |
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
| 159 |
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
| 160 |
+
use the default API endpoint.
|
| 161 |
+
|
| 162 |
+
More details can be found at https://google.aip.dev/auth/4114.
|
| 163 |
+
|
| 164 |
+
Args:
|
| 165 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 166 |
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
| 167 |
+
in this method.
|
| 168 |
+
|
| 169 |
+
Returns:
|
| 170 |
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
| 171 |
+
client cert source to use.
|
| 172 |
+
|
| 173 |
+
Raises:
|
| 174 |
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
| 175 |
+
"""
|
| 176 |
+
return SpeechClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
|
| 177 |
+
|
| 178 |
+
@property
|
| 179 |
+
def transport(self) -> SpeechTransport:
|
| 180 |
+
"""Returns the transport used by the client instance.
|
| 181 |
+
|
| 182 |
+
Returns:
|
| 183 |
+
SpeechTransport: The transport used by the client instance.
|
| 184 |
+
"""
|
| 185 |
+
return self._client.transport
|
| 186 |
+
|
| 187 |
+
@property
|
| 188 |
+
def api_endpoint(self) -> str:
|
| 189 |
+
"""Return the API endpoint used by the client instance.
|
| 190 |
+
|
| 191 |
+
Returns:
|
| 192 |
+
str: The API endpoint used by the client instance.
|
| 193 |
+
"""
|
| 194 |
+
return self._client._api_endpoint
|
| 195 |
+
|
| 196 |
+
@property
|
| 197 |
+
def universe_domain(self) -> str:
|
| 198 |
+
"""Return the universe domain used by the client instance.
|
| 199 |
+
|
| 200 |
+
Returns:
|
| 201 |
+
str: The universe domain used
|
| 202 |
+
by the client instance.
|
| 203 |
+
"""
|
| 204 |
+
return self._client._universe_domain
|
| 205 |
+
|
| 206 |
+
get_transport_class = SpeechClient.get_transport_class
|
| 207 |
+
|
| 208 |
+
def __init__(
|
| 209 |
+
self,
|
| 210 |
+
*,
|
| 211 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 212 |
+
transport: Optional[
|
| 213 |
+
Union[str, SpeechTransport, Callable[..., SpeechTransport]]
|
| 214 |
+
] = "grpc_asyncio",
|
| 215 |
+
client_options: Optional[ClientOptions] = None,
|
| 216 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 217 |
+
) -> None:
|
| 218 |
+
"""Instantiates the speech async client.
|
| 219 |
+
|
| 220 |
+
Args:
|
| 221 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 222 |
+
authorization credentials to attach to requests. These
|
| 223 |
+
credentials identify the application to the service; if none
|
| 224 |
+
are specified, the client will attempt to ascertain the
|
| 225 |
+
credentials from the environment.
|
| 226 |
+
transport (Optional[Union[str,SpeechTransport,Callable[..., SpeechTransport]]]):
|
| 227 |
+
The transport to use, or a Callable that constructs and returns a new transport to use.
|
| 228 |
+
If a Callable is given, it will be called with the same set of initialization
|
| 229 |
+
arguments as used in the SpeechTransport constructor.
|
| 230 |
+
If set to None, a transport is chosen automatically.
|
| 231 |
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
| 232 |
+
Custom options for the client.
|
| 233 |
+
|
| 234 |
+
1. The ``api_endpoint`` property can be used to override the
|
| 235 |
+
default endpoint provided by the client when ``transport`` is
|
| 236 |
+
not explicitly provided. Only if this property is not set and
|
| 237 |
+
``transport`` was not explicitly provided, the endpoint is
|
| 238 |
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
| 239 |
+
variable, which have one of the following values:
|
| 240 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 241 |
+
use the default regular endpoint) and "auto" (auto-switch to the
|
| 242 |
+
default mTLS endpoint if client certificate is present; this is
|
| 243 |
+
the default value).
|
| 244 |
+
|
| 245 |
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 246 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 247 |
+
to provide a client certificate for mTLS transport. If
|
| 248 |
+
not provided, the default SSL client certificate will be used if
|
| 249 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 250 |
+
set, no client certificate will be used.
|
| 251 |
+
|
| 252 |
+
3. The ``universe_domain`` property can be used to override the
|
| 253 |
+
default "googleapis.com" universe. Note that ``api_endpoint``
|
| 254 |
+
property still takes precedence; and ``universe_domain`` is
|
| 255 |
+
currently not supported for mTLS.
|
| 256 |
+
|
| 257 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 258 |
+
The client info used to send a user-agent string along with
|
| 259 |
+
API requests. If ``None``, then default info will be used.
|
| 260 |
+
Generally, you only need to set this if you're developing
|
| 261 |
+
your own client library.
|
| 262 |
+
|
| 263 |
+
Raises:
|
| 264 |
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
| 265 |
+
creation failed for any reason.
|
| 266 |
+
"""
|
| 267 |
+
self._client = SpeechClient(
|
| 268 |
+
credentials=credentials,
|
| 269 |
+
transport=transport,
|
| 270 |
+
client_options=client_options,
|
| 271 |
+
client_info=client_info,
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 275 |
+
std_logging.DEBUG
|
| 276 |
+
): # pragma: NO COVER
|
| 277 |
+
_LOGGER.debug(
|
| 278 |
+
"Created client `google.cloud.speech_v1.SpeechAsyncClient`.",
|
| 279 |
+
extra={
|
| 280 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 281 |
+
"universeDomain": getattr(
|
| 282 |
+
self._client._transport._credentials, "universe_domain", ""
|
| 283 |
+
),
|
| 284 |
+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
|
| 285 |
+
"credentialsInfo": getattr(
|
| 286 |
+
self.transport._credentials, "get_cred_info", lambda: None
|
| 287 |
+
)(),
|
| 288 |
+
}
|
| 289 |
+
if hasattr(self._client._transport, "_credentials")
|
| 290 |
+
else {
|
| 291 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 292 |
+
"credentialsType": None,
|
| 293 |
+
},
|
| 294 |
+
)
|
| 295 |
+
|
| 296 |
+
async def recognize(
|
| 297 |
+
self,
|
| 298 |
+
request: Optional[Union[cloud_speech.RecognizeRequest, dict]] = None,
|
| 299 |
+
*,
|
| 300 |
+
config: Optional[cloud_speech.RecognitionConfig] = None,
|
| 301 |
+
audio: Optional[cloud_speech.RecognitionAudio] = None,
|
| 302 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 303 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 304 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 305 |
+
) -> cloud_speech.RecognizeResponse:
|
| 306 |
+
r"""Performs synchronous speech recognition: receive
|
| 307 |
+
results after all audio has been sent and processed.
|
| 308 |
+
|
| 309 |
+
.. code-block:: python
|
| 310 |
+
|
| 311 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 312 |
+
# code template only.
|
| 313 |
+
# It will require modifications to work:
|
| 314 |
+
# - It may require correct/in-range values for request initialization.
|
| 315 |
+
# - It may require specifying regional endpoints when creating the service
|
| 316 |
+
# client as shown in:
|
| 317 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 318 |
+
from google.cloud import speech_v1
|
| 319 |
+
|
| 320 |
+
async def sample_recognize():
|
| 321 |
+
# Create a client
|
| 322 |
+
client = speech_v1.SpeechAsyncClient()
|
| 323 |
+
|
| 324 |
+
# Initialize request argument(s)
|
| 325 |
+
config = speech_v1.RecognitionConfig()
|
| 326 |
+
config.language_code = "language_code_value"
|
| 327 |
+
|
| 328 |
+
audio = speech_v1.RecognitionAudio()
|
| 329 |
+
audio.content = b'content_blob'
|
| 330 |
+
|
| 331 |
+
request = speech_v1.RecognizeRequest(
|
| 332 |
+
config=config,
|
| 333 |
+
audio=audio,
|
| 334 |
+
)
|
| 335 |
+
|
| 336 |
+
# Make the request
|
| 337 |
+
response = await client.recognize(request=request)
|
| 338 |
+
|
| 339 |
+
# Handle the response
|
| 340 |
+
print(response)
|
| 341 |
+
|
| 342 |
+
Args:
|
| 343 |
+
request (Optional[Union[google.cloud.speech_v1.types.RecognizeRequest, dict]]):
|
| 344 |
+
The request object. The top-level message sent by the client for the
|
| 345 |
+
``Recognize`` method.
|
| 346 |
+
config (:class:`google.cloud.speech_v1.types.RecognitionConfig`):
|
| 347 |
+
Required. Provides information to the
|
| 348 |
+
recognizer that specifies how to process
|
| 349 |
+
the request.
|
| 350 |
+
|
| 351 |
+
This corresponds to the ``config`` field
|
| 352 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 353 |
+
should not be set.
|
| 354 |
+
audio (:class:`google.cloud.speech_v1.types.RecognitionAudio`):
|
| 355 |
+
Required. The audio data to be
|
| 356 |
+
recognized.
|
| 357 |
+
|
| 358 |
+
This corresponds to the ``audio`` field
|
| 359 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 360 |
+
should not be set.
|
| 361 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 362 |
+
should be retried.
|
| 363 |
+
timeout (float): The timeout for this request.
|
| 364 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 365 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 366 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 367 |
+
be of type `bytes`.
|
| 368 |
+
|
| 369 |
+
Returns:
|
| 370 |
+
google.cloud.speech_v1.types.RecognizeResponse:
|
| 371 |
+
The only message returned to the client by the Recognize method. It
|
| 372 |
+
contains the result as zero or more sequential
|
| 373 |
+
SpeechRecognitionResult messages.
|
| 374 |
+
|
| 375 |
+
"""
|
| 376 |
+
# Create or coerce a protobuf request object.
|
| 377 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 378 |
+
# gotten any keyword arguments that map to the request.
|
| 379 |
+
flattened_params = [config, audio]
|
| 380 |
+
has_flattened_params = (
|
| 381 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 382 |
+
)
|
| 383 |
+
if request is not None and has_flattened_params:
|
| 384 |
+
raise ValueError(
|
| 385 |
+
"If the `request` argument is set, then none of "
|
| 386 |
+
"the individual field arguments should be set."
|
| 387 |
+
)
|
| 388 |
+
|
| 389 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 390 |
+
# there are no flattened fields), or create one.
|
| 391 |
+
if not isinstance(request, cloud_speech.RecognizeRequest):
|
| 392 |
+
request = cloud_speech.RecognizeRequest(request)
|
| 393 |
+
|
| 394 |
+
# If we have keyword arguments corresponding to fields on the
|
| 395 |
+
# request, apply these.
|
| 396 |
+
if config is not None:
|
| 397 |
+
request.config = config
|
| 398 |
+
if audio is not None:
|
| 399 |
+
request.audio = audio
|
| 400 |
+
|
| 401 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 402 |
+
# and friendly error handling.
|
| 403 |
+
rpc = self._client._transport._wrapped_methods[
|
| 404 |
+
self._client._transport.recognize
|
| 405 |
+
]
|
| 406 |
+
|
| 407 |
+
# Validate the universe domain.
|
| 408 |
+
self._client._validate_universe_domain()
|
| 409 |
+
|
| 410 |
+
# Send the request.
|
| 411 |
+
response = await rpc(
|
| 412 |
+
request,
|
| 413 |
+
retry=retry,
|
| 414 |
+
timeout=timeout,
|
| 415 |
+
metadata=metadata,
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
# Done; return the response.
|
| 419 |
+
return response
|
| 420 |
+
|
| 421 |
+
async def long_running_recognize(
|
| 422 |
+
self,
|
| 423 |
+
request: Optional[Union[cloud_speech.LongRunningRecognizeRequest, dict]] = None,
|
| 424 |
+
*,
|
| 425 |
+
config: Optional[cloud_speech.RecognitionConfig] = None,
|
| 426 |
+
audio: Optional[cloud_speech.RecognitionAudio] = None,
|
| 427 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 428 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 429 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 430 |
+
) -> operation_async.AsyncOperation:
|
| 431 |
+
r"""Performs asynchronous speech recognition: receive results via
|
| 432 |
+
the google.longrunning.Operations interface. Returns either an
|
| 433 |
+
``Operation.error`` or an ``Operation.response`` which contains
|
| 434 |
+
a ``LongRunningRecognizeResponse`` message. For more information
|
| 435 |
+
on asynchronous speech recognition, see the
|
| 436 |
+
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
|
| 437 |
+
|
| 438 |
+
.. code-block:: python
|
| 439 |
+
|
| 440 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 441 |
+
# code template only.
|
| 442 |
+
# It will require modifications to work:
|
| 443 |
+
# - It may require correct/in-range values for request initialization.
|
| 444 |
+
# - It may require specifying regional endpoints when creating the service
|
| 445 |
+
# client as shown in:
|
| 446 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 447 |
+
from google.cloud import speech_v1
|
| 448 |
+
|
| 449 |
+
async def sample_long_running_recognize():
|
| 450 |
+
# Create a client
|
| 451 |
+
client = speech_v1.SpeechAsyncClient()
|
| 452 |
+
|
| 453 |
+
# Initialize request argument(s)
|
| 454 |
+
config = speech_v1.RecognitionConfig()
|
| 455 |
+
config.language_code = "language_code_value"
|
| 456 |
+
|
| 457 |
+
audio = speech_v1.RecognitionAudio()
|
| 458 |
+
audio.content = b'content_blob'
|
| 459 |
+
|
| 460 |
+
request = speech_v1.LongRunningRecognizeRequest(
|
| 461 |
+
config=config,
|
| 462 |
+
audio=audio,
|
| 463 |
+
)
|
| 464 |
+
|
| 465 |
+
# Make the request
|
| 466 |
+
operation = client.long_running_recognize(request=request)
|
| 467 |
+
|
| 468 |
+
print("Waiting for operation to complete...")
|
| 469 |
+
|
| 470 |
+
response = (await operation).result()
|
| 471 |
+
|
| 472 |
+
# Handle the response
|
| 473 |
+
print(response)
|
| 474 |
+
|
| 475 |
+
Args:
|
| 476 |
+
request (Optional[Union[google.cloud.speech_v1.types.LongRunningRecognizeRequest, dict]]):
|
| 477 |
+
The request object. The top-level message sent by the client for the
|
| 478 |
+
``LongRunningRecognize`` method.
|
| 479 |
+
config (:class:`google.cloud.speech_v1.types.RecognitionConfig`):
|
| 480 |
+
Required. Provides information to the
|
| 481 |
+
recognizer that specifies how to process
|
| 482 |
+
the request.
|
| 483 |
+
|
| 484 |
+
This corresponds to the ``config`` field
|
| 485 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 486 |
+
should not be set.
|
| 487 |
+
audio (:class:`google.cloud.speech_v1.types.RecognitionAudio`):
|
| 488 |
+
Required. The audio data to be
|
| 489 |
+
recognized.
|
| 490 |
+
|
| 491 |
+
This corresponds to the ``audio`` field
|
| 492 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 493 |
+
should not be set.
|
| 494 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 495 |
+
should be retried.
|
| 496 |
+
timeout (float): The timeout for this request.
|
| 497 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 498 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 499 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 500 |
+
be of type `bytes`.
|
| 501 |
+
|
| 502 |
+
Returns:
|
| 503 |
+
google.api_core.operation_async.AsyncOperation:
|
| 504 |
+
An object representing a long-running operation.
|
| 505 |
+
|
| 506 |
+
The result type for the operation will be :class:`google.cloud.speech_v1.types.LongRunningRecognizeResponse` The only message returned to the client by the LongRunningRecognize method.
|
| 507 |
+
It contains the result as zero or more sequential
|
| 508 |
+
SpeechRecognitionResult messages. It is included in
|
| 509 |
+
the result.response field of the Operation returned
|
| 510 |
+
by the GetOperation call of the
|
| 511 |
+
google::longrunning::Operations service.
|
| 512 |
+
|
| 513 |
+
"""
|
| 514 |
+
# Create or coerce a protobuf request object.
|
| 515 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 516 |
+
# gotten any keyword arguments that map to the request.
|
| 517 |
+
flattened_params = [config, audio]
|
| 518 |
+
has_flattened_params = (
|
| 519 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 520 |
+
)
|
| 521 |
+
if request is not None and has_flattened_params:
|
| 522 |
+
raise ValueError(
|
| 523 |
+
"If the `request` argument is set, then none of "
|
| 524 |
+
"the individual field arguments should be set."
|
| 525 |
+
)
|
| 526 |
+
|
| 527 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 528 |
+
# there are no flattened fields), or create one.
|
| 529 |
+
if not isinstance(request, cloud_speech.LongRunningRecognizeRequest):
|
| 530 |
+
request = cloud_speech.LongRunningRecognizeRequest(request)
|
| 531 |
+
|
| 532 |
+
# If we have keyword arguments corresponding to fields on the
|
| 533 |
+
# request, apply these.
|
| 534 |
+
if config is not None:
|
| 535 |
+
request.config = config
|
| 536 |
+
if audio is not None:
|
| 537 |
+
request.audio = audio
|
| 538 |
+
|
| 539 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 540 |
+
# and friendly error handling.
|
| 541 |
+
rpc = self._client._transport._wrapped_methods[
|
| 542 |
+
self._client._transport.long_running_recognize
|
| 543 |
+
]
|
| 544 |
+
|
| 545 |
+
# Validate the universe domain.
|
| 546 |
+
self._client._validate_universe_domain()
|
| 547 |
+
|
| 548 |
+
# Send the request.
|
| 549 |
+
response = await rpc(
|
| 550 |
+
request,
|
| 551 |
+
retry=retry,
|
| 552 |
+
timeout=timeout,
|
| 553 |
+
metadata=metadata,
|
| 554 |
+
)
|
| 555 |
+
|
| 556 |
+
# Wrap the response in an operation future.
|
| 557 |
+
response = operation_async.from_gapic(
|
| 558 |
+
response,
|
| 559 |
+
self._client._transport.operations_client,
|
| 560 |
+
cloud_speech.LongRunningRecognizeResponse,
|
| 561 |
+
metadata_type=cloud_speech.LongRunningRecognizeMetadata,
|
| 562 |
+
)
|
| 563 |
+
|
| 564 |
+
# Done; return the response.
|
| 565 |
+
return response
|
| 566 |
+
|
| 567 |
+
def streaming_recognize(
|
| 568 |
+
self,
|
| 569 |
+
requests: Optional[
|
| 570 |
+
AsyncIterator[cloud_speech.StreamingRecognizeRequest]
|
| 571 |
+
] = None,
|
| 572 |
+
*,
|
| 573 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 574 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 575 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 576 |
+
) -> Awaitable[AsyncIterable[cloud_speech.StreamingRecognizeResponse]]:
|
| 577 |
+
r"""Performs bidirectional streaming speech recognition:
|
| 578 |
+
receive results while sending audio. This method is only
|
| 579 |
+
available via the gRPC API (not REST).
|
| 580 |
+
|
| 581 |
+
.. code-block:: python
|
| 582 |
+
|
| 583 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 584 |
+
# code template only.
|
| 585 |
+
# It will require modifications to work:
|
| 586 |
+
# - It may require correct/in-range values for request initialization.
|
| 587 |
+
# - It may require specifying regional endpoints when creating the service
|
| 588 |
+
# client as shown in:
|
| 589 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 590 |
+
from google.cloud import speech_v1
|
| 591 |
+
|
| 592 |
+
async def sample_streaming_recognize():
|
| 593 |
+
# Create a client
|
| 594 |
+
client = speech_v1.SpeechAsyncClient()
|
| 595 |
+
|
| 596 |
+
# Initialize request argument(s)
|
| 597 |
+
streaming_config = speech_v1.StreamingRecognitionConfig()
|
| 598 |
+
streaming_config.config.language_code = "language_code_value"
|
| 599 |
+
|
| 600 |
+
request = speech_v1.StreamingRecognizeRequest(
|
| 601 |
+
streaming_config=streaming_config,
|
| 602 |
+
)
|
| 603 |
+
|
| 604 |
+
# This method expects an iterator which contains
|
| 605 |
+
# 'speech_v1.StreamingRecognizeRequest' objects
|
| 606 |
+
# Here we create a generator that yields a single `request` for
|
| 607 |
+
# demonstrative purposes.
|
| 608 |
+
requests = [request]
|
| 609 |
+
|
| 610 |
+
def request_generator():
|
| 611 |
+
for request in requests:
|
| 612 |
+
yield request
|
| 613 |
+
|
| 614 |
+
# Make the request
|
| 615 |
+
stream = await client.streaming_recognize(requests=request_generator())
|
| 616 |
+
|
| 617 |
+
# Handle the response
|
| 618 |
+
async for response in stream:
|
| 619 |
+
print(response)
|
| 620 |
+
|
| 621 |
+
Args:
|
| 622 |
+
requests (AsyncIterator[`google.cloud.speech_v1.types.StreamingRecognizeRequest`]):
|
| 623 |
+
The request object AsyncIterator. The top-level message sent by the client for the
|
| 624 |
+
``StreamingRecognize`` method. Multiple
|
| 625 |
+
``StreamingRecognizeRequest`` messages are sent. The
|
| 626 |
+
first message must contain a ``streaming_config``
|
| 627 |
+
message and must not contain ``audio_content``. All
|
| 628 |
+
subsequent messages must contain ``audio_content`` and
|
| 629 |
+
must not contain a ``streaming_config`` message.
|
| 630 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 631 |
+
should be retried.
|
| 632 |
+
timeout (float): The timeout for this request.
|
| 633 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 634 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 635 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 636 |
+
be of type `bytes`.
|
| 637 |
+
|
| 638 |
+
Returns:
|
| 639 |
+
AsyncIterable[google.cloud.speech_v1.types.StreamingRecognizeResponse]:
|
| 640 |
+
StreamingRecognizeResponse is the only message returned to the client by
|
| 641 |
+
StreamingRecognize. A series of zero or more
|
| 642 |
+
StreamingRecognizeResponse messages are streamed back
|
| 643 |
+
to the client. If there is no recognizable audio, and
|
| 644 |
+
single_utterance is set to false, then no messages
|
| 645 |
+
are streamed back to the client.
|
| 646 |
+
|
| 647 |
+
Here's an example of a series of
|
| 648 |
+
\`StreamingRecognizeResponse`s that might be returned
|
| 649 |
+
while processing audio:
|
| 650 |
+
|
| 651 |
+
1. results { alternatives { transcript: "tube" }
|
| 652 |
+
stability: 0.01 }
|
| 653 |
+
|
| 654 |
+
2. results { alternatives { transcript: "to be a" }
|
| 655 |
+
stability: 0.01 }
|
| 656 |
+
|
| 657 |
+
3. results { alternatives { transcript: "to be" }
|
| 658 |
+
stability: 0.9 } results { alternatives {
|
| 659 |
+
transcript: " or not to be" } stability: 0.01 }
|
| 660 |
+
|
| 661 |
+
4.
|
| 662 |
+
|
| 663 |
+
results { alternatives { transcript: "to be or not to be"
|
| 664 |
+
confidence: 0.92 } alternatives { transcript:
|
| 665 |
+
"to bee or not to bee" } is_final: true }
|
| 666 |
+
|
| 667 |
+
5. results { alternatives { transcript: " that's" }
|
| 668 |
+
stability: 0.01 }
|
| 669 |
+
|
| 670 |
+
6. results { alternatives { transcript: " that is" }
|
| 671 |
+
stability: 0.9 } results { alternatives {
|
| 672 |
+
transcript: " the question" } stability: 0.01 }
|
| 673 |
+
|
| 674 |
+
7.
|
| 675 |
+
|
| 676 |
+
results { alternatives { transcript: " that is the question"
|
| 677 |
+
confidence: 0.98 } alternatives { transcript: "
|
| 678 |
+
that was the question" } is_final: true }
|
| 679 |
+
|
| 680 |
+
Notes:
|
| 681 |
+
|
| 682 |
+
- Only two of the above responses #4 and #7 contain
|
| 683 |
+
final results; they are indicated by is_final:
|
| 684 |
+
true. Concatenating these together generates the
|
| 685 |
+
full transcript: "to be or not to be that is the
|
| 686 |
+
question".
|
| 687 |
+
|
| 688 |
+
- The others contain interim results. #3 and #6
|
| 689 |
+
contain two interim \`results\`: the first portion
|
| 690 |
+
has a high stability and is less likely to change;
|
| 691 |
+
the second portion has a low stability and is very
|
| 692 |
+
likely to change. A UI designer might choose to
|
| 693 |
+
show only high stability results.
|
| 694 |
+
|
| 695 |
+
- The specific stability and confidence values shown
|
| 696 |
+
above are only for illustrative purposes. Actual
|
| 697 |
+
values may vary.
|
| 698 |
+
|
| 699 |
+
-
|
| 700 |
+
|
| 701 |
+
In each response, only one of these fields will be set:
|
| 702 |
+
error, speech_event_type, or one or more
|
| 703 |
+
(repeated) results.
|
| 704 |
+
|
| 705 |
+
"""
|
| 706 |
+
|
| 707 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 708 |
+
# and friendly error handling.
|
| 709 |
+
rpc = self._client._transport._wrapped_methods[
|
| 710 |
+
self._client._transport.streaming_recognize
|
| 711 |
+
]
|
| 712 |
+
|
| 713 |
+
# Validate the universe domain.
|
| 714 |
+
self._client._validate_universe_domain()
|
| 715 |
+
|
| 716 |
+
# Send the request.
|
| 717 |
+
response = rpc(
|
| 718 |
+
requests,
|
| 719 |
+
retry=retry,
|
| 720 |
+
timeout=timeout,
|
| 721 |
+
metadata=metadata,
|
| 722 |
+
)
|
| 723 |
+
|
| 724 |
+
# Done; return the response.
|
| 725 |
+
return response
|
| 726 |
+
|
| 727 |
+
async def list_operations(
|
| 728 |
+
self,
|
| 729 |
+
request: Optional[Union[operations_pb2.ListOperationsRequest, dict]] = None,
|
| 730 |
+
*,
|
| 731 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 732 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 733 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 734 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 735 |
+
r"""Lists operations that match the specified filter in the request.
|
| 736 |
+
|
| 737 |
+
Args:
|
| 738 |
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
| 739 |
+
The request object. Request message for
|
| 740 |
+
`ListOperations` method.
|
| 741 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
| 742 |
+
if any, should be retried.
|
| 743 |
+
timeout (float): The timeout for this request.
|
| 744 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 745 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 746 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 747 |
+
be of type `bytes`.
|
| 748 |
+
Returns:
|
| 749 |
+
~.operations_pb2.ListOperationsResponse:
|
| 750 |
+
Response message for ``ListOperations`` method.
|
| 751 |
+
"""
|
| 752 |
+
# Create or coerce a protobuf request object.
|
| 753 |
+
# The request isn't a proto-plus wrapped type,
|
| 754 |
+
# so it must be constructed via keyword expansion.
|
| 755 |
+
if request is None:
|
| 756 |
+
request_pb = operations_pb2.ListOperationsRequest()
|
| 757 |
+
elif isinstance(request, dict):
|
| 758 |
+
request_pb = operations_pb2.ListOperationsRequest(**request)
|
| 759 |
+
else:
|
| 760 |
+
request_pb = request
|
| 761 |
+
|
| 762 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 763 |
+
# and friendly error handling.
|
| 764 |
+
rpc = self.transport._wrapped_methods[self._client._transport.list_operations]
|
| 765 |
+
|
| 766 |
+
# Certain fields should be provided within the metadata header;
|
| 767 |
+
# add these here.
|
| 768 |
+
metadata = tuple(metadata) + (
|
| 769 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 770 |
+
)
|
| 771 |
+
|
| 772 |
+
# Validate the universe domain.
|
| 773 |
+
self._client._validate_universe_domain()
|
| 774 |
+
|
| 775 |
+
# Send the request.
|
| 776 |
+
response = await rpc(
|
| 777 |
+
request_pb,
|
| 778 |
+
retry=retry,
|
| 779 |
+
timeout=timeout,
|
| 780 |
+
metadata=metadata,
|
| 781 |
+
)
|
| 782 |
+
|
| 783 |
+
# Done; return the response.
|
| 784 |
+
return response
|
| 785 |
+
|
| 786 |
+
async def get_operation(
|
| 787 |
+
self,
|
| 788 |
+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
|
| 789 |
+
*,
|
| 790 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 791 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 792 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 793 |
+
) -> operations_pb2.Operation:
|
| 794 |
+
r"""Gets the latest state of a long-running operation.
|
| 795 |
+
|
| 796 |
+
Args:
|
| 797 |
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
| 798 |
+
The request object. Request message for
|
| 799 |
+
`GetOperation` method.
|
| 800 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
| 801 |
+
if any, should be retried.
|
| 802 |
+
timeout (float): The timeout for this request.
|
| 803 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 804 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 805 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 806 |
+
be of type `bytes`.
|
| 807 |
+
Returns:
|
| 808 |
+
~.operations_pb2.Operation:
|
| 809 |
+
An ``Operation`` object.
|
| 810 |
+
"""
|
| 811 |
+
# Create or coerce a protobuf request object.
|
| 812 |
+
# The request isn't a proto-plus wrapped type,
|
| 813 |
+
# so it must be constructed via keyword expansion.
|
| 814 |
+
if request is None:
|
| 815 |
+
request_pb = operations_pb2.GetOperationRequest()
|
| 816 |
+
elif isinstance(request, dict):
|
| 817 |
+
request_pb = operations_pb2.GetOperationRequest(**request)
|
| 818 |
+
else:
|
| 819 |
+
request_pb = request
|
| 820 |
+
|
| 821 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 822 |
+
# and friendly error handling.
|
| 823 |
+
rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
|
| 824 |
+
|
| 825 |
+
# Certain fields should be provided within the metadata header;
|
| 826 |
+
# add these here.
|
| 827 |
+
metadata = tuple(metadata) + (
|
| 828 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 829 |
+
)
|
| 830 |
+
|
| 831 |
+
# Validate the universe domain.
|
| 832 |
+
self._client._validate_universe_domain()
|
| 833 |
+
|
| 834 |
+
# Send the request.
|
| 835 |
+
response = await rpc(
|
| 836 |
+
request_pb,
|
| 837 |
+
retry=retry,
|
| 838 |
+
timeout=timeout,
|
| 839 |
+
metadata=metadata,
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
# Done; return the response.
|
| 843 |
+
return response
|
| 844 |
+
|
| 845 |
+
async def __aenter__(self) -> "SpeechAsyncClient":
|
| 846 |
+
return self
|
| 847 |
+
|
| 848 |
+
async def __aexit__(self, exc_type, exc, tb):
|
| 849 |
+
await self.transport.close()
|
| 850 |
+
|
| 851 |
+
|
| 852 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 853 |
+
gapic_version=package_version.__version__
|
| 854 |
+
)
|
| 855 |
+
|
| 856 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 857 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 858 |
+
|
| 859 |
+
|
| 860 |
+
__all__ = ("SpeechAsyncClient",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/client.py
ADDED
|
@@ -0,0 +1,1324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json
|
| 17 |
+
import logging as std_logging
|
| 18 |
+
import os
|
| 19 |
+
import re
|
| 20 |
+
import warnings
|
| 21 |
+
from collections import OrderedDict
|
| 22 |
+
from http import HTTPStatus
|
| 23 |
+
from typing import (
|
| 24 |
+
Callable,
|
| 25 |
+
Dict,
|
| 26 |
+
Iterable,
|
| 27 |
+
Iterator,
|
| 28 |
+
Mapping,
|
| 29 |
+
MutableMapping,
|
| 30 |
+
MutableSequence,
|
| 31 |
+
Optional,
|
| 32 |
+
Sequence,
|
| 33 |
+
Tuple,
|
| 34 |
+
Type,
|
| 35 |
+
Union,
|
| 36 |
+
cast,
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
import google.protobuf
|
| 40 |
+
from google.api_core import client_options as client_options_lib
|
| 41 |
+
from google.api_core import exceptions as core_exceptions
|
| 42 |
+
from google.api_core import gapic_v1
|
| 43 |
+
from google.api_core import retry as retries
|
| 44 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 45 |
+
from google.auth.exceptions import MutualTLSChannelError # type: ignore
|
| 46 |
+
from google.auth.transport import mtls # type: ignore
|
| 47 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 48 |
+
from google.oauth2 import service_account # type: ignore
|
| 49 |
+
|
| 50 |
+
from google.cloud.speech_v1 import gapic_version as package_version
|
| 51 |
+
|
| 52 |
+
try:
|
| 53 |
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
| 54 |
+
except AttributeError: # pragma: NO COVER
|
| 55 |
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
from google.api_core import client_logging # type: ignore
|
| 59 |
+
|
| 60 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 61 |
+
except ImportError: # pragma: NO COVER
|
| 62 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 63 |
+
|
| 64 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 65 |
+
|
| 66 |
+
import google.api_core.operation as operation # type: ignore
|
| 67 |
+
import google.api_core.operation_async as operation_async # type: ignore
|
| 68 |
+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
|
| 69 |
+
import google.rpc.status_pb2 as status_pb2 # type: ignore
|
| 70 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 71 |
+
|
| 72 |
+
from google.cloud.speech_v1.types import cloud_speech
|
| 73 |
+
|
| 74 |
+
from .transports.base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 75 |
+
from .transports.grpc import SpeechGrpcTransport
|
| 76 |
+
from .transports.grpc_asyncio import SpeechGrpcAsyncIOTransport
|
| 77 |
+
from .transports.rest import SpeechRestTransport
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class SpeechClientMeta(type):
|
| 81 |
+
"""Metaclass for the Speech client.
|
| 82 |
+
|
| 83 |
+
This provides class-level methods for building and retrieving
|
| 84 |
+
support objects (e.g. transport) without polluting the client instance
|
| 85 |
+
objects.
|
| 86 |
+
"""
|
| 87 |
+
|
| 88 |
+
_transport_registry = OrderedDict() # type: Dict[str, Type[SpeechTransport]]
|
| 89 |
+
_transport_registry["grpc"] = SpeechGrpcTransport
|
| 90 |
+
_transport_registry["grpc_asyncio"] = SpeechGrpcAsyncIOTransport
|
| 91 |
+
_transport_registry["rest"] = SpeechRestTransport
|
| 92 |
+
|
| 93 |
+
def get_transport_class(
|
| 94 |
+
cls,
|
| 95 |
+
label: Optional[str] = None,
|
| 96 |
+
) -> Type[SpeechTransport]:
|
| 97 |
+
"""Returns an appropriate transport class.
|
| 98 |
+
|
| 99 |
+
Args:
|
| 100 |
+
label: The name of the desired transport. If none is
|
| 101 |
+
provided, then the first transport in the registry is used.
|
| 102 |
+
|
| 103 |
+
Returns:
|
| 104 |
+
The transport class to use.
|
| 105 |
+
"""
|
| 106 |
+
# If a specific transport is requested, return that one.
|
| 107 |
+
if label:
|
| 108 |
+
return cls._transport_registry[label]
|
| 109 |
+
|
| 110 |
+
# No transport is requested; return the default (that is, the first one
|
| 111 |
+
# in the dictionary).
|
| 112 |
+
return next(iter(cls._transport_registry.values()))
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
class SpeechClient(metaclass=SpeechClientMeta):
|
| 116 |
+
"""Service that implements Google Cloud Speech API."""
|
| 117 |
+
|
| 118 |
+
@staticmethod
|
| 119 |
+
def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
|
| 120 |
+
"""Converts api endpoint to mTLS endpoint.
|
| 121 |
+
|
| 122 |
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
| 123 |
+
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
| 124 |
+
Args:
|
| 125 |
+
api_endpoint (Optional[str]): the api endpoint to convert.
|
| 126 |
+
Returns:
|
| 127 |
+
Optional[str]: converted mTLS api endpoint.
|
| 128 |
+
"""
|
| 129 |
+
if not api_endpoint:
|
| 130 |
+
return api_endpoint
|
| 131 |
+
|
| 132 |
+
mtls_endpoint_re = re.compile(
|
| 133 |
+
r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
m = mtls_endpoint_re.match(api_endpoint)
|
| 137 |
+
if m is None:
|
| 138 |
+
# Could not parse api_endpoint; return as-is.
|
| 139 |
+
return api_endpoint
|
| 140 |
+
|
| 141 |
+
name, mtls, sandbox, googledomain = m.groups()
|
| 142 |
+
if mtls or not googledomain:
|
| 143 |
+
return api_endpoint
|
| 144 |
+
|
| 145 |
+
if sandbox:
|
| 146 |
+
return api_endpoint.replace(
|
| 147 |
+
"sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
|
| 151 |
+
|
| 152 |
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
| 153 |
+
DEFAULT_ENDPOINT = "speech.googleapis.com"
|
| 154 |
+
DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
|
| 155 |
+
DEFAULT_ENDPOINT
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
_DEFAULT_ENDPOINT_TEMPLATE = "speech.{UNIVERSE_DOMAIN}"
|
| 159 |
+
_DEFAULT_UNIVERSE = "googleapis.com"
|
| 160 |
+
|
| 161 |
+
@staticmethod
|
| 162 |
+
def _use_client_cert_effective():
|
| 163 |
+
"""Returns whether client certificate should be used for mTLS if the
|
| 164 |
+
google-auth version supports should_use_client_cert automatic mTLS enablement.
|
| 165 |
+
|
| 166 |
+
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
|
| 167 |
+
|
| 168 |
+
Returns:
|
| 169 |
+
bool: whether client certificate should be used for mTLS
|
| 170 |
+
Raises:
|
| 171 |
+
ValueError: (If using a version of google-auth without should_use_client_cert and
|
| 172 |
+
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
|
| 173 |
+
"""
|
| 174 |
+
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
|
| 175 |
+
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
|
| 176 |
+
return mtls.should_use_client_cert()
|
| 177 |
+
else: # pragma: NO COVER
|
| 178 |
+
# if unsupported, fallback to reading from env var
|
| 179 |
+
use_client_cert_str = os.getenv(
|
| 180 |
+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
| 181 |
+
).lower()
|
| 182 |
+
if use_client_cert_str not in ("true", "false"):
|
| 183 |
+
raise ValueError(
|
| 184 |
+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
|
| 185 |
+
" either `true` or `false`"
|
| 186 |
+
)
|
| 187 |
+
return use_client_cert_str == "true"
|
| 188 |
+
|
| 189 |
+
@classmethod
|
| 190 |
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
| 191 |
+
"""Creates an instance of this client using the provided credentials
|
| 192 |
+
info.
|
| 193 |
+
|
| 194 |
+
Args:
|
| 195 |
+
info (dict): The service account private key info.
|
| 196 |
+
args: Additional arguments to pass to the constructor.
|
| 197 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 198 |
+
|
| 199 |
+
Returns:
|
| 200 |
+
SpeechClient: The constructed client.
|
| 201 |
+
"""
|
| 202 |
+
credentials = service_account.Credentials.from_service_account_info(info)
|
| 203 |
+
kwargs["credentials"] = credentials
|
| 204 |
+
return cls(*args, **kwargs)
|
| 205 |
+
|
| 206 |
+
@classmethod
|
| 207 |
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
| 208 |
+
"""Creates an instance of this client using the provided credentials
|
| 209 |
+
file.
|
| 210 |
+
|
| 211 |
+
Args:
|
| 212 |
+
filename (str): The path to the service account private key json
|
| 213 |
+
file.
|
| 214 |
+
args: Additional arguments to pass to the constructor.
|
| 215 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 216 |
+
|
| 217 |
+
Returns:
|
| 218 |
+
SpeechClient: The constructed client.
|
| 219 |
+
"""
|
| 220 |
+
credentials = service_account.Credentials.from_service_account_file(filename)
|
| 221 |
+
kwargs["credentials"] = credentials
|
| 222 |
+
return cls(*args, **kwargs)
|
| 223 |
+
|
| 224 |
+
from_service_account_json = from_service_account_file
|
| 225 |
+
|
| 226 |
+
@property
|
| 227 |
+
def transport(self) -> SpeechTransport:
|
| 228 |
+
"""Returns the transport used by the client instance.
|
| 229 |
+
|
| 230 |
+
Returns:
|
| 231 |
+
SpeechTransport: The transport used by the client
|
| 232 |
+
instance.
|
| 233 |
+
"""
|
| 234 |
+
return self._transport
|
| 235 |
+
|
| 236 |
+
@staticmethod
|
| 237 |
+
def custom_class_path(
|
| 238 |
+
project: str,
|
| 239 |
+
location: str,
|
| 240 |
+
custom_class: str,
|
| 241 |
+
) -> str:
|
| 242 |
+
"""Returns a fully-qualified custom_class string."""
|
| 243 |
+
return "projects/{project}/locations/{location}/customClasses/{custom_class}".format(
|
| 244 |
+
project=project,
|
| 245 |
+
location=location,
|
| 246 |
+
custom_class=custom_class,
|
| 247 |
+
)
|
| 248 |
+
|
| 249 |
+
@staticmethod
|
| 250 |
+
def parse_custom_class_path(path: str) -> Dict[str, str]:
|
| 251 |
+
"""Parses a custom_class path into its component segments."""
|
| 252 |
+
m = re.match(
|
| 253 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/customClasses/(?P<custom_class>.+?)$",
|
| 254 |
+
path,
|
| 255 |
+
)
|
| 256 |
+
return m.groupdict() if m else {}
|
| 257 |
+
|
| 258 |
+
@staticmethod
|
| 259 |
+
def phrase_set_path(
|
| 260 |
+
project: str,
|
| 261 |
+
location: str,
|
| 262 |
+
phrase_set: str,
|
| 263 |
+
) -> str:
|
| 264 |
+
"""Returns a fully-qualified phrase_set string."""
|
| 265 |
+
return "projects/{project}/locations/{location}/phraseSets/{phrase_set}".format(
|
| 266 |
+
project=project,
|
| 267 |
+
location=location,
|
| 268 |
+
phrase_set=phrase_set,
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
@staticmethod
|
| 272 |
+
def parse_phrase_set_path(path: str) -> Dict[str, str]:
|
| 273 |
+
"""Parses a phrase_set path into its component segments."""
|
| 274 |
+
m = re.match(
|
| 275 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/phraseSets/(?P<phrase_set>.+?)$",
|
| 276 |
+
path,
|
| 277 |
+
)
|
| 278 |
+
return m.groupdict() if m else {}
|
| 279 |
+
|
| 280 |
+
@staticmethod
|
| 281 |
+
def common_billing_account_path(
|
| 282 |
+
billing_account: str,
|
| 283 |
+
) -> str:
|
| 284 |
+
"""Returns a fully-qualified billing_account string."""
|
| 285 |
+
return "billingAccounts/{billing_account}".format(
|
| 286 |
+
billing_account=billing_account,
|
| 287 |
+
)
|
| 288 |
+
|
| 289 |
+
@staticmethod
|
| 290 |
+
def parse_common_billing_account_path(path: str) -> Dict[str, str]:
|
| 291 |
+
"""Parse a billing_account path into its component segments."""
|
| 292 |
+
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
|
| 293 |
+
return m.groupdict() if m else {}
|
| 294 |
+
|
| 295 |
+
@staticmethod
|
| 296 |
+
def common_folder_path(
|
| 297 |
+
folder: str,
|
| 298 |
+
) -> str:
|
| 299 |
+
"""Returns a fully-qualified folder string."""
|
| 300 |
+
return "folders/{folder}".format(
|
| 301 |
+
folder=folder,
|
| 302 |
+
)
|
| 303 |
+
|
| 304 |
+
@staticmethod
|
| 305 |
+
def parse_common_folder_path(path: str) -> Dict[str, str]:
|
| 306 |
+
"""Parse a folder path into its component segments."""
|
| 307 |
+
m = re.match(r"^folders/(?P<folder>.+?)$", path)
|
| 308 |
+
return m.groupdict() if m else {}
|
| 309 |
+
|
| 310 |
+
@staticmethod
|
| 311 |
+
def common_organization_path(
|
| 312 |
+
organization: str,
|
| 313 |
+
) -> str:
|
| 314 |
+
"""Returns a fully-qualified organization string."""
|
| 315 |
+
return "organizations/{organization}".format(
|
| 316 |
+
organization=organization,
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
+
@staticmethod
|
| 320 |
+
def parse_common_organization_path(path: str) -> Dict[str, str]:
|
| 321 |
+
"""Parse a organization path into its component segments."""
|
| 322 |
+
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
|
| 323 |
+
return m.groupdict() if m else {}
|
| 324 |
+
|
| 325 |
+
@staticmethod
|
| 326 |
+
def common_project_path(
|
| 327 |
+
project: str,
|
| 328 |
+
) -> str:
|
| 329 |
+
"""Returns a fully-qualified project string."""
|
| 330 |
+
return "projects/{project}".format(
|
| 331 |
+
project=project,
|
| 332 |
+
)
|
| 333 |
+
|
| 334 |
+
@staticmethod
|
| 335 |
+
def parse_common_project_path(path: str) -> Dict[str, str]:
|
| 336 |
+
"""Parse a project path into its component segments."""
|
| 337 |
+
m = re.match(r"^projects/(?P<project>.+?)$", path)
|
| 338 |
+
return m.groupdict() if m else {}
|
| 339 |
+
|
| 340 |
+
@staticmethod
|
| 341 |
+
def common_location_path(
|
| 342 |
+
project: str,
|
| 343 |
+
location: str,
|
| 344 |
+
) -> str:
|
| 345 |
+
"""Returns a fully-qualified location string."""
|
| 346 |
+
return "projects/{project}/locations/{location}".format(
|
| 347 |
+
project=project,
|
| 348 |
+
location=location,
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
+
@staticmethod
|
| 352 |
+
def parse_common_location_path(path: str) -> Dict[str, str]:
|
| 353 |
+
"""Parse a location path into its component segments."""
|
| 354 |
+
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
|
| 355 |
+
return m.groupdict() if m else {}
|
| 356 |
+
|
| 357 |
+
@classmethod
|
| 358 |
+
def get_mtls_endpoint_and_cert_source(
|
| 359 |
+
cls, client_options: Optional[client_options_lib.ClientOptions] = None
|
| 360 |
+
):
|
| 361 |
+
"""Deprecated. Return the API endpoint and client cert source for mutual TLS.
|
| 362 |
+
|
| 363 |
+
The client cert source is determined in the following order:
|
| 364 |
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
| 365 |
+
client cert source is None.
|
| 366 |
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
| 367 |
+
default client cert source exists, use the default one; otherwise the client cert
|
| 368 |
+
source is None.
|
| 369 |
+
|
| 370 |
+
The API endpoint is determined in the following order:
|
| 371 |
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
| 372 |
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
| 373 |
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
| 374 |
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
| 375 |
+
use the default API endpoint.
|
| 376 |
+
|
| 377 |
+
More details can be found at https://google.aip.dev/auth/4114.
|
| 378 |
+
|
| 379 |
+
Args:
|
| 380 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 381 |
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
| 382 |
+
in this method.
|
| 383 |
+
|
| 384 |
+
Returns:
|
| 385 |
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
| 386 |
+
client cert source to use.
|
| 387 |
+
|
| 388 |
+
Raises:
|
| 389 |
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
| 390 |
+
"""
|
| 391 |
+
|
| 392 |
+
warnings.warn(
|
| 393 |
+
"get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
|
| 394 |
+
DeprecationWarning,
|
| 395 |
+
)
|
| 396 |
+
if client_options is None:
|
| 397 |
+
client_options = client_options_lib.ClientOptions()
|
| 398 |
+
use_client_cert = SpeechClient._use_client_cert_effective()
|
| 399 |
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
|
| 400 |
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
| 401 |
+
raise MutualTLSChannelError(
|
| 402 |
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
# Figure out the client cert source to use.
|
| 406 |
+
client_cert_source = None
|
| 407 |
+
if use_client_cert:
|
| 408 |
+
if client_options.client_cert_source:
|
| 409 |
+
client_cert_source = client_options.client_cert_source
|
| 410 |
+
elif mtls.has_default_client_cert_source():
|
| 411 |
+
client_cert_source = mtls.default_client_cert_source()
|
| 412 |
+
|
| 413 |
+
# Figure out which api endpoint to use.
|
| 414 |
+
if client_options.api_endpoint is not None:
|
| 415 |
+
api_endpoint = client_options.api_endpoint
|
| 416 |
+
elif use_mtls_endpoint == "always" or (
|
| 417 |
+
use_mtls_endpoint == "auto" and client_cert_source
|
| 418 |
+
):
|
| 419 |
+
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
|
| 420 |
+
else:
|
| 421 |
+
api_endpoint = cls.DEFAULT_ENDPOINT
|
| 422 |
+
|
| 423 |
+
return api_endpoint, client_cert_source
|
| 424 |
+
|
| 425 |
+
@staticmethod
|
| 426 |
+
def _read_environment_variables():
|
| 427 |
+
"""Returns the environment variables used by the client.
|
| 428 |
+
|
| 429 |
+
Returns:
|
| 430 |
+
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
|
| 431 |
+
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
|
| 432 |
+
|
| 433 |
+
Raises:
|
| 434 |
+
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
|
| 435 |
+
any of ["true", "false"].
|
| 436 |
+
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
| 437 |
+
is not any of ["auto", "never", "always"].
|
| 438 |
+
"""
|
| 439 |
+
use_client_cert = SpeechClient._use_client_cert_effective()
|
| 440 |
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
| 441 |
+
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
| 442 |
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
| 443 |
+
raise MutualTLSChannelError(
|
| 444 |
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
| 445 |
+
)
|
| 446 |
+
return use_client_cert, use_mtls_endpoint, universe_domain_env
|
| 447 |
+
|
| 448 |
+
@staticmethod
|
| 449 |
+
def _get_client_cert_source(provided_cert_source, use_cert_flag):
|
| 450 |
+
"""Return the client cert source to be used by the client.
|
| 451 |
+
|
| 452 |
+
Args:
|
| 453 |
+
provided_cert_source (bytes): The client certificate source provided.
|
| 454 |
+
use_cert_flag (bool): A flag indicating whether to use the client certificate.
|
| 455 |
+
|
| 456 |
+
Returns:
|
| 457 |
+
bytes or None: The client cert source to be used by the client.
|
| 458 |
+
"""
|
| 459 |
+
client_cert_source = None
|
| 460 |
+
if use_cert_flag:
|
| 461 |
+
if provided_cert_source:
|
| 462 |
+
client_cert_source = provided_cert_source
|
| 463 |
+
elif mtls.has_default_client_cert_source():
|
| 464 |
+
client_cert_source = mtls.default_client_cert_source()
|
| 465 |
+
return client_cert_source
|
| 466 |
+
|
| 467 |
+
@staticmethod
|
| 468 |
+
def _get_api_endpoint(
|
| 469 |
+
api_override, client_cert_source, universe_domain, use_mtls_endpoint
|
| 470 |
+
) -> str:
|
| 471 |
+
"""Return the API endpoint used by the client.
|
| 472 |
+
|
| 473 |
+
Args:
|
| 474 |
+
api_override (str): The API endpoint override. If specified, this is always
|
| 475 |
+
the return value of this function and the other arguments are not used.
|
| 476 |
+
client_cert_source (bytes): The client certificate source used by the client.
|
| 477 |
+
universe_domain (str): The universe domain used by the client.
|
| 478 |
+
use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
|
| 479 |
+
Possible values are "always", "auto", or "never".
|
| 480 |
+
|
| 481 |
+
Returns:
|
| 482 |
+
str: The API endpoint to be used by the client.
|
| 483 |
+
"""
|
| 484 |
+
if api_override is not None:
|
| 485 |
+
api_endpoint = api_override
|
| 486 |
+
elif use_mtls_endpoint == "always" or (
|
| 487 |
+
use_mtls_endpoint == "auto" and client_cert_source
|
| 488 |
+
):
|
| 489 |
+
_default_universe = SpeechClient._DEFAULT_UNIVERSE
|
| 490 |
+
if universe_domain != _default_universe:
|
| 491 |
+
raise MutualTLSChannelError(
|
| 492 |
+
f"mTLS is not supported in any universe other than {_default_universe}."
|
| 493 |
+
)
|
| 494 |
+
api_endpoint = SpeechClient.DEFAULT_MTLS_ENDPOINT
|
| 495 |
+
else:
|
| 496 |
+
api_endpoint = SpeechClient._DEFAULT_ENDPOINT_TEMPLATE.format(
|
| 497 |
+
UNIVERSE_DOMAIN=universe_domain
|
| 498 |
+
)
|
| 499 |
+
return api_endpoint
|
| 500 |
+
|
| 501 |
+
@staticmethod
|
| 502 |
+
def _get_universe_domain(
|
| 503 |
+
client_universe_domain: Optional[str], universe_domain_env: Optional[str]
|
| 504 |
+
) -> str:
|
| 505 |
+
"""Return the universe domain used by the client.
|
| 506 |
+
|
| 507 |
+
Args:
|
| 508 |
+
client_universe_domain (Optional[str]): The universe domain configured via the client options.
|
| 509 |
+
universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
|
| 510 |
+
|
| 511 |
+
Returns:
|
| 512 |
+
str: The universe domain to be used by the client.
|
| 513 |
+
|
| 514 |
+
Raises:
|
| 515 |
+
ValueError: If the universe domain is an empty string.
|
| 516 |
+
"""
|
| 517 |
+
universe_domain = SpeechClient._DEFAULT_UNIVERSE
|
| 518 |
+
if client_universe_domain is not None:
|
| 519 |
+
universe_domain = client_universe_domain
|
| 520 |
+
elif universe_domain_env is not None:
|
| 521 |
+
universe_domain = universe_domain_env
|
| 522 |
+
if len(universe_domain.strip()) == 0:
|
| 523 |
+
raise ValueError("Universe Domain cannot be an empty string.")
|
| 524 |
+
return universe_domain
|
| 525 |
+
|
| 526 |
+
def _validate_universe_domain(self):
|
| 527 |
+
"""Validates client's and credentials' universe domains are consistent.
|
| 528 |
+
|
| 529 |
+
Returns:
|
| 530 |
+
bool: True iff the configured universe domain is valid.
|
| 531 |
+
|
| 532 |
+
Raises:
|
| 533 |
+
ValueError: If the configured universe domain is not valid.
|
| 534 |
+
"""
|
| 535 |
+
|
| 536 |
+
# NOTE (b/349488459): universe validation is disabled until further notice.
|
| 537 |
+
return True
|
| 538 |
+
|
| 539 |
+
def _add_cred_info_for_auth_errors(
|
| 540 |
+
self, error: core_exceptions.GoogleAPICallError
|
| 541 |
+
) -> None:
|
| 542 |
+
"""Adds credential info string to error details for 401/403/404 errors.
|
| 543 |
+
|
| 544 |
+
Args:
|
| 545 |
+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
|
| 546 |
+
"""
|
| 547 |
+
if error.code not in [
|
| 548 |
+
HTTPStatus.UNAUTHORIZED,
|
| 549 |
+
HTTPStatus.FORBIDDEN,
|
| 550 |
+
HTTPStatus.NOT_FOUND,
|
| 551 |
+
]:
|
| 552 |
+
return
|
| 553 |
+
|
| 554 |
+
cred = self._transport._credentials
|
| 555 |
+
|
| 556 |
+
# get_cred_info is only available in google-auth>=2.35.0
|
| 557 |
+
if not hasattr(cred, "get_cred_info"):
|
| 558 |
+
return
|
| 559 |
+
|
| 560 |
+
# ignore the type check since pypy test fails when get_cred_info
|
| 561 |
+
# is not available
|
| 562 |
+
cred_info = cred.get_cred_info() # type: ignore
|
| 563 |
+
if cred_info and hasattr(error._details, "append"):
|
| 564 |
+
error._details.append(json.dumps(cred_info))
|
| 565 |
+
|
| 566 |
+
@property
|
| 567 |
+
def api_endpoint(self) -> str:
|
| 568 |
+
"""Return the API endpoint used by the client instance.
|
| 569 |
+
|
| 570 |
+
Returns:
|
| 571 |
+
str: The API endpoint used by the client instance.
|
| 572 |
+
"""
|
| 573 |
+
return self._api_endpoint
|
| 574 |
+
|
| 575 |
+
@property
|
| 576 |
+
def universe_domain(self) -> str:
|
| 577 |
+
"""Return the universe domain used by the client instance.
|
| 578 |
+
|
| 579 |
+
Returns:
|
| 580 |
+
str: The universe domain used by the client instance.
|
| 581 |
+
"""
|
| 582 |
+
return self._universe_domain
|
| 583 |
+
|
| 584 |
+
def __init__(
|
| 585 |
+
self,
|
| 586 |
+
*,
|
| 587 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 588 |
+
transport: Optional[
|
| 589 |
+
Union[str, SpeechTransport, Callable[..., SpeechTransport]]
|
| 590 |
+
] = None,
|
| 591 |
+
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
|
| 592 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 593 |
+
) -> None:
|
| 594 |
+
"""Instantiates the speech client.
|
| 595 |
+
|
| 596 |
+
Args:
|
| 597 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 598 |
+
authorization credentials to attach to requests. These
|
| 599 |
+
credentials identify the application to the service; if none
|
| 600 |
+
are specified, the client will attempt to ascertain the
|
| 601 |
+
credentials from the environment.
|
| 602 |
+
transport (Optional[Union[str,SpeechTransport,Callable[..., SpeechTransport]]]):
|
| 603 |
+
The transport to use, or a Callable that constructs and returns a new transport.
|
| 604 |
+
If a Callable is given, it will be called with the same set of initialization
|
| 605 |
+
arguments as used in the SpeechTransport constructor.
|
| 606 |
+
If set to None, a transport is chosen automatically.
|
| 607 |
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
| 608 |
+
Custom options for the client.
|
| 609 |
+
|
| 610 |
+
1. The ``api_endpoint`` property can be used to override the
|
| 611 |
+
default endpoint provided by the client when ``transport`` is
|
| 612 |
+
not explicitly provided. Only if this property is not set and
|
| 613 |
+
``transport`` was not explicitly provided, the endpoint is
|
| 614 |
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
| 615 |
+
variable, which have one of the following values:
|
| 616 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 617 |
+
use the default regular endpoint) and "auto" (auto-switch to the
|
| 618 |
+
default mTLS endpoint if client certificate is present; this is
|
| 619 |
+
the default value).
|
| 620 |
+
|
| 621 |
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 622 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 623 |
+
to provide a client certificate for mTLS transport. If
|
| 624 |
+
not provided, the default SSL client certificate will be used if
|
| 625 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 626 |
+
set, no client certificate will be used.
|
| 627 |
+
|
| 628 |
+
3. The ``universe_domain`` property can be used to override the
|
| 629 |
+
default "googleapis.com" universe. Note that the ``api_endpoint``
|
| 630 |
+
property still takes precedence; and ``universe_domain`` is
|
| 631 |
+
currently not supported for mTLS.
|
| 632 |
+
|
| 633 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 634 |
+
The client info used to send a user-agent string along with
|
| 635 |
+
API requests. If ``None``, then default info will be used.
|
| 636 |
+
Generally, you only need to set this if you're developing
|
| 637 |
+
your own client library.
|
| 638 |
+
|
| 639 |
+
Raises:
|
| 640 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 641 |
+
creation failed for any reason.
|
| 642 |
+
"""
|
| 643 |
+
self._client_options = client_options
|
| 644 |
+
if isinstance(self._client_options, dict):
|
| 645 |
+
self._client_options = client_options_lib.from_dict(self._client_options)
|
| 646 |
+
if self._client_options is None:
|
| 647 |
+
self._client_options = client_options_lib.ClientOptions()
|
| 648 |
+
self._client_options = cast(
|
| 649 |
+
client_options_lib.ClientOptions, self._client_options
|
| 650 |
+
)
|
| 651 |
+
|
| 652 |
+
universe_domain_opt = getattr(self._client_options, "universe_domain", None)
|
| 653 |
+
|
| 654 |
+
self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
|
| 655 |
+
SpeechClient._read_environment_variables()
|
| 656 |
+
)
|
| 657 |
+
self._client_cert_source = SpeechClient._get_client_cert_source(
|
| 658 |
+
self._client_options.client_cert_source, self._use_client_cert
|
| 659 |
+
)
|
| 660 |
+
self._universe_domain = SpeechClient._get_universe_domain(
|
| 661 |
+
universe_domain_opt, self._universe_domain_env
|
| 662 |
+
)
|
| 663 |
+
self._api_endpoint: str = "" # updated below, depending on `transport`
|
| 664 |
+
|
| 665 |
+
# Initialize the universe domain validation.
|
| 666 |
+
self._is_universe_domain_valid = False
|
| 667 |
+
|
| 668 |
+
if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
|
| 669 |
+
# Setup logging.
|
| 670 |
+
client_logging.initialize_logging()
|
| 671 |
+
|
| 672 |
+
api_key_value = getattr(self._client_options, "api_key", None)
|
| 673 |
+
if api_key_value and credentials:
|
| 674 |
+
raise ValueError(
|
| 675 |
+
"client_options.api_key and credentials are mutually exclusive"
|
| 676 |
+
)
|
| 677 |
+
|
| 678 |
+
# Save or instantiate the transport.
|
| 679 |
+
# Ordinarily, we provide the transport, but allowing a custom transport
|
| 680 |
+
# instance provides an extensibility point for unusual situations.
|
| 681 |
+
transport_provided = isinstance(transport, SpeechTransport)
|
| 682 |
+
if transport_provided:
|
| 683 |
+
# transport is a SpeechTransport instance.
|
| 684 |
+
if credentials or self._client_options.credentials_file or api_key_value:
|
| 685 |
+
raise ValueError(
|
| 686 |
+
"When providing a transport instance, "
|
| 687 |
+
"provide its credentials directly."
|
| 688 |
+
)
|
| 689 |
+
if self._client_options.scopes:
|
| 690 |
+
raise ValueError(
|
| 691 |
+
"When providing a transport instance, provide its scopes directly."
|
| 692 |
+
)
|
| 693 |
+
self._transport = cast(SpeechTransport, transport)
|
| 694 |
+
self._api_endpoint = self._transport.host
|
| 695 |
+
|
| 696 |
+
self._api_endpoint = self._api_endpoint or SpeechClient._get_api_endpoint(
|
| 697 |
+
self._client_options.api_endpoint,
|
| 698 |
+
self._client_cert_source,
|
| 699 |
+
self._universe_domain,
|
| 700 |
+
self._use_mtls_endpoint,
|
| 701 |
+
)
|
| 702 |
+
|
| 703 |
+
if not transport_provided:
|
| 704 |
+
import google.auth._default # type: ignore
|
| 705 |
+
|
| 706 |
+
if api_key_value and hasattr(
|
| 707 |
+
google.auth._default, "get_api_key_credentials"
|
| 708 |
+
):
|
| 709 |
+
credentials = google.auth._default.get_api_key_credentials(
|
| 710 |
+
api_key_value
|
| 711 |
+
)
|
| 712 |
+
|
| 713 |
+
transport_init: Union[
|
| 714 |
+
Type[SpeechTransport], Callable[..., SpeechTransport]
|
| 715 |
+
] = (
|
| 716 |
+
SpeechClient.get_transport_class(transport)
|
| 717 |
+
if isinstance(transport, str) or transport is None
|
| 718 |
+
else cast(Callable[..., SpeechTransport], transport)
|
| 719 |
+
)
|
| 720 |
+
# initialize with the provided callable or the passed in class
|
| 721 |
+
self._transport = transport_init(
|
| 722 |
+
credentials=credentials,
|
| 723 |
+
credentials_file=self._client_options.credentials_file,
|
| 724 |
+
host=self._api_endpoint,
|
| 725 |
+
scopes=self._client_options.scopes,
|
| 726 |
+
client_cert_source_for_mtls=self._client_cert_source,
|
| 727 |
+
quota_project_id=self._client_options.quota_project_id,
|
| 728 |
+
client_info=client_info,
|
| 729 |
+
always_use_jwt_access=True,
|
| 730 |
+
api_audience=self._client_options.api_audience,
|
| 731 |
+
)
|
| 732 |
+
|
| 733 |
+
if "async" not in str(self._transport):
|
| 734 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 735 |
+
std_logging.DEBUG
|
| 736 |
+
): # pragma: NO COVER
|
| 737 |
+
_LOGGER.debug(
|
| 738 |
+
"Created client `google.cloud.speech_v1.SpeechClient`.",
|
| 739 |
+
extra={
|
| 740 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 741 |
+
"universeDomain": getattr(
|
| 742 |
+
self._transport._credentials, "universe_domain", ""
|
| 743 |
+
),
|
| 744 |
+
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
|
| 745 |
+
"credentialsInfo": getattr(
|
| 746 |
+
self.transport._credentials, "get_cred_info", lambda: None
|
| 747 |
+
)(),
|
| 748 |
+
}
|
| 749 |
+
if hasattr(self._transport, "_credentials")
|
| 750 |
+
else {
|
| 751 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 752 |
+
"credentialsType": None,
|
| 753 |
+
},
|
| 754 |
+
)
|
| 755 |
+
|
| 756 |
+
def recognize(
|
| 757 |
+
self,
|
| 758 |
+
request: Optional[Union[cloud_speech.RecognizeRequest, dict]] = None,
|
| 759 |
+
*,
|
| 760 |
+
config: Optional[cloud_speech.RecognitionConfig] = None,
|
| 761 |
+
audio: Optional[cloud_speech.RecognitionAudio] = None,
|
| 762 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 763 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 764 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 765 |
+
) -> cloud_speech.RecognizeResponse:
|
| 766 |
+
r"""Performs synchronous speech recognition: receive
|
| 767 |
+
results after all audio has been sent and processed.
|
| 768 |
+
|
| 769 |
+
.. code-block:: python
|
| 770 |
+
|
| 771 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 772 |
+
# code template only.
|
| 773 |
+
# It will require modifications to work:
|
| 774 |
+
# - It may require correct/in-range values for request initialization.
|
| 775 |
+
# - It may require specifying regional endpoints when creating the service
|
| 776 |
+
# client as shown in:
|
| 777 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 778 |
+
from google.cloud import speech_v1
|
| 779 |
+
|
| 780 |
+
def sample_recognize():
|
| 781 |
+
# Create a client
|
| 782 |
+
client = speech_v1.SpeechClient()
|
| 783 |
+
|
| 784 |
+
# Initialize request argument(s)
|
| 785 |
+
config = speech_v1.RecognitionConfig()
|
| 786 |
+
config.language_code = "language_code_value"
|
| 787 |
+
|
| 788 |
+
audio = speech_v1.RecognitionAudio()
|
| 789 |
+
audio.content = b'content_blob'
|
| 790 |
+
|
| 791 |
+
request = speech_v1.RecognizeRequest(
|
| 792 |
+
config=config,
|
| 793 |
+
audio=audio,
|
| 794 |
+
)
|
| 795 |
+
|
| 796 |
+
# Make the request
|
| 797 |
+
response = client.recognize(request=request)
|
| 798 |
+
|
| 799 |
+
# Handle the response
|
| 800 |
+
print(response)
|
| 801 |
+
|
| 802 |
+
Args:
|
| 803 |
+
request (Union[google.cloud.speech_v1.types.RecognizeRequest, dict]):
|
| 804 |
+
The request object. The top-level message sent by the client for the
|
| 805 |
+
``Recognize`` method.
|
| 806 |
+
config (google.cloud.speech_v1.types.RecognitionConfig):
|
| 807 |
+
Required. Provides information to the
|
| 808 |
+
recognizer that specifies how to process
|
| 809 |
+
the request.
|
| 810 |
+
|
| 811 |
+
This corresponds to the ``config`` field
|
| 812 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 813 |
+
should not be set.
|
| 814 |
+
audio (google.cloud.speech_v1.types.RecognitionAudio):
|
| 815 |
+
Required. The audio data to be
|
| 816 |
+
recognized.
|
| 817 |
+
|
| 818 |
+
This corresponds to the ``audio`` field
|
| 819 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 820 |
+
should not be set.
|
| 821 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 822 |
+
should be retried.
|
| 823 |
+
timeout (float): The timeout for this request.
|
| 824 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 825 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 826 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 827 |
+
be of type `bytes`.
|
| 828 |
+
|
| 829 |
+
Returns:
|
| 830 |
+
google.cloud.speech_v1.types.RecognizeResponse:
|
| 831 |
+
The only message returned to the client by the Recognize method. It
|
| 832 |
+
contains the result as zero or more sequential
|
| 833 |
+
SpeechRecognitionResult messages.
|
| 834 |
+
|
| 835 |
+
"""
|
| 836 |
+
# Create or coerce a protobuf request object.
|
| 837 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 838 |
+
# gotten any keyword arguments that map to the request.
|
| 839 |
+
flattened_params = [config, audio]
|
| 840 |
+
has_flattened_params = (
|
| 841 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 842 |
+
)
|
| 843 |
+
if request is not None and has_flattened_params:
|
| 844 |
+
raise ValueError(
|
| 845 |
+
"If the `request` argument is set, then none of "
|
| 846 |
+
"the individual field arguments should be set."
|
| 847 |
+
)
|
| 848 |
+
|
| 849 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 850 |
+
# there are no flattened fields), or create one.
|
| 851 |
+
if not isinstance(request, cloud_speech.RecognizeRequest):
|
| 852 |
+
request = cloud_speech.RecognizeRequest(request)
|
| 853 |
+
# If we have keyword arguments corresponding to fields on the
|
| 854 |
+
# request, apply these.
|
| 855 |
+
if config is not None:
|
| 856 |
+
request.config = config
|
| 857 |
+
if audio is not None:
|
| 858 |
+
request.audio = audio
|
| 859 |
+
|
| 860 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 861 |
+
# and friendly error handling.
|
| 862 |
+
rpc = self._transport._wrapped_methods[self._transport.recognize]
|
| 863 |
+
|
| 864 |
+
# Validate the universe domain.
|
| 865 |
+
self._validate_universe_domain()
|
| 866 |
+
|
| 867 |
+
# Send the request.
|
| 868 |
+
response = rpc(
|
| 869 |
+
request,
|
| 870 |
+
retry=retry,
|
| 871 |
+
timeout=timeout,
|
| 872 |
+
metadata=metadata,
|
| 873 |
+
)
|
| 874 |
+
|
| 875 |
+
# Done; return the response.
|
| 876 |
+
return response
|
| 877 |
+
|
| 878 |
+
def long_running_recognize(
|
| 879 |
+
self,
|
| 880 |
+
request: Optional[Union[cloud_speech.LongRunningRecognizeRequest, dict]] = None,
|
| 881 |
+
*,
|
| 882 |
+
config: Optional[cloud_speech.RecognitionConfig] = None,
|
| 883 |
+
audio: Optional[cloud_speech.RecognitionAudio] = None,
|
| 884 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 885 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 886 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 887 |
+
) -> operation.Operation:
|
| 888 |
+
r"""Performs asynchronous speech recognition: receive results via
|
| 889 |
+
the google.longrunning.Operations interface. Returns either an
|
| 890 |
+
``Operation.error`` or an ``Operation.response`` which contains
|
| 891 |
+
a ``LongRunningRecognizeResponse`` message. For more information
|
| 892 |
+
on asynchronous speech recognition, see the
|
| 893 |
+
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
|
| 894 |
+
|
| 895 |
+
.. code-block:: python
|
| 896 |
+
|
| 897 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 898 |
+
# code template only.
|
| 899 |
+
# It will require modifications to work:
|
| 900 |
+
# - It may require correct/in-range values for request initialization.
|
| 901 |
+
# - It may require specifying regional endpoints when creating the service
|
| 902 |
+
# client as shown in:
|
| 903 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 904 |
+
from google.cloud import speech_v1
|
| 905 |
+
|
| 906 |
+
def sample_long_running_recognize():
|
| 907 |
+
# Create a client
|
| 908 |
+
client = speech_v1.SpeechClient()
|
| 909 |
+
|
| 910 |
+
# Initialize request argument(s)
|
| 911 |
+
config = speech_v1.RecognitionConfig()
|
| 912 |
+
config.language_code = "language_code_value"
|
| 913 |
+
|
| 914 |
+
audio = speech_v1.RecognitionAudio()
|
| 915 |
+
audio.content = b'content_blob'
|
| 916 |
+
|
| 917 |
+
request = speech_v1.LongRunningRecognizeRequest(
|
| 918 |
+
config=config,
|
| 919 |
+
audio=audio,
|
| 920 |
+
)
|
| 921 |
+
|
| 922 |
+
# Make the request
|
| 923 |
+
operation = client.long_running_recognize(request=request)
|
| 924 |
+
|
| 925 |
+
print("Waiting for operation to complete...")
|
| 926 |
+
|
| 927 |
+
response = operation.result()
|
| 928 |
+
|
| 929 |
+
# Handle the response
|
| 930 |
+
print(response)
|
| 931 |
+
|
| 932 |
+
Args:
|
| 933 |
+
request (Union[google.cloud.speech_v1.types.LongRunningRecognizeRequest, dict]):
|
| 934 |
+
The request object. The top-level message sent by the client for the
|
| 935 |
+
``LongRunningRecognize`` method.
|
| 936 |
+
config (google.cloud.speech_v1.types.RecognitionConfig):
|
| 937 |
+
Required. Provides information to the
|
| 938 |
+
recognizer that specifies how to process
|
| 939 |
+
the request.
|
| 940 |
+
|
| 941 |
+
This corresponds to the ``config`` field
|
| 942 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 943 |
+
should not be set.
|
| 944 |
+
audio (google.cloud.speech_v1.types.RecognitionAudio):
|
| 945 |
+
Required. The audio data to be
|
| 946 |
+
recognized.
|
| 947 |
+
|
| 948 |
+
This corresponds to the ``audio`` field
|
| 949 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 950 |
+
should not be set.
|
| 951 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 952 |
+
should be retried.
|
| 953 |
+
timeout (float): The timeout for this request.
|
| 954 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 955 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 956 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 957 |
+
be of type `bytes`.
|
| 958 |
+
|
| 959 |
+
Returns:
|
| 960 |
+
google.api_core.operation.Operation:
|
| 961 |
+
An object representing a long-running operation.
|
| 962 |
+
|
| 963 |
+
The result type for the operation will be :class:`google.cloud.speech_v1.types.LongRunningRecognizeResponse` The only message returned to the client by the LongRunningRecognize method.
|
| 964 |
+
It contains the result as zero or more sequential
|
| 965 |
+
SpeechRecognitionResult messages. It is included in
|
| 966 |
+
the result.response field of the Operation returned
|
| 967 |
+
by the GetOperation call of the
|
| 968 |
+
google::longrunning::Operations service.
|
| 969 |
+
|
| 970 |
+
"""
|
| 971 |
+
# Create or coerce a protobuf request object.
|
| 972 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 973 |
+
# gotten any keyword arguments that map to the request.
|
| 974 |
+
flattened_params = [config, audio]
|
| 975 |
+
has_flattened_params = (
|
| 976 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 977 |
+
)
|
| 978 |
+
if request is not None and has_flattened_params:
|
| 979 |
+
raise ValueError(
|
| 980 |
+
"If the `request` argument is set, then none of "
|
| 981 |
+
"the individual field arguments should be set."
|
| 982 |
+
)
|
| 983 |
+
|
| 984 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 985 |
+
# there are no flattened fields), or create one.
|
| 986 |
+
if not isinstance(request, cloud_speech.LongRunningRecognizeRequest):
|
| 987 |
+
request = cloud_speech.LongRunningRecognizeRequest(request)
|
| 988 |
+
# If we have keyword arguments corresponding to fields on the
|
| 989 |
+
# request, apply these.
|
| 990 |
+
if config is not None:
|
| 991 |
+
request.config = config
|
| 992 |
+
if audio is not None:
|
| 993 |
+
request.audio = audio
|
| 994 |
+
|
| 995 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 996 |
+
# and friendly error handling.
|
| 997 |
+
rpc = self._transport._wrapped_methods[self._transport.long_running_recognize]
|
| 998 |
+
|
| 999 |
+
# Validate the universe domain.
|
| 1000 |
+
self._validate_universe_domain()
|
| 1001 |
+
|
| 1002 |
+
# Send the request.
|
| 1003 |
+
response = rpc(
|
| 1004 |
+
request,
|
| 1005 |
+
retry=retry,
|
| 1006 |
+
timeout=timeout,
|
| 1007 |
+
metadata=metadata,
|
| 1008 |
+
)
|
| 1009 |
+
|
| 1010 |
+
# Wrap the response in an operation future.
|
| 1011 |
+
response = operation.from_gapic(
|
| 1012 |
+
response,
|
| 1013 |
+
self._transport.operations_client,
|
| 1014 |
+
cloud_speech.LongRunningRecognizeResponse,
|
| 1015 |
+
metadata_type=cloud_speech.LongRunningRecognizeMetadata,
|
| 1016 |
+
)
|
| 1017 |
+
|
| 1018 |
+
# Done; return the response.
|
| 1019 |
+
return response
|
| 1020 |
+
|
| 1021 |
+
def streaming_recognize(
|
| 1022 |
+
self,
|
| 1023 |
+
requests: Optional[Iterator[cloud_speech.StreamingRecognizeRequest]] = None,
|
| 1024 |
+
*,
|
| 1025 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1026 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1027 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1028 |
+
) -> Iterable[cloud_speech.StreamingRecognizeResponse]:
|
| 1029 |
+
r"""Performs bidirectional streaming speech recognition:
|
| 1030 |
+
receive results while sending audio. This method is only
|
| 1031 |
+
available via the gRPC API (not REST).
|
| 1032 |
+
|
| 1033 |
+
.. code-block:: python
|
| 1034 |
+
|
| 1035 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1036 |
+
# code template only.
|
| 1037 |
+
# It will require modifications to work:
|
| 1038 |
+
# - It may require correct/in-range values for request initialization.
|
| 1039 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1040 |
+
# client as shown in:
|
| 1041 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1042 |
+
from google.cloud import speech_v1
|
| 1043 |
+
|
| 1044 |
+
def sample_streaming_recognize():
|
| 1045 |
+
# Create a client
|
| 1046 |
+
client = speech_v1.SpeechClient()
|
| 1047 |
+
|
| 1048 |
+
# Initialize request argument(s)
|
| 1049 |
+
streaming_config = speech_v1.StreamingRecognitionConfig()
|
| 1050 |
+
streaming_config.config.language_code = "language_code_value"
|
| 1051 |
+
|
| 1052 |
+
request = speech_v1.StreamingRecognizeRequest(
|
| 1053 |
+
streaming_config=streaming_config,
|
| 1054 |
+
)
|
| 1055 |
+
|
| 1056 |
+
# This method expects an iterator which contains
|
| 1057 |
+
# 'speech_v1.StreamingRecognizeRequest' objects
|
| 1058 |
+
# Here we create a generator that yields a single `request` for
|
| 1059 |
+
# demonstrative purposes.
|
| 1060 |
+
requests = [request]
|
| 1061 |
+
|
| 1062 |
+
def request_generator():
|
| 1063 |
+
for request in requests:
|
| 1064 |
+
yield request
|
| 1065 |
+
|
| 1066 |
+
# Make the request
|
| 1067 |
+
stream = client.streaming_recognize(requests=request_generator())
|
| 1068 |
+
|
| 1069 |
+
# Handle the response
|
| 1070 |
+
for response in stream:
|
| 1071 |
+
print(response)
|
| 1072 |
+
|
| 1073 |
+
Args:
|
| 1074 |
+
requests (Iterator[google.cloud.speech_v1.types.StreamingRecognizeRequest]):
|
| 1075 |
+
The request object iterator. The top-level message sent by the client for the
|
| 1076 |
+
``StreamingRecognize`` method. Multiple
|
| 1077 |
+
``StreamingRecognizeRequest`` messages are sent. The
|
| 1078 |
+
first message must contain a ``streaming_config``
|
| 1079 |
+
message and must not contain ``audio_content``. All
|
| 1080 |
+
subsequent messages must contain ``audio_content`` and
|
| 1081 |
+
must not contain a ``streaming_config`` message.
|
| 1082 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1083 |
+
should be retried.
|
| 1084 |
+
timeout (float): The timeout for this request.
|
| 1085 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1086 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1087 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1088 |
+
be of type `bytes`.
|
| 1089 |
+
|
| 1090 |
+
Returns:
|
| 1091 |
+
Iterable[google.cloud.speech_v1.types.StreamingRecognizeResponse]:
|
| 1092 |
+
StreamingRecognizeResponse is the only message returned to the client by
|
| 1093 |
+
StreamingRecognize. A series of zero or more
|
| 1094 |
+
StreamingRecognizeResponse messages are streamed back
|
| 1095 |
+
to the client. If there is no recognizable audio, and
|
| 1096 |
+
single_utterance is set to false, then no messages
|
| 1097 |
+
are streamed back to the client.
|
| 1098 |
+
|
| 1099 |
+
Here's an example of a series of
|
| 1100 |
+
\`StreamingRecognizeResponse`s that might be returned
|
| 1101 |
+
while processing audio:
|
| 1102 |
+
|
| 1103 |
+
1. results { alternatives { transcript: "tube" }
|
| 1104 |
+
stability: 0.01 }
|
| 1105 |
+
|
| 1106 |
+
2. results { alternatives { transcript: "to be a" }
|
| 1107 |
+
stability: 0.01 }
|
| 1108 |
+
|
| 1109 |
+
3. results { alternatives { transcript: "to be" }
|
| 1110 |
+
stability: 0.9 } results { alternatives {
|
| 1111 |
+
transcript: " or not to be" } stability: 0.01 }
|
| 1112 |
+
|
| 1113 |
+
4.
|
| 1114 |
+
|
| 1115 |
+
results { alternatives { transcript: "to be or not to be"
|
| 1116 |
+
confidence: 0.92 } alternatives { transcript:
|
| 1117 |
+
"to bee or not to bee" } is_final: true }
|
| 1118 |
+
|
| 1119 |
+
5. results { alternatives { transcript: " that's" }
|
| 1120 |
+
stability: 0.01 }
|
| 1121 |
+
|
| 1122 |
+
6. results { alternatives { transcript: " that is" }
|
| 1123 |
+
stability: 0.9 } results { alternatives {
|
| 1124 |
+
transcript: " the question" } stability: 0.01 }
|
| 1125 |
+
|
| 1126 |
+
7.
|
| 1127 |
+
|
| 1128 |
+
results { alternatives { transcript: " that is the question"
|
| 1129 |
+
confidence: 0.98 } alternatives { transcript: "
|
| 1130 |
+
that was the question" } is_final: true }
|
| 1131 |
+
|
| 1132 |
+
Notes:
|
| 1133 |
+
|
| 1134 |
+
- Only two of the above responses #4 and #7 contain
|
| 1135 |
+
final results; they are indicated by is_final:
|
| 1136 |
+
true. Concatenating these together generates the
|
| 1137 |
+
full transcript: "to be or not to be that is the
|
| 1138 |
+
question".
|
| 1139 |
+
|
| 1140 |
+
- The others contain interim results. #3 and #6
|
| 1141 |
+
contain two interim \`results\`: the first portion
|
| 1142 |
+
has a high stability and is less likely to change;
|
| 1143 |
+
the second portion has a low stability and is very
|
| 1144 |
+
likely to change. A UI designer might choose to
|
| 1145 |
+
show only high stability results.
|
| 1146 |
+
|
| 1147 |
+
- The specific stability and confidence values shown
|
| 1148 |
+
above are only for illustrative purposes. Actual
|
| 1149 |
+
values may vary.
|
| 1150 |
+
|
| 1151 |
+
-
|
| 1152 |
+
|
| 1153 |
+
In each response, only one of these fields will be set:
|
| 1154 |
+
error, speech_event_type, or one or more
|
| 1155 |
+
(repeated) results.
|
| 1156 |
+
|
| 1157 |
+
"""
|
| 1158 |
+
|
| 1159 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1160 |
+
# and friendly error handling.
|
| 1161 |
+
rpc = self._transport._wrapped_methods[self._transport.streaming_recognize]
|
| 1162 |
+
|
| 1163 |
+
# Validate the universe domain.
|
| 1164 |
+
self._validate_universe_domain()
|
| 1165 |
+
|
| 1166 |
+
# Send the request.
|
| 1167 |
+
response = rpc(
|
| 1168 |
+
requests,
|
| 1169 |
+
retry=retry,
|
| 1170 |
+
timeout=timeout,
|
| 1171 |
+
metadata=metadata,
|
| 1172 |
+
)
|
| 1173 |
+
|
| 1174 |
+
# Done; return the response.
|
| 1175 |
+
return response
|
| 1176 |
+
|
| 1177 |
+
def __enter__(self) -> "SpeechClient":
|
| 1178 |
+
return self
|
| 1179 |
+
|
| 1180 |
+
def __exit__(self, type, value, traceback):
|
| 1181 |
+
"""Releases underlying transport's resources.
|
| 1182 |
+
|
| 1183 |
+
.. warning::
|
| 1184 |
+
ONLY use as a context manager if the transport is NOT shared
|
| 1185 |
+
with other clients! Exiting the with block will CLOSE the transport
|
| 1186 |
+
and may cause errors in other clients!
|
| 1187 |
+
"""
|
| 1188 |
+
self.transport.close()
|
| 1189 |
+
|
| 1190 |
+
def list_operations(
|
| 1191 |
+
self,
|
| 1192 |
+
request: Optional[Union[operations_pb2.ListOperationsRequest, dict]] = None,
|
| 1193 |
+
*,
|
| 1194 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1195 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1196 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1197 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 1198 |
+
r"""Lists operations that match the specified filter in the request.
|
| 1199 |
+
|
| 1200 |
+
Args:
|
| 1201 |
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
| 1202 |
+
The request object. Request message for
|
| 1203 |
+
`ListOperations` method.
|
| 1204 |
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
| 1205 |
+
if any, should be retried.
|
| 1206 |
+
timeout (float): The timeout for this request.
|
| 1207 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1208 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1209 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1210 |
+
be of type `bytes`.
|
| 1211 |
+
Returns:
|
| 1212 |
+
~.operations_pb2.ListOperationsResponse:
|
| 1213 |
+
Response message for ``ListOperations`` method.
|
| 1214 |
+
"""
|
| 1215 |
+
# Create or coerce a protobuf request object.
|
| 1216 |
+
# The request isn't a proto-plus wrapped type,
|
| 1217 |
+
# so it must be constructed via keyword expansion.
|
| 1218 |
+
if request is None:
|
| 1219 |
+
request_pb = operations_pb2.ListOperationsRequest()
|
| 1220 |
+
elif isinstance(request, dict):
|
| 1221 |
+
request_pb = operations_pb2.ListOperationsRequest(**request)
|
| 1222 |
+
else:
|
| 1223 |
+
request_pb = request
|
| 1224 |
+
|
| 1225 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1226 |
+
# and friendly error handling.
|
| 1227 |
+
rpc = self._transport._wrapped_methods[self._transport.list_operations]
|
| 1228 |
+
|
| 1229 |
+
# Certain fields should be provided within the metadata header;
|
| 1230 |
+
# add these here.
|
| 1231 |
+
metadata = tuple(metadata) + (
|
| 1232 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 1233 |
+
)
|
| 1234 |
+
|
| 1235 |
+
# Validate the universe domain.
|
| 1236 |
+
self._validate_universe_domain()
|
| 1237 |
+
|
| 1238 |
+
try:
|
| 1239 |
+
# Send the request.
|
| 1240 |
+
response = rpc(
|
| 1241 |
+
request_pb,
|
| 1242 |
+
retry=retry,
|
| 1243 |
+
timeout=timeout,
|
| 1244 |
+
metadata=metadata,
|
| 1245 |
+
)
|
| 1246 |
+
|
| 1247 |
+
# Done; return the response.
|
| 1248 |
+
return response
|
| 1249 |
+
except core_exceptions.GoogleAPICallError as e:
|
| 1250 |
+
self._add_cred_info_for_auth_errors(e)
|
| 1251 |
+
raise e
|
| 1252 |
+
|
| 1253 |
+
def get_operation(
|
| 1254 |
+
self,
|
| 1255 |
+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
|
| 1256 |
+
*,
|
| 1257 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1258 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1259 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1260 |
+
) -> operations_pb2.Operation:
|
| 1261 |
+
r"""Gets the latest state of a long-running operation.
|
| 1262 |
+
|
| 1263 |
+
Args:
|
| 1264 |
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
| 1265 |
+
The request object. Request message for
|
| 1266 |
+
`GetOperation` method.
|
| 1267 |
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
| 1268 |
+
if any, should be retried.
|
| 1269 |
+
timeout (float): The timeout for this request.
|
| 1270 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1271 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1272 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1273 |
+
be of type `bytes`.
|
| 1274 |
+
Returns:
|
| 1275 |
+
~.operations_pb2.Operation:
|
| 1276 |
+
An ``Operation`` object.
|
| 1277 |
+
"""
|
| 1278 |
+
# Create or coerce a protobuf request object.
|
| 1279 |
+
# The request isn't a proto-plus wrapped type,
|
| 1280 |
+
# so it must be constructed via keyword expansion.
|
| 1281 |
+
if request is None:
|
| 1282 |
+
request_pb = operations_pb2.GetOperationRequest()
|
| 1283 |
+
elif isinstance(request, dict):
|
| 1284 |
+
request_pb = operations_pb2.GetOperationRequest(**request)
|
| 1285 |
+
else:
|
| 1286 |
+
request_pb = request
|
| 1287 |
+
|
| 1288 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1289 |
+
# and friendly error handling.
|
| 1290 |
+
rpc = self._transport._wrapped_methods[self._transport.get_operation]
|
| 1291 |
+
|
| 1292 |
+
# Certain fields should be provided within the metadata header;
|
| 1293 |
+
# add these here.
|
| 1294 |
+
metadata = tuple(metadata) + (
|
| 1295 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 1296 |
+
)
|
| 1297 |
+
|
| 1298 |
+
# Validate the universe domain.
|
| 1299 |
+
self._validate_universe_domain()
|
| 1300 |
+
|
| 1301 |
+
try:
|
| 1302 |
+
# Send the request.
|
| 1303 |
+
response = rpc(
|
| 1304 |
+
request_pb,
|
| 1305 |
+
retry=retry,
|
| 1306 |
+
timeout=timeout,
|
| 1307 |
+
metadata=metadata,
|
| 1308 |
+
)
|
| 1309 |
+
|
| 1310 |
+
# Done; return the response.
|
| 1311 |
+
return response
|
| 1312 |
+
except core_exceptions.GoogleAPICallError as e:
|
| 1313 |
+
self._add_cred_info_for_auth_errors(e)
|
| 1314 |
+
raise e
|
| 1315 |
+
|
| 1316 |
+
|
| 1317 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 1318 |
+
gapic_version=package_version.__version__
|
| 1319 |
+
)
|
| 1320 |
+
|
| 1321 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 1322 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 1323 |
+
|
| 1324 |
+
__all__ = ("SpeechClient",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from collections import OrderedDict
|
| 17 |
+
from typing import Dict, Type
|
| 18 |
+
|
| 19 |
+
from .base import SpeechTransport
|
| 20 |
+
from .grpc import SpeechGrpcTransport
|
| 21 |
+
from .grpc_asyncio import SpeechGrpcAsyncIOTransport
|
| 22 |
+
from .rest import SpeechRestInterceptor, SpeechRestTransport
|
| 23 |
+
|
| 24 |
+
# Compile a registry of transports.
|
| 25 |
+
_transport_registry = OrderedDict() # type: Dict[str, Type[SpeechTransport]]
|
| 26 |
+
_transport_registry["grpc"] = SpeechGrpcTransport
|
| 27 |
+
_transport_registry["grpc_asyncio"] = SpeechGrpcAsyncIOTransport
|
| 28 |
+
_transport_registry["rest"] = SpeechRestTransport
|
| 29 |
+
|
| 30 |
+
__all__ = (
|
| 31 |
+
"SpeechTransport",
|
| 32 |
+
"SpeechGrpcTransport",
|
| 33 |
+
"SpeechGrpcAsyncIOTransport",
|
| 34 |
+
"SpeechRestTransport",
|
| 35 |
+
"SpeechRestInterceptor",
|
| 36 |
+
)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/base.py
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import abc
|
| 17 |
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
|
| 18 |
+
|
| 19 |
+
import google.api_core
|
| 20 |
+
import google.auth # type: ignore
|
| 21 |
+
import google.protobuf
|
| 22 |
+
from google.api_core import exceptions as core_exceptions
|
| 23 |
+
from google.api_core import gapic_v1, operations_v1
|
| 24 |
+
from google.api_core import retry as retries
|
| 25 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 26 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 27 |
+
from google.oauth2 import service_account # type: ignore
|
| 28 |
+
|
| 29 |
+
from google.cloud.speech_v1 import gapic_version as package_version
|
| 30 |
+
from google.cloud.speech_v1.types import cloud_speech
|
| 31 |
+
|
| 32 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 33 |
+
gapic_version=package_version.__version__
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 37 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class SpeechTransport(abc.ABC):
|
| 41 |
+
"""Abstract transport class for Speech."""
|
| 42 |
+
|
| 43 |
+
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
|
| 44 |
+
|
| 45 |
+
DEFAULT_HOST: str = "speech.googleapis.com"
|
| 46 |
+
|
| 47 |
+
def __init__(
|
| 48 |
+
self,
|
| 49 |
+
*,
|
| 50 |
+
host: str = DEFAULT_HOST,
|
| 51 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 52 |
+
credentials_file: Optional[str] = None,
|
| 53 |
+
scopes: Optional[Sequence[str]] = None,
|
| 54 |
+
quota_project_id: Optional[str] = None,
|
| 55 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 56 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 57 |
+
api_audience: Optional[str] = None,
|
| 58 |
+
**kwargs,
|
| 59 |
+
) -> None:
|
| 60 |
+
"""Instantiate the transport.
|
| 61 |
+
|
| 62 |
+
Args:
|
| 63 |
+
host (Optional[str]):
|
| 64 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 65 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 66 |
+
authorization credentials to attach to requests. These
|
| 67 |
+
credentials identify the application to the service; if none
|
| 68 |
+
are specified, the client will attempt to ascertain the
|
| 69 |
+
credentials from the environment.
|
| 70 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 71 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 72 |
+
This argument is mutually exclusive with credentials. This argument will be
|
| 73 |
+
removed in the next major version of this library.
|
| 74 |
+
scopes (Optional[Sequence[str]]): A list of scopes.
|
| 75 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 76 |
+
and quota.
|
| 77 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 78 |
+
The client info used to send a user-agent string along with
|
| 79 |
+
API requests. If ``None``, then default info will be used.
|
| 80 |
+
Generally, you only need to set this if you're developing
|
| 81 |
+
your own client library.
|
| 82 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 83 |
+
be used for service account credentials.
|
| 84 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 85 |
+
to the service that will be set when using certain 3rd party
|
| 86 |
+
authentication flows. Audience is typically a resource identifier.
|
| 87 |
+
If not set, the host value will be used as a default.
|
| 88 |
+
"""
|
| 89 |
+
|
| 90 |
+
# Save the scopes.
|
| 91 |
+
self._scopes = scopes
|
| 92 |
+
if not hasattr(self, "_ignore_credentials"):
|
| 93 |
+
self._ignore_credentials: bool = False
|
| 94 |
+
|
| 95 |
+
# If no credentials are provided, then determine the appropriate
|
| 96 |
+
# defaults.
|
| 97 |
+
if credentials and credentials_file:
|
| 98 |
+
raise core_exceptions.DuplicateCredentialArgs(
|
| 99 |
+
"'credentials_file' and 'credentials' are mutually exclusive"
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
if credentials_file is not None:
|
| 103 |
+
credentials, _ = google.auth.load_credentials_from_file(
|
| 104 |
+
credentials_file,
|
| 105 |
+
scopes=scopes,
|
| 106 |
+
quota_project_id=quota_project_id,
|
| 107 |
+
default_scopes=self.AUTH_SCOPES,
|
| 108 |
+
)
|
| 109 |
+
elif credentials is None and not self._ignore_credentials:
|
| 110 |
+
credentials, _ = google.auth.default(
|
| 111 |
+
scopes=scopes,
|
| 112 |
+
quota_project_id=quota_project_id,
|
| 113 |
+
default_scopes=self.AUTH_SCOPES,
|
| 114 |
+
)
|
| 115 |
+
# Don't apply audience if the credentials file passed from user.
|
| 116 |
+
if hasattr(credentials, "with_gdch_audience"):
|
| 117 |
+
credentials = credentials.with_gdch_audience(
|
| 118 |
+
api_audience if api_audience else host
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
# If the credentials are service account credentials, then always try to use self signed JWT.
|
| 122 |
+
if (
|
| 123 |
+
always_use_jwt_access
|
| 124 |
+
and isinstance(credentials, service_account.Credentials)
|
| 125 |
+
and hasattr(service_account.Credentials, "with_always_use_jwt_access")
|
| 126 |
+
):
|
| 127 |
+
credentials = credentials.with_always_use_jwt_access(True)
|
| 128 |
+
|
| 129 |
+
# Save the credentials.
|
| 130 |
+
self._credentials = credentials
|
| 131 |
+
|
| 132 |
+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
|
| 133 |
+
if ":" not in host:
|
| 134 |
+
host += ":443"
|
| 135 |
+
self._host = host
|
| 136 |
+
|
| 137 |
+
self._wrapped_methods: Dict[Callable, Callable] = {}
|
| 138 |
+
|
| 139 |
+
@property
|
| 140 |
+
def host(self):
|
| 141 |
+
return self._host
|
| 142 |
+
|
| 143 |
+
def _prep_wrapped_messages(self, client_info):
|
| 144 |
+
# Precompute the wrapped methods.
|
| 145 |
+
self._wrapped_methods = {
|
| 146 |
+
self.recognize: gapic_v1.method.wrap_method(
|
| 147 |
+
self.recognize,
|
| 148 |
+
default_retry=retries.Retry(
|
| 149 |
+
initial=0.1,
|
| 150 |
+
maximum=60.0,
|
| 151 |
+
multiplier=1.3,
|
| 152 |
+
predicate=retries.if_exception_type(
|
| 153 |
+
core_exceptions.DeadlineExceeded,
|
| 154 |
+
core_exceptions.ServiceUnavailable,
|
| 155 |
+
),
|
| 156 |
+
deadline=5000.0,
|
| 157 |
+
),
|
| 158 |
+
default_timeout=5000.0,
|
| 159 |
+
client_info=client_info,
|
| 160 |
+
),
|
| 161 |
+
self.long_running_recognize: gapic_v1.method.wrap_method(
|
| 162 |
+
self.long_running_recognize,
|
| 163 |
+
default_timeout=5000.0,
|
| 164 |
+
client_info=client_info,
|
| 165 |
+
),
|
| 166 |
+
self.streaming_recognize: gapic_v1.method.wrap_method(
|
| 167 |
+
self.streaming_recognize,
|
| 168 |
+
default_retry=retries.Retry(
|
| 169 |
+
initial=0.1,
|
| 170 |
+
maximum=60.0,
|
| 171 |
+
multiplier=1.3,
|
| 172 |
+
predicate=retries.if_exception_type(
|
| 173 |
+
core_exceptions.DeadlineExceeded,
|
| 174 |
+
core_exceptions.ServiceUnavailable,
|
| 175 |
+
),
|
| 176 |
+
deadline=5000.0,
|
| 177 |
+
),
|
| 178 |
+
default_timeout=5000.0,
|
| 179 |
+
client_info=client_info,
|
| 180 |
+
),
|
| 181 |
+
self.get_operation: gapic_v1.method.wrap_method(
|
| 182 |
+
self.get_operation,
|
| 183 |
+
default_timeout=None,
|
| 184 |
+
client_info=client_info,
|
| 185 |
+
),
|
| 186 |
+
self.list_operations: gapic_v1.method.wrap_method(
|
| 187 |
+
self.list_operations,
|
| 188 |
+
default_timeout=None,
|
| 189 |
+
client_info=client_info,
|
| 190 |
+
),
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
def close(self):
|
| 194 |
+
"""Closes resources associated with the transport.
|
| 195 |
+
|
| 196 |
+
.. warning::
|
| 197 |
+
Only call this method if the transport is NOT shared
|
| 198 |
+
with other clients - this may cause errors in other clients!
|
| 199 |
+
"""
|
| 200 |
+
raise NotImplementedError()
|
| 201 |
+
|
| 202 |
+
@property
|
| 203 |
+
def operations_client(self):
|
| 204 |
+
"""Return the client designed to process long-running operations."""
|
| 205 |
+
raise NotImplementedError()
|
| 206 |
+
|
| 207 |
+
@property
|
| 208 |
+
def recognize(
|
| 209 |
+
self,
|
| 210 |
+
) -> Callable[
|
| 211 |
+
[cloud_speech.RecognizeRequest],
|
| 212 |
+
Union[
|
| 213 |
+
cloud_speech.RecognizeResponse, Awaitable[cloud_speech.RecognizeResponse]
|
| 214 |
+
],
|
| 215 |
+
]:
|
| 216 |
+
raise NotImplementedError()
|
| 217 |
+
|
| 218 |
+
@property
|
| 219 |
+
def long_running_recognize(
|
| 220 |
+
self,
|
| 221 |
+
) -> Callable[
|
| 222 |
+
[cloud_speech.LongRunningRecognizeRequest],
|
| 223 |
+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
|
| 224 |
+
]:
|
| 225 |
+
raise NotImplementedError()
|
| 226 |
+
|
| 227 |
+
@property
|
| 228 |
+
def streaming_recognize(
|
| 229 |
+
self,
|
| 230 |
+
) -> Callable[
|
| 231 |
+
[cloud_speech.StreamingRecognizeRequest],
|
| 232 |
+
Union[
|
| 233 |
+
cloud_speech.StreamingRecognizeResponse,
|
| 234 |
+
Awaitable[cloud_speech.StreamingRecognizeResponse],
|
| 235 |
+
],
|
| 236 |
+
]:
|
| 237 |
+
raise NotImplementedError()
|
| 238 |
+
|
| 239 |
+
@property
|
| 240 |
+
def list_operations(
|
| 241 |
+
self,
|
| 242 |
+
) -> Callable[
|
| 243 |
+
[operations_pb2.ListOperationsRequest],
|
| 244 |
+
Union[
|
| 245 |
+
operations_pb2.ListOperationsResponse,
|
| 246 |
+
Awaitable[operations_pb2.ListOperationsResponse],
|
| 247 |
+
],
|
| 248 |
+
]:
|
| 249 |
+
raise NotImplementedError()
|
| 250 |
+
|
| 251 |
+
@property
|
| 252 |
+
def get_operation(
|
| 253 |
+
self,
|
| 254 |
+
) -> Callable[
|
| 255 |
+
[operations_pb2.GetOperationRequest],
|
| 256 |
+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
|
| 257 |
+
]:
|
| 258 |
+
raise NotImplementedError()
|
| 259 |
+
|
| 260 |
+
@property
|
| 261 |
+
def kind(self) -> str:
|
| 262 |
+
raise NotImplementedError()
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
__all__ = ("SpeechTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/grpc.py
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json
|
| 17 |
+
import logging as std_logging
|
| 18 |
+
import pickle
|
| 19 |
+
import warnings
|
| 20 |
+
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
|
| 21 |
+
|
| 22 |
+
import google.auth # type: ignore
|
| 23 |
+
import google.protobuf.message
|
| 24 |
+
import grpc # type: ignore
|
| 25 |
+
import proto # type: ignore
|
| 26 |
+
from google.api_core import gapic_v1, grpc_helpers, operations_v1
|
| 27 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 28 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 29 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 30 |
+
from google.protobuf.json_format import MessageToJson
|
| 31 |
+
|
| 32 |
+
from google.cloud.speech_v1.types import cloud_speech
|
| 33 |
+
|
| 34 |
+
from .base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 35 |
+
|
| 36 |
+
try:
|
| 37 |
+
from google.api_core import client_logging # type: ignore
|
| 38 |
+
|
| 39 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 40 |
+
except ImportError: # pragma: NO COVER
|
| 41 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 42 |
+
|
| 43 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
|
| 47 |
+
def intercept_unary_unary(self, continuation, client_call_details, request):
|
| 48 |
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 49 |
+
std_logging.DEBUG
|
| 50 |
+
)
|
| 51 |
+
if logging_enabled: # pragma: NO COVER
|
| 52 |
+
request_metadata = client_call_details.metadata
|
| 53 |
+
if isinstance(request, proto.Message):
|
| 54 |
+
request_payload = type(request).to_json(request)
|
| 55 |
+
elif isinstance(request, google.protobuf.message.Message):
|
| 56 |
+
request_payload = MessageToJson(request)
|
| 57 |
+
else:
|
| 58 |
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
|
| 59 |
+
|
| 60 |
+
request_metadata = {
|
| 61 |
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
| 62 |
+
for key, value in request_metadata
|
| 63 |
+
}
|
| 64 |
+
grpc_request = {
|
| 65 |
+
"payload": request_payload,
|
| 66 |
+
"requestMethod": "grpc",
|
| 67 |
+
"metadata": dict(request_metadata),
|
| 68 |
+
}
|
| 69 |
+
_LOGGER.debug(
|
| 70 |
+
f"Sending request for {client_call_details.method}",
|
| 71 |
+
extra={
|
| 72 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 73 |
+
"rpcName": str(client_call_details.method),
|
| 74 |
+
"request": grpc_request,
|
| 75 |
+
"metadata": grpc_request["metadata"],
|
| 76 |
+
},
|
| 77 |
+
)
|
| 78 |
+
response = continuation(client_call_details, request)
|
| 79 |
+
if logging_enabled: # pragma: NO COVER
|
| 80 |
+
response_metadata = response.trailing_metadata()
|
| 81 |
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
| 82 |
+
metadata = (
|
| 83 |
+
dict([(k, str(v)) for k, v in response_metadata])
|
| 84 |
+
if response_metadata
|
| 85 |
+
else None
|
| 86 |
+
)
|
| 87 |
+
result = response.result()
|
| 88 |
+
if isinstance(result, proto.Message):
|
| 89 |
+
response_payload = type(result).to_json(result)
|
| 90 |
+
elif isinstance(result, google.protobuf.message.Message):
|
| 91 |
+
response_payload = MessageToJson(result)
|
| 92 |
+
else:
|
| 93 |
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
|
| 94 |
+
grpc_response = {
|
| 95 |
+
"payload": response_payload,
|
| 96 |
+
"metadata": metadata,
|
| 97 |
+
"status": "OK",
|
| 98 |
+
}
|
| 99 |
+
_LOGGER.debug(
|
| 100 |
+
f"Received response for {client_call_details.method}.",
|
| 101 |
+
extra={
|
| 102 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 103 |
+
"rpcName": client_call_details.method,
|
| 104 |
+
"response": grpc_response,
|
| 105 |
+
"metadata": grpc_response["metadata"],
|
| 106 |
+
},
|
| 107 |
+
)
|
| 108 |
+
return response
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
class SpeechGrpcTransport(SpeechTransport):
|
| 112 |
+
"""gRPC backend transport for Speech.
|
| 113 |
+
|
| 114 |
+
Service that implements Google Cloud Speech API.
|
| 115 |
+
|
| 116 |
+
This class defines the same methods as the primary client, so the
|
| 117 |
+
primary client can load the underlying transport implementation
|
| 118 |
+
and call it.
|
| 119 |
+
|
| 120 |
+
It sends protocol buffers over the wire using gRPC (which is built on
|
| 121 |
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
_stubs: Dict[str, Callable]
|
| 125 |
+
|
| 126 |
+
def __init__(
|
| 127 |
+
self,
|
| 128 |
+
*,
|
| 129 |
+
host: str = "speech.googleapis.com",
|
| 130 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 131 |
+
credentials_file: Optional[str] = None,
|
| 132 |
+
scopes: Optional[Sequence[str]] = None,
|
| 133 |
+
channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
|
| 134 |
+
api_mtls_endpoint: Optional[str] = None,
|
| 135 |
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 136 |
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
| 137 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 138 |
+
quota_project_id: Optional[str] = None,
|
| 139 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 140 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 141 |
+
api_audience: Optional[str] = None,
|
| 142 |
+
) -> None:
|
| 143 |
+
"""Instantiate the transport.
|
| 144 |
+
|
| 145 |
+
Args:
|
| 146 |
+
host (Optional[str]):
|
| 147 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 148 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 149 |
+
authorization credentials to attach to requests. These
|
| 150 |
+
credentials identify the application to the service; if none
|
| 151 |
+
are specified, the client will attempt to ascertain the
|
| 152 |
+
credentials from the environment.
|
| 153 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 154 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 155 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 156 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 157 |
+
This argument will be removed in the next major version of this library.
|
| 158 |
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
| 159 |
+
ignored if a ``channel`` instance is provided.
|
| 160 |
+
channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
|
| 161 |
+
A ``Channel`` instance through which to make calls, or a Callable
|
| 162 |
+
that constructs and returns one. If set to None, ``self.create_channel``
|
| 163 |
+
is used to create the channel. If a Callable is given, it will be called
|
| 164 |
+
with the same arguments as used in ``self.create_channel``.
|
| 165 |
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
| 166 |
+
If provided, it overrides the ``host`` argument and tries to create
|
| 167 |
+
a mutual TLS channel with client SSL credentials from
|
| 168 |
+
``client_cert_source`` or application default SSL credentials.
|
| 169 |
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 170 |
+
Deprecated. A callback to provide client SSL certificate bytes and
|
| 171 |
+
private key bytes, both in PEM format. It is ignored if
|
| 172 |
+
``api_mtls_endpoint`` is None.
|
| 173 |
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
| 174 |
+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
|
| 175 |
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 176 |
+
A callback to provide client certificate bytes and private key bytes,
|
| 177 |
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
| 178 |
+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
|
| 179 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 180 |
+
and quota.
|
| 181 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 182 |
+
The client info used to send a user-agent string along with
|
| 183 |
+
API requests. If ``None``, then default info will be used.
|
| 184 |
+
Generally, you only need to set this if you're developing
|
| 185 |
+
your own client library.
|
| 186 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 187 |
+
be used for service account credentials.
|
| 188 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 189 |
+
to the service that will be set when using certain 3rd party
|
| 190 |
+
authentication flows. Audience is typically a resource identifier.
|
| 191 |
+
If not set, the host value will be used as a default.
|
| 192 |
+
|
| 193 |
+
Raises:
|
| 194 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 195 |
+
creation failed for any reason.
|
| 196 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 197 |
+
and ``credentials_file`` are passed.
|
| 198 |
+
"""
|
| 199 |
+
self._grpc_channel = None
|
| 200 |
+
self._ssl_channel_credentials = ssl_channel_credentials
|
| 201 |
+
self._stubs: Dict[str, Callable] = {}
|
| 202 |
+
self._operations_client: Optional[operations_v1.OperationsClient] = None
|
| 203 |
+
|
| 204 |
+
if api_mtls_endpoint:
|
| 205 |
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
| 206 |
+
if client_cert_source:
|
| 207 |
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
| 208 |
+
|
| 209 |
+
if isinstance(channel, grpc.Channel):
|
| 210 |
+
# Ignore credentials if a channel was passed.
|
| 211 |
+
credentials = None
|
| 212 |
+
self._ignore_credentials = True
|
| 213 |
+
# If a channel was explicitly provided, set it.
|
| 214 |
+
self._grpc_channel = channel
|
| 215 |
+
self._ssl_channel_credentials = None
|
| 216 |
+
|
| 217 |
+
else:
|
| 218 |
+
if api_mtls_endpoint:
|
| 219 |
+
host = api_mtls_endpoint
|
| 220 |
+
|
| 221 |
+
# Create SSL credentials with client_cert_source or application
|
| 222 |
+
# default SSL credentials.
|
| 223 |
+
if client_cert_source:
|
| 224 |
+
cert, key = client_cert_source()
|
| 225 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 226 |
+
certificate_chain=cert, private_key=key
|
| 227 |
+
)
|
| 228 |
+
else:
|
| 229 |
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
| 230 |
+
|
| 231 |
+
else:
|
| 232 |
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
| 233 |
+
cert, key = client_cert_source_for_mtls()
|
| 234 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 235 |
+
certificate_chain=cert, private_key=key
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
# The base transport sets the host, credentials and scopes
|
| 239 |
+
super().__init__(
|
| 240 |
+
host=host,
|
| 241 |
+
credentials=credentials,
|
| 242 |
+
credentials_file=credentials_file,
|
| 243 |
+
scopes=scopes,
|
| 244 |
+
quota_project_id=quota_project_id,
|
| 245 |
+
client_info=client_info,
|
| 246 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 247 |
+
api_audience=api_audience,
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
if not self._grpc_channel:
|
| 251 |
+
# initialize with the provided callable or the default channel
|
| 252 |
+
channel_init = channel or type(self).create_channel
|
| 253 |
+
self._grpc_channel = channel_init(
|
| 254 |
+
self._host,
|
| 255 |
+
# use the credentials which are saved
|
| 256 |
+
credentials=self._credentials,
|
| 257 |
+
# Set ``credentials_file`` to ``None`` here as
|
| 258 |
+
# the credentials that we saved earlier should be used.
|
| 259 |
+
credentials_file=None,
|
| 260 |
+
scopes=self._scopes,
|
| 261 |
+
ssl_credentials=self._ssl_channel_credentials,
|
| 262 |
+
quota_project_id=quota_project_id,
|
| 263 |
+
options=[
|
| 264 |
+
("grpc.max_send_message_length", -1),
|
| 265 |
+
("grpc.max_receive_message_length", -1),
|
| 266 |
+
],
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
self._interceptor = _LoggingClientInterceptor()
|
| 270 |
+
self._logged_channel = grpc.intercept_channel(
|
| 271 |
+
self._grpc_channel, self._interceptor
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
# Wrap messages. This must be done after self._logged_channel exists
|
| 275 |
+
self._prep_wrapped_messages(client_info)
|
| 276 |
+
|
| 277 |
+
@classmethod
|
| 278 |
+
def create_channel(
|
| 279 |
+
cls,
|
| 280 |
+
host: str = "speech.googleapis.com",
|
| 281 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 282 |
+
credentials_file: Optional[str] = None,
|
| 283 |
+
scopes: Optional[Sequence[str]] = None,
|
| 284 |
+
quota_project_id: Optional[str] = None,
|
| 285 |
+
**kwargs,
|
| 286 |
+
) -> grpc.Channel:
|
| 287 |
+
"""Create and return a gRPC channel object.
|
| 288 |
+
Args:
|
| 289 |
+
host (Optional[str]): The host for the channel to use.
|
| 290 |
+
credentials (Optional[~.Credentials]): The
|
| 291 |
+
authorization credentials to attach to requests. These
|
| 292 |
+
credentials identify this application to the service. If
|
| 293 |
+
none are specified, the client will attempt to ascertain
|
| 294 |
+
the credentials from the environment.
|
| 295 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 296 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 297 |
+
This argument is mutually exclusive with credentials. This argument will be
|
| 298 |
+
removed in the next major version of this library.
|
| 299 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 300 |
+
service. These are only used when credentials are not specified and
|
| 301 |
+
are passed to :func:`google.auth.default`.
|
| 302 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 303 |
+
and quota.
|
| 304 |
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
| 305 |
+
channel creation.
|
| 306 |
+
Returns:
|
| 307 |
+
grpc.Channel: A gRPC channel object.
|
| 308 |
+
|
| 309 |
+
Raises:
|
| 310 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 311 |
+
and ``credentials_file`` are passed.
|
| 312 |
+
"""
|
| 313 |
+
|
| 314 |
+
return grpc_helpers.create_channel(
|
| 315 |
+
host,
|
| 316 |
+
credentials=credentials,
|
| 317 |
+
credentials_file=credentials_file,
|
| 318 |
+
quota_project_id=quota_project_id,
|
| 319 |
+
default_scopes=cls.AUTH_SCOPES,
|
| 320 |
+
scopes=scopes,
|
| 321 |
+
default_host=cls.DEFAULT_HOST,
|
| 322 |
+
**kwargs,
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
@property
|
| 326 |
+
def grpc_channel(self) -> grpc.Channel:
|
| 327 |
+
"""Return the channel designed to connect to this service."""
|
| 328 |
+
return self._grpc_channel
|
| 329 |
+
|
| 330 |
+
@property
|
| 331 |
+
def operations_client(self) -> operations_v1.OperationsClient:
|
| 332 |
+
"""Create the client designed to process long-running operations.
|
| 333 |
+
|
| 334 |
+
This property caches on the instance; repeated calls return the same
|
| 335 |
+
client.
|
| 336 |
+
"""
|
| 337 |
+
# Quick check: Only create a new client if we do not already have one.
|
| 338 |
+
if self._operations_client is None:
|
| 339 |
+
self._operations_client = operations_v1.OperationsClient(
|
| 340 |
+
self._logged_channel
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
# Return the client from cache.
|
| 344 |
+
return self._operations_client
|
| 345 |
+
|
| 346 |
+
@property
|
| 347 |
+
def recognize(
|
| 348 |
+
self,
|
| 349 |
+
) -> Callable[[cloud_speech.RecognizeRequest], cloud_speech.RecognizeResponse]:
|
| 350 |
+
r"""Return a callable for the recognize method over gRPC.
|
| 351 |
+
|
| 352 |
+
Performs synchronous speech recognition: receive
|
| 353 |
+
results after all audio has been sent and processed.
|
| 354 |
+
|
| 355 |
+
Returns:
|
| 356 |
+
Callable[[~.RecognizeRequest],
|
| 357 |
+
~.RecognizeResponse]:
|
| 358 |
+
A function that, when called, will call the underlying RPC
|
| 359 |
+
on the server.
|
| 360 |
+
"""
|
| 361 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 362 |
+
# the request.
|
| 363 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 364 |
+
# to pass in the functions for each.
|
| 365 |
+
if "recognize" not in self._stubs:
|
| 366 |
+
self._stubs["recognize"] = self._logged_channel.unary_unary(
|
| 367 |
+
"/google.cloud.speech.v1.Speech/Recognize",
|
| 368 |
+
request_serializer=cloud_speech.RecognizeRequest.serialize,
|
| 369 |
+
response_deserializer=cloud_speech.RecognizeResponse.deserialize,
|
| 370 |
+
)
|
| 371 |
+
return self._stubs["recognize"]
|
| 372 |
+
|
| 373 |
+
@property
|
| 374 |
+
def long_running_recognize(
|
| 375 |
+
self,
|
| 376 |
+
) -> Callable[[cloud_speech.LongRunningRecognizeRequest], operations_pb2.Operation]:
|
| 377 |
+
r"""Return a callable for the long running recognize method over gRPC.
|
| 378 |
+
|
| 379 |
+
Performs asynchronous speech recognition: receive results via
|
| 380 |
+
the google.longrunning.Operations interface. Returns either an
|
| 381 |
+
``Operation.error`` or an ``Operation.response`` which contains
|
| 382 |
+
a ``LongRunningRecognizeResponse`` message. For more information
|
| 383 |
+
on asynchronous speech recognition, see the
|
| 384 |
+
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
|
| 385 |
+
|
| 386 |
+
Returns:
|
| 387 |
+
Callable[[~.LongRunningRecognizeRequest],
|
| 388 |
+
~.Operation]:
|
| 389 |
+
A function that, when called, will call the underlying RPC
|
| 390 |
+
on the server.
|
| 391 |
+
"""
|
| 392 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 393 |
+
# the request.
|
| 394 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 395 |
+
# to pass in the functions for each.
|
| 396 |
+
if "long_running_recognize" not in self._stubs:
|
| 397 |
+
self._stubs["long_running_recognize"] = self._logged_channel.unary_unary(
|
| 398 |
+
"/google.cloud.speech.v1.Speech/LongRunningRecognize",
|
| 399 |
+
request_serializer=cloud_speech.LongRunningRecognizeRequest.serialize,
|
| 400 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 401 |
+
)
|
| 402 |
+
return self._stubs["long_running_recognize"]
|
| 403 |
+
|
| 404 |
+
@property
|
| 405 |
+
def streaming_recognize(
|
| 406 |
+
self,
|
| 407 |
+
) -> Callable[
|
| 408 |
+
[cloud_speech.StreamingRecognizeRequest],
|
| 409 |
+
cloud_speech.StreamingRecognizeResponse,
|
| 410 |
+
]:
|
| 411 |
+
r"""Return a callable for the streaming recognize method over gRPC.
|
| 412 |
+
|
| 413 |
+
Performs bidirectional streaming speech recognition:
|
| 414 |
+
receive results while sending audio. This method is only
|
| 415 |
+
available via the gRPC API (not REST).
|
| 416 |
+
|
| 417 |
+
Returns:
|
| 418 |
+
Callable[[~.StreamingRecognizeRequest],
|
| 419 |
+
~.StreamingRecognizeResponse]:
|
| 420 |
+
A function that, when called, will call the underlying RPC
|
| 421 |
+
on the server.
|
| 422 |
+
"""
|
| 423 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 424 |
+
# the request.
|
| 425 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 426 |
+
# to pass in the functions for each.
|
| 427 |
+
if "streaming_recognize" not in self._stubs:
|
| 428 |
+
self._stubs["streaming_recognize"] = self._logged_channel.stream_stream(
|
| 429 |
+
"/google.cloud.speech.v1.Speech/StreamingRecognize",
|
| 430 |
+
request_serializer=cloud_speech.StreamingRecognizeRequest.serialize,
|
| 431 |
+
response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize,
|
| 432 |
+
)
|
| 433 |
+
return self._stubs["streaming_recognize"]
|
| 434 |
+
|
| 435 |
+
def close(self):
|
| 436 |
+
self._logged_channel.close()
|
| 437 |
+
|
| 438 |
+
@property
|
| 439 |
+
def get_operation(
|
| 440 |
+
self,
|
| 441 |
+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
|
| 442 |
+
r"""Return a callable for the get_operation method over gRPC."""
|
| 443 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 444 |
+
# the request.
|
| 445 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 446 |
+
# to pass in the functions for each.
|
| 447 |
+
if "get_operation" not in self._stubs:
|
| 448 |
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
| 449 |
+
"/google.longrunning.Operations/GetOperation",
|
| 450 |
+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
| 451 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 452 |
+
)
|
| 453 |
+
return self._stubs["get_operation"]
|
| 454 |
+
|
| 455 |
+
@property
|
| 456 |
+
def list_operations(
|
| 457 |
+
self,
|
| 458 |
+
) -> Callable[
|
| 459 |
+
[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
|
| 460 |
+
]:
|
| 461 |
+
r"""Return a callable for the list_operations method over gRPC."""
|
| 462 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 463 |
+
# the request.
|
| 464 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 465 |
+
# to pass in the functions for each.
|
| 466 |
+
if "list_operations" not in self._stubs:
|
| 467 |
+
self._stubs["list_operations"] = self._logged_channel.unary_unary(
|
| 468 |
+
"/google.longrunning.Operations/ListOperations",
|
| 469 |
+
request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
|
| 470 |
+
response_deserializer=operations_pb2.ListOperationsResponse.FromString,
|
| 471 |
+
)
|
| 472 |
+
return self._stubs["list_operations"]
|
| 473 |
+
|
| 474 |
+
@property
|
| 475 |
+
def kind(self) -> str:
|
| 476 |
+
return "grpc"
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
__all__ = ("SpeechGrpcTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/grp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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import inspect
|
| 17 |
+
import json
|
| 18 |
+
import logging as std_logging
|
| 19 |
+
import pickle
|
| 20 |
+
import warnings
|
| 21 |
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
|
| 22 |
+
|
| 23 |
+
import google.protobuf.message
|
| 24 |
+
import grpc # type: ignore
|
| 25 |
+
import proto # type: ignore
|
| 26 |
+
from google.api_core import exceptions as core_exceptions
|
| 27 |
+
from google.api_core import gapic_v1, grpc_helpers_async, operations_v1
|
| 28 |
+
from google.api_core import retry_async as retries
|
| 29 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 30 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 31 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 32 |
+
from google.protobuf.json_format import MessageToJson
|
| 33 |
+
from grpc.experimental import aio # type: ignore
|
| 34 |
+
|
| 35 |
+
from google.cloud.speech_v1.types import cloud_speech
|
| 36 |
+
|
| 37 |
+
from .base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 38 |
+
from .grpc import SpeechGrpcTransport
|
| 39 |
+
|
| 40 |
+
try:
|
| 41 |
+
from google.api_core import client_logging # type: ignore
|
| 42 |
+
|
| 43 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 44 |
+
except ImportError: # pragma: NO COVER
|
| 45 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 46 |
+
|
| 47 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class _LoggingClientAIOInterceptor(
|
| 51 |
+
grpc.aio.UnaryUnaryClientInterceptor
|
| 52 |
+
): # pragma: NO COVER
|
| 53 |
+
async def intercept_unary_unary(self, continuation, client_call_details, request):
|
| 54 |
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 55 |
+
std_logging.DEBUG
|
| 56 |
+
)
|
| 57 |
+
if logging_enabled: # pragma: NO COVER
|
| 58 |
+
request_metadata = client_call_details.metadata
|
| 59 |
+
if isinstance(request, proto.Message):
|
| 60 |
+
request_payload = type(request).to_json(request)
|
| 61 |
+
elif isinstance(request, google.protobuf.message.Message):
|
| 62 |
+
request_payload = MessageToJson(request)
|
| 63 |
+
else:
|
| 64 |
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
|
| 65 |
+
|
| 66 |
+
request_metadata = {
|
| 67 |
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
| 68 |
+
for key, value in request_metadata
|
| 69 |
+
}
|
| 70 |
+
grpc_request = {
|
| 71 |
+
"payload": request_payload,
|
| 72 |
+
"requestMethod": "grpc",
|
| 73 |
+
"metadata": dict(request_metadata),
|
| 74 |
+
}
|
| 75 |
+
_LOGGER.debug(
|
| 76 |
+
f"Sending request for {client_call_details.method}",
|
| 77 |
+
extra={
|
| 78 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 79 |
+
"rpcName": str(client_call_details.method),
|
| 80 |
+
"request": grpc_request,
|
| 81 |
+
"metadata": grpc_request["metadata"],
|
| 82 |
+
},
|
| 83 |
+
)
|
| 84 |
+
response = await continuation(client_call_details, request)
|
| 85 |
+
if logging_enabled: # pragma: NO COVER
|
| 86 |
+
response_metadata = await response.trailing_metadata()
|
| 87 |
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
| 88 |
+
metadata = (
|
| 89 |
+
dict([(k, str(v)) for k, v in response_metadata])
|
| 90 |
+
if response_metadata
|
| 91 |
+
else None
|
| 92 |
+
)
|
| 93 |
+
result = await response
|
| 94 |
+
if isinstance(result, proto.Message):
|
| 95 |
+
response_payload = type(result).to_json(result)
|
| 96 |
+
elif isinstance(result, google.protobuf.message.Message):
|
| 97 |
+
response_payload = MessageToJson(result)
|
| 98 |
+
else:
|
| 99 |
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
|
| 100 |
+
grpc_response = {
|
| 101 |
+
"payload": response_payload,
|
| 102 |
+
"metadata": metadata,
|
| 103 |
+
"status": "OK",
|
| 104 |
+
}
|
| 105 |
+
_LOGGER.debug(
|
| 106 |
+
f"Received response to rpc {client_call_details.method}.",
|
| 107 |
+
extra={
|
| 108 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 109 |
+
"rpcName": str(client_call_details.method),
|
| 110 |
+
"response": grpc_response,
|
| 111 |
+
"metadata": grpc_response["metadata"],
|
| 112 |
+
},
|
| 113 |
+
)
|
| 114 |
+
return response
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
class SpeechGrpcAsyncIOTransport(SpeechTransport):
|
| 118 |
+
"""gRPC AsyncIO backend transport for Speech.
|
| 119 |
+
|
| 120 |
+
Service that implements Google Cloud Speech API.
|
| 121 |
+
|
| 122 |
+
This class defines the same methods as the primary client, so the
|
| 123 |
+
primary client can load the underlying transport implementation
|
| 124 |
+
and call it.
|
| 125 |
+
|
| 126 |
+
It sends protocol buffers over the wire using gRPC (which is built on
|
| 127 |
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
| 128 |
+
"""
|
| 129 |
+
|
| 130 |
+
_grpc_channel: aio.Channel
|
| 131 |
+
_stubs: Dict[str, Callable] = {}
|
| 132 |
+
|
| 133 |
+
@classmethod
|
| 134 |
+
def create_channel(
|
| 135 |
+
cls,
|
| 136 |
+
host: str = "speech.googleapis.com",
|
| 137 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 138 |
+
credentials_file: Optional[str] = None,
|
| 139 |
+
scopes: Optional[Sequence[str]] = None,
|
| 140 |
+
quota_project_id: Optional[str] = None,
|
| 141 |
+
**kwargs,
|
| 142 |
+
) -> aio.Channel:
|
| 143 |
+
"""Create and return a gRPC AsyncIO channel object.
|
| 144 |
+
Args:
|
| 145 |
+
host (Optional[str]): The host for the channel to use.
|
| 146 |
+
credentials (Optional[~.Credentials]): The
|
| 147 |
+
authorization credentials to attach to requests. These
|
| 148 |
+
credentials identify this application to the service. If
|
| 149 |
+
none are specified, the client will attempt to ascertain
|
| 150 |
+
the credentials from the environment.
|
| 151 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 152 |
+
be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be
|
| 153 |
+
removed in the next major version of this library.
|
| 154 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 155 |
+
service. These are only used when credentials are not specified and
|
| 156 |
+
are passed to :func:`google.auth.default`.
|
| 157 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 158 |
+
and quota.
|
| 159 |
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
| 160 |
+
channel creation.
|
| 161 |
+
Returns:
|
| 162 |
+
aio.Channel: A gRPC AsyncIO channel object.
|
| 163 |
+
"""
|
| 164 |
+
|
| 165 |
+
return grpc_helpers_async.create_channel(
|
| 166 |
+
host,
|
| 167 |
+
credentials=credentials,
|
| 168 |
+
credentials_file=credentials_file,
|
| 169 |
+
quota_project_id=quota_project_id,
|
| 170 |
+
default_scopes=cls.AUTH_SCOPES,
|
| 171 |
+
scopes=scopes,
|
| 172 |
+
default_host=cls.DEFAULT_HOST,
|
| 173 |
+
**kwargs,
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
def __init__(
|
| 177 |
+
self,
|
| 178 |
+
*,
|
| 179 |
+
host: str = "speech.googleapis.com",
|
| 180 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 181 |
+
credentials_file: Optional[str] = None,
|
| 182 |
+
scopes: Optional[Sequence[str]] = None,
|
| 183 |
+
channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
|
| 184 |
+
api_mtls_endpoint: Optional[str] = None,
|
| 185 |
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 186 |
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
| 187 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 188 |
+
quota_project_id: Optional[str] = None,
|
| 189 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 190 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 191 |
+
api_audience: Optional[str] = None,
|
| 192 |
+
) -> None:
|
| 193 |
+
"""Instantiate the transport.
|
| 194 |
+
|
| 195 |
+
Args:
|
| 196 |
+
host (Optional[str]):
|
| 197 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 198 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 199 |
+
authorization credentials to attach to requests. These
|
| 200 |
+
credentials identify the application to the service; if none
|
| 201 |
+
are specified, the client will attempt to ascertain the
|
| 202 |
+
credentials from the environment.
|
| 203 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 204 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 205 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 206 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 207 |
+
This argument will be removed in the next major version of this library.
|
| 208 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 209 |
+
service. These are only used when credentials are not specified and
|
| 210 |
+
are passed to :func:`google.auth.default`.
|
| 211 |
+
channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
|
| 212 |
+
A ``Channel`` instance through which to make calls, or a Callable
|
| 213 |
+
that constructs and returns one. If set to None, ``self.create_channel``
|
| 214 |
+
is used to create the channel. If a Callable is given, it will be called
|
| 215 |
+
with the same arguments as used in ``self.create_channel``.
|
| 216 |
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
| 217 |
+
If provided, it overrides the ``host`` argument and tries to create
|
| 218 |
+
a mutual TLS channel with client SSL credentials from
|
| 219 |
+
``client_cert_source`` or application default SSL credentials.
|
| 220 |
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 221 |
+
Deprecated. A callback to provide client SSL certificate bytes and
|
| 222 |
+
private key bytes, both in PEM format. It is ignored if
|
| 223 |
+
``api_mtls_endpoint`` is None.
|
| 224 |
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
| 225 |
+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
|
| 226 |
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 227 |
+
A callback to provide client certificate bytes and private key bytes,
|
| 228 |
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
| 229 |
+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
|
| 230 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 231 |
+
and quota.
|
| 232 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 233 |
+
The client info used to send a user-agent string along with
|
| 234 |
+
API requests. If ``None``, then default info will be used.
|
| 235 |
+
Generally, you only need to set this if you're developing
|
| 236 |
+
your own client library.
|
| 237 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 238 |
+
be used for service account credentials.
|
| 239 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 240 |
+
to the service that will be set when using certain 3rd party
|
| 241 |
+
authentication flows. Audience is typically a resource identifier.
|
| 242 |
+
If not set, the host value will be used as a default.
|
| 243 |
+
|
| 244 |
+
Raises:
|
| 245 |
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
| 246 |
+
creation failed for any reason.
|
| 247 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 248 |
+
and ``credentials_file`` are passed.
|
| 249 |
+
"""
|
| 250 |
+
self._grpc_channel = None
|
| 251 |
+
self._ssl_channel_credentials = ssl_channel_credentials
|
| 252 |
+
self._stubs: Dict[str, Callable] = {}
|
| 253 |
+
self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None
|
| 254 |
+
|
| 255 |
+
if api_mtls_endpoint:
|
| 256 |
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
| 257 |
+
if client_cert_source:
|
| 258 |
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
| 259 |
+
|
| 260 |
+
if isinstance(channel, aio.Channel):
|
| 261 |
+
# Ignore credentials if a channel was passed.
|
| 262 |
+
credentials = None
|
| 263 |
+
self._ignore_credentials = True
|
| 264 |
+
# If a channel was explicitly provided, set it.
|
| 265 |
+
self._grpc_channel = channel
|
| 266 |
+
self._ssl_channel_credentials = None
|
| 267 |
+
else:
|
| 268 |
+
if api_mtls_endpoint:
|
| 269 |
+
host = api_mtls_endpoint
|
| 270 |
+
|
| 271 |
+
# Create SSL credentials with client_cert_source or application
|
| 272 |
+
# default SSL credentials.
|
| 273 |
+
if client_cert_source:
|
| 274 |
+
cert, key = client_cert_source()
|
| 275 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 276 |
+
certificate_chain=cert, private_key=key
|
| 277 |
+
)
|
| 278 |
+
else:
|
| 279 |
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
| 280 |
+
|
| 281 |
+
else:
|
| 282 |
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
| 283 |
+
cert, key = client_cert_source_for_mtls()
|
| 284 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 285 |
+
certificate_chain=cert, private_key=key
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
# The base transport sets the host, credentials and scopes
|
| 289 |
+
super().__init__(
|
| 290 |
+
host=host,
|
| 291 |
+
credentials=credentials,
|
| 292 |
+
credentials_file=credentials_file,
|
| 293 |
+
scopes=scopes,
|
| 294 |
+
quota_project_id=quota_project_id,
|
| 295 |
+
client_info=client_info,
|
| 296 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 297 |
+
api_audience=api_audience,
|
| 298 |
+
)
|
| 299 |
+
|
| 300 |
+
if not self._grpc_channel:
|
| 301 |
+
# initialize with the provided callable or the default channel
|
| 302 |
+
channel_init = channel or type(self).create_channel
|
| 303 |
+
self._grpc_channel = channel_init(
|
| 304 |
+
self._host,
|
| 305 |
+
# use the credentials which are saved
|
| 306 |
+
credentials=self._credentials,
|
| 307 |
+
# Set ``credentials_file`` to ``None`` here as
|
| 308 |
+
# the credentials that we saved earlier should be used.
|
| 309 |
+
credentials_file=None,
|
| 310 |
+
scopes=self._scopes,
|
| 311 |
+
ssl_credentials=self._ssl_channel_credentials,
|
| 312 |
+
quota_project_id=quota_project_id,
|
| 313 |
+
options=[
|
| 314 |
+
("grpc.max_send_message_length", -1),
|
| 315 |
+
("grpc.max_receive_message_length", -1),
|
| 316 |
+
],
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
+
self._interceptor = _LoggingClientAIOInterceptor()
|
| 320 |
+
self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
|
| 321 |
+
self._logged_channel = self._grpc_channel
|
| 322 |
+
self._wrap_with_kind = (
|
| 323 |
+
"kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
|
| 324 |
+
)
|
| 325 |
+
# Wrap messages. This must be done after self._logged_channel exists
|
| 326 |
+
self._prep_wrapped_messages(client_info)
|
| 327 |
+
|
| 328 |
+
@property
|
| 329 |
+
def grpc_channel(self) -> aio.Channel:
|
| 330 |
+
"""Create the channel designed to connect to this service.
|
| 331 |
+
|
| 332 |
+
This property caches on the instance; repeated calls return
|
| 333 |
+
the same channel.
|
| 334 |
+
"""
|
| 335 |
+
# Return the channel from cache.
|
| 336 |
+
return self._grpc_channel
|
| 337 |
+
|
| 338 |
+
@property
|
| 339 |
+
def operations_client(self) -> operations_v1.OperationsAsyncClient:
|
| 340 |
+
"""Create the client designed to process long-running operations.
|
| 341 |
+
|
| 342 |
+
This property caches on the instance; repeated calls return the same
|
| 343 |
+
client.
|
| 344 |
+
"""
|
| 345 |
+
# Quick check: Only create a new client if we do not already have one.
|
| 346 |
+
if self._operations_client is None:
|
| 347 |
+
self._operations_client = operations_v1.OperationsAsyncClient(
|
| 348 |
+
self._logged_channel
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
+
# Return the client from cache.
|
| 352 |
+
return self._operations_client
|
| 353 |
+
|
| 354 |
+
@property
|
| 355 |
+
def recognize(
|
| 356 |
+
self,
|
| 357 |
+
) -> Callable[
|
| 358 |
+
[cloud_speech.RecognizeRequest], Awaitable[cloud_speech.RecognizeResponse]
|
| 359 |
+
]:
|
| 360 |
+
r"""Return a callable for the recognize method over gRPC.
|
| 361 |
+
|
| 362 |
+
Performs synchronous speech recognition: receive
|
| 363 |
+
results after all audio has been sent and processed.
|
| 364 |
+
|
| 365 |
+
Returns:
|
| 366 |
+
Callable[[~.RecognizeRequest],
|
| 367 |
+
Awaitable[~.RecognizeResponse]]:
|
| 368 |
+
A function that, when called, will call the underlying RPC
|
| 369 |
+
on the server.
|
| 370 |
+
"""
|
| 371 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 372 |
+
# the request.
|
| 373 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 374 |
+
# to pass in the functions for each.
|
| 375 |
+
if "recognize" not in self._stubs:
|
| 376 |
+
self._stubs["recognize"] = self._logged_channel.unary_unary(
|
| 377 |
+
"/google.cloud.speech.v1.Speech/Recognize",
|
| 378 |
+
request_serializer=cloud_speech.RecognizeRequest.serialize,
|
| 379 |
+
response_deserializer=cloud_speech.RecognizeResponse.deserialize,
|
| 380 |
+
)
|
| 381 |
+
return self._stubs["recognize"]
|
| 382 |
+
|
| 383 |
+
@property
|
| 384 |
+
def long_running_recognize(
|
| 385 |
+
self,
|
| 386 |
+
) -> Callable[
|
| 387 |
+
[cloud_speech.LongRunningRecognizeRequest], Awaitable[operations_pb2.Operation]
|
| 388 |
+
]:
|
| 389 |
+
r"""Return a callable for the long running recognize method over gRPC.
|
| 390 |
+
|
| 391 |
+
Performs asynchronous speech recognition: receive results via
|
| 392 |
+
the google.longrunning.Operations interface. Returns either an
|
| 393 |
+
``Operation.error`` or an ``Operation.response`` which contains
|
| 394 |
+
a ``LongRunningRecognizeResponse`` message. For more information
|
| 395 |
+
on asynchronous speech recognition, see the
|
| 396 |
+
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
|
| 397 |
+
|
| 398 |
+
Returns:
|
| 399 |
+
Callable[[~.LongRunningRecognizeRequest],
|
| 400 |
+
Awaitable[~.Operation]]:
|
| 401 |
+
A function that, when called, will call the underlying RPC
|
| 402 |
+
on the server.
|
| 403 |
+
"""
|
| 404 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 405 |
+
# the request.
|
| 406 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 407 |
+
# to pass in the functions for each.
|
| 408 |
+
if "long_running_recognize" not in self._stubs:
|
| 409 |
+
self._stubs["long_running_recognize"] = self._logged_channel.unary_unary(
|
| 410 |
+
"/google.cloud.speech.v1.Speech/LongRunningRecognize",
|
| 411 |
+
request_serializer=cloud_speech.LongRunningRecognizeRequest.serialize,
|
| 412 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 413 |
+
)
|
| 414 |
+
return self._stubs["long_running_recognize"]
|
| 415 |
+
|
| 416 |
+
@property
|
| 417 |
+
def streaming_recognize(
|
| 418 |
+
self,
|
| 419 |
+
) -> Callable[
|
| 420 |
+
[cloud_speech.StreamingRecognizeRequest],
|
| 421 |
+
Awaitable[cloud_speech.StreamingRecognizeResponse],
|
| 422 |
+
]:
|
| 423 |
+
r"""Return a callable for the streaming recognize method over gRPC.
|
| 424 |
+
|
| 425 |
+
Performs bidirectional streaming speech recognition:
|
| 426 |
+
receive results while sending audio. This method is only
|
| 427 |
+
available via the gRPC API (not REST).
|
| 428 |
+
|
| 429 |
+
Returns:
|
| 430 |
+
Callable[[~.StreamingRecognizeRequest],
|
| 431 |
+
Awaitable[~.StreamingRecognizeResponse]]:
|
| 432 |
+
A function that, when called, will call the underlying RPC
|
| 433 |
+
on the server.
|
| 434 |
+
"""
|
| 435 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 436 |
+
# the request.
|
| 437 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 438 |
+
# to pass in the functions for each.
|
| 439 |
+
if "streaming_recognize" not in self._stubs:
|
| 440 |
+
self._stubs["streaming_recognize"] = self._logged_channel.stream_stream(
|
| 441 |
+
"/google.cloud.speech.v1.Speech/StreamingRecognize",
|
| 442 |
+
request_serializer=cloud_speech.StreamingRecognizeRequest.serialize,
|
| 443 |
+
response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize,
|
| 444 |
+
)
|
| 445 |
+
return self._stubs["streaming_recognize"]
|
| 446 |
+
|
| 447 |
+
def _prep_wrapped_messages(self, client_info):
|
| 448 |
+
"""Precompute the wrapped methods, overriding the base class method to use async wrappers."""
|
| 449 |
+
self._wrapped_methods = {
|
| 450 |
+
self.recognize: self._wrap_method(
|
| 451 |
+
self.recognize,
|
| 452 |
+
default_retry=retries.AsyncRetry(
|
| 453 |
+
initial=0.1,
|
| 454 |
+
maximum=60.0,
|
| 455 |
+
multiplier=1.3,
|
| 456 |
+
predicate=retries.if_exception_type(
|
| 457 |
+
core_exceptions.DeadlineExceeded,
|
| 458 |
+
core_exceptions.ServiceUnavailable,
|
| 459 |
+
),
|
| 460 |
+
deadline=5000.0,
|
| 461 |
+
),
|
| 462 |
+
default_timeout=5000.0,
|
| 463 |
+
client_info=client_info,
|
| 464 |
+
),
|
| 465 |
+
self.long_running_recognize: self._wrap_method(
|
| 466 |
+
self.long_running_recognize,
|
| 467 |
+
default_timeout=5000.0,
|
| 468 |
+
client_info=client_info,
|
| 469 |
+
),
|
| 470 |
+
self.streaming_recognize: self._wrap_method(
|
| 471 |
+
self.streaming_recognize,
|
| 472 |
+
default_retry=retries.AsyncRetry(
|
| 473 |
+
initial=0.1,
|
| 474 |
+
maximum=60.0,
|
| 475 |
+
multiplier=1.3,
|
| 476 |
+
predicate=retries.if_exception_type(
|
| 477 |
+
core_exceptions.DeadlineExceeded,
|
| 478 |
+
core_exceptions.ServiceUnavailable,
|
| 479 |
+
),
|
| 480 |
+
deadline=5000.0,
|
| 481 |
+
),
|
| 482 |
+
default_timeout=5000.0,
|
| 483 |
+
client_info=client_info,
|
| 484 |
+
),
|
| 485 |
+
self.get_operation: self._wrap_method(
|
| 486 |
+
self.get_operation,
|
| 487 |
+
default_timeout=None,
|
| 488 |
+
client_info=client_info,
|
| 489 |
+
),
|
| 490 |
+
self.list_operations: self._wrap_method(
|
| 491 |
+
self.list_operations,
|
| 492 |
+
default_timeout=None,
|
| 493 |
+
client_info=client_info,
|
| 494 |
+
),
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
def _wrap_method(self, func, *args, **kwargs):
|
| 498 |
+
if self._wrap_with_kind: # pragma: NO COVER
|
| 499 |
+
kwargs["kind"] = self.kind
|
| 500 |
+
return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
|
| 501 |
+
|
| 502 |
+
def close(self):
|
| 503 |
+
return self._logged_channel.close()
|
| 504 |
+
|
| 505 |
+
@property
|
| 506 |
+
def kind(self) -> str:
|
| 507 |
+
return "grpc_asyncio"
|
| 508 |
+
|
| 509 |
+
@property
|
| 510 |
+
def get_operation(
|
| 511 |
+
self,
|
| 512 |
+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
|
| 513 |
+
r"""Return a callable for the get_operation method over gRPC."""
|
| 514 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 515 |
+
# the request.
|
| 516 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 517 |
+
# to pass in the functions for each.
|
| 518 |
+
if "get_operation" not in self._stubs:
|
| 519 |
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
| 520 |
+
"/google.longrunning.Operations/GetOperation",
|
| 521 |
+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
| 522 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 523 |
+
)
|
| 524 |
+
return self._stubs["get_operation"]
|
| 525 |
+
|
| 526 |
+
@property
|
| 527 |
+
def list_operations(
|
| 528 |
+
self,
|
| 529 |
+
) -> Callable[
|
| 530 |
+
[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
|
| 531 |
+
]:
|
| 532 |
+
r"""Return a callable for the list_operations method over gRPC."""
|
| 533 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 534 |
+
# the request.
|
| 535 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 536 |
+
# to pass in the functions for each.
|
| 537 |
+
if "list_operations" not in self._stubs:
|
| 538 |
+
self._stubs["list_operations"] = self._logged_channel.unary_unary(
|
| 539 |
+
"/google.longrunning.Operations/ListOperations",
|
| 540 |
+
request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
|
| 541 |
+
response_deserializer=operations_pb2.ListOperationsResponse.FromString,
|
| 542 |
+
)
|
| 543 |
+
return self._stubs["list_operations"]
|
| 544 |
+
|
| 545 |
+
|
| 546 |
+
__all__ = ("S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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import dataclasses
|
| 17 |
+
import json # type: ignore
|
| 18 |
+
import logging
|
| 19 |
+
import warnings
|
| 20 |
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
| 21 |
+
|
| 22 |
+
import google.protobuf
|
| 23 |
+
from google.api_core import exceptions as core_exceptions
|
| 24 |
+
from google.api_core import gapic_v1, operations_v1, rest_helpers, rest_streaming
|
| 25 |
+
from google.api_core import retry as retries
|
| 26 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 27 |
+
from google.auth.transport.requests import AuthorizedSession # type: ignore
|
| 28 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 29 |
+
from google.protobuf import json_format
|
| 30 |
+
from requests import __version__ as requests_version
|
| 31 |
+
|
| 32 |
+
from google.cloud.speech_v1.types import cloud_speech
|
| 33 |
+
|
| 34 |
+
from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
|
| 35 |
+
from .rest_base import _BaseSpeechRestTransport
|
| 36 |
+
|
| 37 |
+
try:
|
| 38 |
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
| 39 |
+
except AttributeError: # pragma: NO COVER
|
| 40 |
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
| 41 |
+
|
| 42 |
+
try:
|
| 43 |
+
from google.api_core import client_logging # type: ignore
|
| 44 |
+
|
| 45 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 46 |
+
except ImportError: # pragma: NO COVER
|
| 47 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 48 |
+
|
| 49 |
+
_LOGGER = logging.getLogger(__name__)
|
| 50 |
+
|
| 51 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 52 |
+
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
|
| 53 |
+
grpc_version=None,
|
| 54 |
+
rest_version=f"requests@{requests_version}",
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 58 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class SpeechRestInterceptor:
|
| 62 |
+
"""Interceptor for Speech.
|
| 63 |
+
|
| 64 |
+
Interceptors are used to manipulate requests, request metadata, and responses
|
| 65 |
+
in arbitrary ways.
|
| 66 |
+
Example use cases include:
|
| 67 |
+
* Logging
|
| 68 |
+
* Verifying requests according to service or custom semantics
|
| 69 |
+
* Stripping extraneous information from responses
|
| 70 |
+
|
| 71 |
+
These use cases and more can be enabled by injecting an
|
| 72 |
+
instance of a custom subclass when constructing the SpeechRestTransport.
|
| 73 |
+
|
| 74 |
+
.. code-block:: python
|
| 75 |
+
class MyCustomSpeechInterceptor(SpeechRestInterceptor):
|
| 76 |
+
def pre_long_running_recognize(self, request, metadata):
|
| 77 |
+
logging.log(f"Received request: {request}")
|
| 78 |
+
return request, metadata
|
| 79 |
+
|
| 80 |
+
def post_long_running_recognize(self, response):
|
| 81 |
+
logging.log(f"Received response: {response}")
|
| 82 |
+
return response
|
| 83 |
+
|
| 84 |
+
def pre_recognize(self, request, metadata):
|
| 85 |
+
logging.log(f"Received request: {request}")
|
| 86 |
+
return request, metadata
|
| 87 |
+
|
| 88 |
+
def post_recognize(self, response):
|
| 89 |
+
logging.log(f"Received response: {response}")
|
| 90 |
+
return response
|
| 91 |
+
|
| 92 |
+
transport = SpeechRestTransport(interceptor=MyCustomSpeechInterceptor())
|
| 93 |
+
client = SpeechClient(transport=transport)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
"""
|
| 97 |
+
|
| 98 |
+
def pre_long_running_recognize(
|
| 99 |
+
self,
|
| 100 |
+
request: cloud_speech.LongRunningRecognizeRequest,
|
| 101 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 102 |
+
) -> Tuple[
|
| 103 |
+
cloud_speech.LongRunningRecognizeRequest,
|
| 104 |
+
Sequence[Tuple[str, Union[str, bytes]]],
|
| 105 |
+
]:
|
| 106 |
+
"""Pre-rpc interceptor for long_running_recognize
|
| 107 |
+
|
| 108 |
+
Override in a subclass to manipulate the request or metadata
|
| 109 |
+
before they are sent to the Speech server.
|
| 110 |
+
"""
|
| 111 |
+
return request, metadata
|
| 112 |
+
|
| 113 |
+
def post_long_running_recognize(
|
| 114 |
+
self, response: operations_pb2.Operation
|
| 115 |
+
) -> operations_pb2.Operation:
|
| 116 |
+
"""Post-rpc interceptor for long_running_recognize
|
| 117 |
+
|
| 118 |
+
DEPRECATED. Please use the `post_long_running_recognize_with_metadata`
|
| 119 |
+
interceptor instead.
|
| 120 |
+
|
| 121 |
+
Override in a subclass to read or manipulate the response
|
| 122 |
+
after it is returned by the Speech server but before
|
| 123 |
+
it is returned to user code. This `post_long_running_recognize` interceptor runs
|
| 124 |
+
before the `post_long_running_recognize_with_metadata` interceptor.
|
| 125 |
+
"""
|
| 126 |
+
return response
|
| 127 |
+
|
| 128 |
+
def post_long_running_recognize_with_metadata(
|
| 129 |
+
self,
|
| 130 |
+
response: operations_pb2.Operation,
|
| 131 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 132 |
+
) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]:
|
| 133 |
+
"""Post-rpc interceptor for long_running_recognize
|
| 134 |
+
|
| 135 |
+
Override in a subclass to read or manipulate the response or metadata after it
|
| 136 |
+
is returned by the Speech server but before it is returned to user code.
|
| 137 |
+
|
| 138 |
+
We recommend only using this `post_long_running_recognize_with_metadata`
|
| 139 |
+
interceptor in new development instead of the `post_long_running_recognize` interceptor.
|
| 140 |
+
When both interceptors are used, this `post_long_running_recognize_with_metadata` interceptor runs after the
|
| 141 |
+
`post_long_running_recognize` interceptor. The (possibly modified) response returned by
|
| 142 |
+
`post_long_running_recognize` will be passed to
|
| 143 |
+
`post_long_running_recognize_with_metadata`.
|
| 144 |
+
"""
|
| 145 |
+
return response, metadata
|
| 146 |
+
|
| 147 |
+
def pre_recognize(
|
| 148 |
+
self,
|
| 149 |
+
request: cloud_speech.RecognizeRequest,
|
| 150 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 151 |
+
) -> Tuple[cloud_speech.RecognizeRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
| 152 |
+
"""Pre-rpc interceptor for recognize
|
| 153 |
+
|
| 154 |
+
Override in a subclass to manipulate the request or metadata
|
| 155 |
+
before they are sent to the Speech server.
|
| 156 |
+
"""
|
| 157 |
+
return request, metadata
|
| 158 |
+
|
| 159 |
+
def post_recognize(
|
| 160 |
+
self, response: cloud_speech.RecognizeResponse
|
| 161 |
+
) -> cloud_speech.RecognizeResponse:
|
| 162 |
+
"""Post-rpc interceptor for recognize
|
| 163 |
+
|
| 164 |
+
DEPRECATED. Please use the `post_recognize_with_metadata`
|
| 165 |
+
interceptor instead.
|
| 166 |
+
|
| 167 |
+
Override in a subclass to read or manipulate the response
|
| 168 |
+
after it is returned by the Speech server but before
|
| 169 |
+
it is returned to user code. This `post_recognize` interceptor runs
|
| 170 |
+
before the `post_recognize_with_metadata` interceptor.
|
| 171 |
+
"""
|
| 172 |
+
return response
|
| 173 |
+
|
| 174 |
+
def post_recognize_with_metadata(
|
| 175 |
+
self,
|
| 176 |
+
response: cloud_speech.RecognizeResponse,
|
| 177 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 178 |
+
) -> Tuple[cloud_speech.RecognizeResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
|
| 179 |
+
"""Post-rpc interceptor for recognize
|
| 180 |
+
|
| 181 |
+
Override in a subclass to read or manipulate the response or metadata after it
|
| 182 |
+
is returned by the Speech server but before it is returned to user code.
|
| 183 |
+
|
| 184 |
+
We recommend only using this `post_recognize_with_metadata`
|
| 185 |
+
interceptor in new development instead of the `post_recognize` interceptor.
|
| 186 |
+
When both interceptors are used, this `post_recognize_with_metadata` interceptor runs after the
|
| 187 |
+
`post_recognize` interceptor. The (possibly modified) response returned by
|
| 188 |
+
`post_recognize` will be passed to
|
| 189 |
+
`post_recognize_with_metadata`.
|
| 190 |
+
"""
|
| 191 |
+
return response, metadata
|
| 192 |
+
|
| 193 |
+
def pre_get_operation(
|
| 194 |
+
self,
|
| 195 |
+
request: operations_pb2.GetOperationRequest,
|
| 196 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 197 |
+
) -> Tuple[
|
| 198 |
+
operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
| 199 |
+
]:
|
| 200 |
+
"""Pre-rpc interceptor for get_operation
|
| 201 |
+
|
| 202 |
+
Override in a subclass to manipulate the request or metadata
|
| 203 |
+
before they are sent to the Speech server.
|
| 204 |
+
"""
|
| 205 |
+
return request, metadata
|
| 206 |
+
|
| 207 |
+
def post_get_operation(
|
| 208 |
+
self, response: operations_pb2.Operation
|
| 209 |
+
) -> operations_pb2.Operation:
|
| 210 |
+
"""Post-rpc interceptor for get_operation
|
| 211 |
+
|
| 212 |
+
Override in a subclass to manipulate the response
|
| 213 |
+
after it is returned by the Speech server but before
|
| 214 |
+
it is returned to user code.
|
| 215 |
+
"""
|
| 216 |
+
return response
|
| 217 |
+
|
| 218 |
+
def pre_list_operations(
|
| 219 |
+
self,
|
| 220 |
+
request: operations_pb2.ListOperationsRequest,
|
| 221 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 222 |
+
) -> Tuple[
|
| 223 |
+
operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
| 224 |
+
]:
|
| 225 |
+
"""Pre-rpc interceptor for list_operations
|
| 226 |
+
|
| 227 |
+
Override in a subclass to manipulate the request or metadata
|
| 228 |
+
before they are sent to the Speech server.
|
| 229 |
+
"""
|
| 230 |
+
return request, metadata
|
| 231 |
+
|
| 232 |
+
def post_list_operations(
|
| 233 |
+
self, response: operations_pb2.ListOperationsResponse
|
| 234 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 235 |
+
"""Post-rpc interceptor for list_operations
|
| 236 |
+
|
| 237 |
+
Override in a subclass to manipulate the response
|
| 238 |
+
after it is returned by the Speech server but before
|
| 239 |
+
it is returned to user code.
|
| 240 |
+
"""
|
| 241 |
+
return response
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
@dataclasses.dataclass
|
| 245 |
+
class SpeechRestStub:
|
| 246 |
+
_session: AuthorizedSession
|
| 247 |
+
_host: str
|
| 248 |
+
_interceptor: SpeechRestInterceptor
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
class SpeechRestTransport(_BaseSpeechRestTransport):
|
| 252 |
+
"""REST backend synchronous transport for Speech.
|
| 253 |
+
|
| 254 |
+
Service that implements Google Cloud Speech API.
|
| 255 |
+
|
| 256 |
+
This class defines the same methods as the primary client, so the
|
| 257 |
+
primary client can load the underlying transport implementation
|
| 258 |
+
and call it.
|
| 259 |
+
|
| 260 |
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
| 261 |
+
"""
|
| 262 |
+
|
| 263 |
+
def __init__(
|
| 264 |
+
self,
|
| 265 |
+
*,
|
| 266 |
+
host: str = "speech.googleapis.com",
|
| 267 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 268 |
+
credentials_file: Optional[str] = None,
|
| 269 |
+
scopes: Optional[Sequence[str]] = None,
|
| 270 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 271 |
+
quota_project_id: Optional[str] = None,
|
| 272 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 273 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 274 |
+
url_scheme: str = "https",
|
| 275 |
+
interceptor: Optional[SpeechRestInterceptor] = None,
|
| 276 |
+
api_audience: Optional[str] = None,
|
| 277 |
+
) -> None:
|
| 278 |
+
"""Instantiate the transport.
|
| 279 |
+
|
| 280 |
+
Args:
|
| 281 |
+
host (Optional[str]):
|
| 282 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 283 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 284 |
+
authorization credentials to attach to requests. These
|
| 285 |
+
credentials identify the application to the service; if none
|
| 286 |
+
are specified, the client will attempt to ascertain the
|
| 287 |
+
credentials from the environment.
|
| 288 |
+
|
| 289 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 290 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 291 |
+
This argument is ignored if ``channel`` is provided. This argument will be
|
| 292 |
+
removed in the next major version of this library.
|
| 293 |
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
| 294 |
+
ignored if ``channel`` is provided.
|
| 295 |
+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
|
| 296 |
+
certificate to configure mutual TLS HTTP channel. It is ignored
|
| 297 |
+
if ``channel`` is provided.
|
| 298 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 299 |
+
and quota.
|
| 300 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 301 |
+
The client info used to send a user-agent string along with
|
| 302 |
+
API requests. If ``None``, then default info will be used.
|
| 303 |
+
Generally, you only need to set this if you are developing
|
| 304 |
+
your own client library.
|
| 305 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 306 |
+
be used for service account credentials.
|
| 307 |
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
| 308 |
+
"https", but for testing or local servers,
|
| 309 |
+
"http" can be specified.
|
| 310 |
+
interceptor (Optional[SpeechRestInterceptor]): Interceptor used
|
| 311 |
+
to manipulate requests, request metadata, and responses.
|
| 312 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 313 |
+
to the service that will be set when using certain 3rd party
|
| 314 |
+
authentication flows. Audience is typically a resource identifier.
|
| 315 |
+
If not set, the host value will be used as a default.
|
| 316 |
+
"""
|
| 317 |
+
# Run the base constructor
|
| 318 |
+
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
|
| 319 |
+
# TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
|
| 320 |
+
# credentials object
|
| 321 |
+
super().__init__(
|
| 322 |
+
host=host,
|
| 323 |
+
credentials=credentials,
|
| 324 |
+
client_info=client_info,
|
| 325 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 326 |
+
url_scheme=url_scheme,
|
| 327 |
+
api_audience=api_audience,
|
| 328 |
+
)
|
| 329 |
+
self._session = AuthorizedSession(
|
| 330 |
+
self._credentials, default_host=self.DEFAULT_HOST
|
| 331 |
+
)
|
| 332 |
+
self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None
|
| 333 |
+
if client_cert_source_for_mtls:
|
| 334 |
+
self._session.configure_mtls_channel(client_cert_source_for_mtls)
|
| 335 |
+
self._interceptor = interceptor or SpeechRestInterceptor()
|
| 336 |
+
self._prep_wrapped_messages(client_info)
|
| 337 |
+
|
| 338 |
+
@property
|
| 339 |
+
def operations_client(self) -> operations_v1.AbstractOperationsClient:
|
| 340 |
+
"""Create the client designed to process long-running operations.
|
| 341 |
+
|
| 342 |
+
This property caches on the instance; repeated calls return the same
|
| 343 |
+
client.
|
| 344 |
+
"""
|
| 345 |
+
# Only create a new client if we do not already have one.
|
| 346 |
+
if self._operations_client is None:
|
| 347 |
+
http_options: Dict[str, List[Dict[str, str]]] = {
|
| 348 |
+
"google.longrunning.Operations.GetOperation": [
|
| 349 |
+
{
|
| 350 |
+
"method": "get",
|
| 351 |
+
"uri": "/v1/operations/{name=**}",
|
| 352 |
+
},
|
| 353 |
+
],
|
| 354 |
+
"google.longrunning.Operations.ListOperations": [
|
| 355 |
+
{
|
| 356 |
+
"method": "get",
|
| 357 |
+
"uri": "/v1/operations",
|
| 358 |
+
},
|
| 359 |
+
],
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
rest_transport = operations_v1.OperationsRestTransport(
|
| 363 |
+
host=self._host,
|
| 364 |
+
# use the credentials which are saved
|
| 365 |
+
credentials=self._credentials,
|
| 366 |
+
scopes=self._scopes,
|
| 367 |
+
http_options=http_options,
|
| 368 |
+
path_prefix="v1",
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
self._operations_client = operations_v1.AbstractOperationsClient(
|
| 372 |
+
transport=rest_transport
|
| 373 |
+
)
|
| 374 |
+
|
| 375 |
+
# Return the client from cache.
|
| 376 |
+
return self._operations_client
|
| 377 |
+
|
| 378 |
+
class _LongRunningRecognize(
|
| 379 |
+
_BaseSpeechRestTransport._BaseLongRunningRecognize, SpeechRestStub
|
| 380 |
+
):
|
| 381 |
+
def __hash__(self):
|
| 382 |
+
return hash("SpeechRestTransport.LongRunningRecognize")
|
| 383 |
+
|
| 384 |
+
@staticmethod
|
| 385 |
+
def _get_response(
|
| 386 |
+
host,
|
| 387 |
+
metadata,
|
| 388 |
+
query_params,
|
| 389 |
+
session,
|
| 390 |
+
timeout,
|
| 391 |
+
transcoded_request,
|
| 392 |
+
body=None,
|
| 393 |
+
):
|
| 394 |
+
uri = transcoded_request["uri"]
|
| 395 |
+
method = transcoded_request["method"]
|
| 396 |
+
headers = dict(metadata)
|
| 397 |
+
headers["Content-Type"] = "application/json"
|
| 398 |
+
response = getattr(session, method)(
|
| 399 |
+
"{host}{uri}".format(host=host, uri=uri),
|
| 400 |
+
timeout=timeout,
|
| 401 |
+
headers=headers,
|
| 402 |
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
| 403 |
+
data=body,
|
| 404 |
+
)
|
| 405 |
+
return response
|
| 406 |
+
|
| 407 |
+
def __call__(
|
| 408 |
+
self,
|
| 409 |
+
request: cloud_speech.LongRunningRecognizeRequest,
|
| 410 |
+
*,
|
| 411 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 412 |
+
timeout: Optional[float] = None,
|
| 413 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 414 |
+
) -> operations_pb2.Operation:
|
| 415 |
+
r"""Call the long running recognize method over HTTP.
|
| 416 |
+
|
| 417 |
+
Args:
|
| 418 |
+
request (~.cloud_speech.LongRunningRecognizeRequest):
|
| 419 |
+
The request object. The top-level message sent by the client for the
|
| 420 |
+
``LongRunningRecognize`` method.
|
| 421 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 422 |
+
should be retried.
|
| 423 |
+
timeout (float): The timeout for this request.
|
| 424 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 425 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 426 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 427 |
+
be of type `bytes`.
|
| 428 |
+
|
| 429 |
+
Returns:
|
| 430 |
+
~.operations_pb2.Operation:
|
| 431 |
+
This resource represents a
|
| 432 |
+
long-running operation that is the
|
| 433 |
+
result of a network API call.
|
| 434 |
+
|
| 435 |
+
"""
|
| 436 |
+
|
| 437 |
+
http_options = (
|
| 438 |
+
_BaseSpeechRestTransport._BaseLongRunningRecognize._get_http_options()
|
| 439 |
+
)
|
| 440 |
+
|
| 441 |
+
request, metadata = self._interceptor.pre_long_running_recognize(
|
| 442 |
+
request, metadata
|
| 443 |
+
)
|
| 444 |
+
transcoded_request = _BaseSpeechRestTransport._BaseLongRunningRecognize._get_transcoded_request(
|
| 445 |
+
http_options, request
|
| 446 |
+
)
|
| 447 |
+
|
| 448 |
+
body = _BaseSpeechRestTransport._BaseLongRunningRecognize._get_request_body_json(
|
| 449 |
+
transcoded_request
|
| 450 |
+
)
|
| 451 |
+
|
| 452 |
+
# Jsonify the query params
|
| 453 |
+
query_params = _BaseSpeechRestTransport._BaseLongRunningRecognize._get_query_params_json(
|
| 454 |
+
transcoded_request
|
| 455 |
+
)
|
| 456 |
+
|
| 457 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 458 |
+
logging.DEBUG
|
| 459 |
+
): # pragma: NO COVER
|
| 460 |
+
request_url = "{host}{uri}".format(
|
| 461 |
+
host=self._host, uri=transcoded_request["uri"]
|
| 462 |
+
)
|
| 463 |
+
method = transcoded_request["method"]
|
| 464 |
+
try:
|
| 465 |
+
request_payload = type(request).to_json(request)
|
| 466 |
+
except:
|
| 467 |
+
request_payload = None
|
| 468 |
+
http_request = {
|
| 469 |
+
"payload": request_payload,
|
| 470 |
+
"requestMethod": method,
|
| 471 |
+
"requestUrl": request_url,
|
| 472 |
+
"headers": dict(metadata),
|
| 473 |
+
}
|
| 474 |
+
_LOGGER.debug(
|
| 475 |
+
f"Sending request for google.cloud.speech_v1.SpeechClient.LongRunningRecognize",
|
| 476 |
+
extra={
|
| 477 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 478 |
+
"rpcName": "LongRunningRecognize",
|
| 479 |
+
"httpRequest": http_request,
|
| 480 |
+
"metadata": http_request["headers"],
|
| 481 |
+
},
|
| 482 |
+
)
|
| 483 |
+
|
| 484 |
+
# Send the request
|
| 485 |
+
response = SpeechRestTransport._LongRunningRecognize._get_response(
|
| 486 |
+
self._host,
|
| 487 |
+
metadata,
|
| 488 |
+
query_params,
|
| 489 |
+
self._session,
|
| 490 |
+
timeout,
|
| 491 |
+
transcoded_request,
|
| 492 |
+
body,
|
| 493 |
+
)
|
| 494 |
+
|
| 495 |
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
| 496 |
+
# subclass.
|
| 497 |
+
if response.status_code >= 400:
|
| 498 |
+
raise core_exceptions.from_http_response(response)
|
| 499 |
+
|
| 500 |
+
# Return the response
|
| 501 |
+
resp = operations_pb2.Operation()
|
| 502 |
+
json_format.Parse(response.content, resp, ignore_unknown_fields=True)
|
| 503 |
+
|
| 504 |
+
resp = self._interceptor.post_long_running_recognize(resp)
|
| 505 |
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
| 506 |
+
resp, _ = self._interceptor.post_long_running_recognize_with_metadata(
|
| 507 |
+
resp, response_metadata
|
| 508 |
+
)
|
| 509 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 510 |
+
logging.DEBUG
|
| 511 |
+
): # pragma: NO COVER
|
| 512 |
+
try:
|
| 513 |
+
response_payload = json_format.MessageToJson(resp)
|
| 514 |
+
except:
|
| 515 |
+
response_payload = None
|
| 516 |
+
http_response = {
|
| 517 |
+
"payload": response_payload,
|
| 518 |
+
"headers": dict(response.headers),
|
| 519 |
+
"status": response.status_code,
|
| 520 |
+
}
|
| 521 |
+
_LOGGER.debug(
|
| 522 |
+
"Received response for google.cloud.speech_v1.SpeechClient.long_running_recognize",
|
| 523 |
+
extra={
|
| 524 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 525 |
+
"rpcName": "LongRunningRecognize",
|
| 526 |
+
"metadata": http_response["headers"],
|
| 527 |
+
"httpResponse": http_response,
|
| 528 |
+
},
|
| 529 |
+
)
|
| 530 |
+
return resp
|
| 531 |
+
|
| 532 |
+
class _Recognize(_BaseSpeechRestTransport._BaseRecognize, SpeechRestStub):
|
| 533 |
+
def __hash__(self):
|
| 534 |
+
return hash("SpeechRestTransport.Recognize")
|
| 535 |
+
|
| 536 |
+
@staticmethod
|
| 537 |
+
def _get_response(
|
| 538 |
+
host,
|
| 539 |
+
metadata,
|
| 540 |
+
query_params,
|
| 541 |
+
session,
|
| 542 |
+
timeout,
|
| 543 |
+
transcoded_request,
|
| 544 |
+
body=None,
|
| 545 |
+
):
|
| 546 |
+
uri = transcoded_request["uri"]
|
| 547 |
+
method = transcoded_request["method"]
|
| 548 |
+
headers = dict(metadata)
|
| 549 |
+
headers["Content-Type"] = "application/json"
|
| 550 |
+
response = getattr(session, method)(
|
| 551 |
+
"{host}{uri}".format(host=host, uri=uri),
|
| 552 |
+
timeout=timeout,
|
| 553 |
+
headers=headers,
|
| 554 |
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
| 555 |
+
data=body,
|
| 556 |
+
)
|
| 557 |
+
return response
|
| 558 |
+
|
| 559 |
+
def __call__(
|
| 560 |
+
self,
|
| 561 |
+
request: cloud_speech.RecognizeRequest,
|
| 562 |
+
*,
|
| 563 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 564 |
+
timeout: Optional[float] = None,
|
| 565 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 566 |
+
) -> cloud_speech.RecognizeResponse:
|
| 567 |
+
r"""Call the recognize method over HTTP.
|
| 568 |
+
|
| 569 |
+
Args:
|
| 570 |
+
request (~.cloud_speech.RecognizeRequest):
|
| 571 |
+
The request object. The top-level message sent by the client for the
|
| 572 |
+
``Recognize`` method.
|
| 573 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 574 |
+
should be retried.
|
| 575 |
+
timeout (float): The timeout for this request.
|
| 576 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 577 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 578 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 579 |
+
be of type `bytes`.
|
| 580 |
+
|
| 581 |
+
Returns:
|
| 582 |
+
~.cloud_speech.RecognizeResponse:
|
| 583 |
+
The only message returned to the client by the
|
| 584 |
+
``Recognize`` method. It contains the result as zero or
|
| 585 |
+
more sequential ``SpeechRecognitionResult`` messages.
|
| 586 |
+
|
| 587 |
+
"""
|
| 588 |
+
|
| 589 |
+
http_options = _BaseSpeechRestTransport._BaseRecognize._get_http_options()
|
| 590 |
+
|
| 591 |
+
request, metadata = self._interceptor.pre_recognize(request, metadata)
|
| 592 |
+
transcoded_request = (
|
| 593 |
+
_BaseSpeechRestTransport._BaseRecognize._get_transcoded_request(
|
| 594 |
+
http_options, request
|
| 595 |
+
)
|
| 596 |
+
)
|
| 597 |
+
|
| 598 |
+
body = _BaseSpeechRestTransport._BaseRecognize._get_request_body_json(
|
| 599 |
+
transcoded_request
|
| 600 |
+
)
|
| 601 |
+
|
| 602 |
+
# Jsonify the query params
|
| 603 |
+
query_params = (
|
| 604 |
+
_BaseSpeechRestTransport._BaseRecognize._get_query_params_json(
|
| 605 |
+
transcoded_request
|
| 606 |
+
)
|
| 607 |
+
)
|
| 608 |
+
|
| 609 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 610 |
+
logging.DEBUG
|
| 611 |
+
): # pragma: NO COVER
|
| 612 |
+
request_url = "{host}{uri}".format(
|
| 613 |
+
host=self._host, uri=transcoded_request["uri"]
|
| 614 |
+
)
|
| 615 |
+
method = transcoded_request["method"]
|
| 616 |
+
try:
|
| 617 |
+
request_payload = type(request).to_json(request)
|
| 618 |
+
except:
|
| 619 |
+
request_payload = None
|
| 620 |
+
http_request = {
|
| 621 |
+
"payload": request_payload,
|
| 622 |
+
"requestMethod": method,
|
| 623 |
+
"requestUrl": request_url,
|
| 624 |
+
"headers": dict(metadata),
|
| 625 |
+
}
|
| 626 |
+
_LOGGER.debug(
|
| 627 |
+
f"Sending request for google.cloud.speech_v1.SpeechClient.Recognize",
|
| 628 |
+
extra={
|
| 629 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 630 |
+
"rpcName": "Recognize",
|
| 631 |
+
"httpRequest": http_request,
|
| 632 |
+
"metadata": http_request["headers"],
|
| 633 |
+
},
|
| 634 |
+
)
|
| 635 |
+
|
| 636 |
+
# Send the request
|
| 637 |
+
response = SpeechRestTransport._Recognize._get_response(
|
| 638 |
+
self._host,
|
| 639 |
+
metadata,
|
| 640 |
+
query_params,
|
| 641 |
+
self._session,
|
| 642 |
+
timeout,
|
| 643 |
+
transcoded_request,
|
| 644 |
+
body,
|
| 645 |
+
)
|
| 646 |
+
|
| 647 |
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
| 648 |
+
# subclass.
|
| 649 |
+
if response.status_code >= 400:
|
| 650 |
+
raise core_exceptions.from_http_response(response)
|
| 651 |
+
|
| 652 |
+
# Return the response
|
| 653 |
+
resp = cloud_speech.RecognizeResponse()
|
| 654 |
+
pb_resp = cloud_speech.RecognizeResponse.pb(resp)
|
| 655 |
+
|
| 656 |
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
| 657 |
+
|
| 658 |
+
resp = self._interceptor.post_recognize(resp)
|
| 659 |
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
| 660 |
+
resp, _ = self._interceptor.post_recognize_with_metadata(
|
| 661 |
+
resp, response_metadata
|
| 662 |
+
)
|
| 663 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 664 |
+
logging.DEBUG
|
| 665 |
+
): # pragma: NO COVER
|
| 666 |
+
try:
|
| 667 |
+
response_payload = cloud_speech.RecognizeResponse.to_json(response)
|
| 668 |
+
except:
|
| 669 |
+
response_payload = None
|
| 670 |
+
http_response = {
|
| 671 |
+
"payload": response_payload,
|
| 672 |
+
"headers": dict(response.headers),
|
| 673 |
+
"status": response.status_code,
|
| 674 |
+
}
|
| 675 |
+
_LOGGER.debug(
|
| 676 |
+
"Received response for google.cloud.speech_v1.SpeechClient.recognize",
|
| 677 |
+
extra={
|
| 678 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 679 |
+
"rpcName": "Recognize",
|
| 680 |
+
"metadata": http_response["headers"],
|
| 681 |
+
"httpResponse": http_response,
|
| 682 |
+
},
|
| 683 |
+
)
|
| 684 |
+
return resp
|
| 685 |
+
|
| 686 |
+
class _StreamingRecognize(
|
| 687 |
+
_BaseSpeechRestTransport._BaseStreamingRecognize, SpeechRestStub
|
| 688 |
+
):
|
| 689 |
+
def __hash__(self):
|
| 690 |
+
return hash("SpeechRestTransport.StreamingRecognize")
|
| 691 |
+
|
| 692 |
+
def __call__(
|
| 693 |
+
self,
|
| 694 |
+
request: cloud_speech.StreamingRecognizeRequest,
|
| 695 |
+
*,
|
| 696 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 697 |
+
timeout: Optional[float] = None,
|
| 698 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 699 |
+
) -> rest_streaming.ResponseIterator:
|
| 700 |
+
raise NotImplementedError(
|
| 701 |
+
"Method StreamingRecognize is not available over REST transport"
|
| 702 |
+
)
|
| 703 |
+
|
| 704 |
+
@property
|
| 705 |
+
def long_running_recognize(
|
| 706 |
+
self,
|
| 707 |
+
) -> Callable[[cloud_speech.LongRunningRecognizeRequest], operations_pb2.Operation]:
|
| 708 |
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
| 709 |
+
# In C++ this would require a dynamic_cast
|
| 710 |
+
return self._LongRunningRecognize(self._session, self._host, self._interceptor) # type: ignore
|
| 711 |
+
|
| 712 |
+
@property
|
| 713 |
+
def recognize(
|
| 714 |
+
self,
|
| 715 |
+
) -> Callable[[cloud_speech.RecognizeRequest], cloud_speech.RecognizeResponse]:
|
| 716 |
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
| 717 |
+
# In C++ this would require a dynamic_cast
|
| 718 |
+
return self._Recognize(self._session, self._host, self._interceptor) # type: ignore
|
| 719 |
+
|
| 720 |
+
@property
|
| 721 |
+
def streaming_recognize(
|
| 722 |
+
self,
|
| 723 |
+
) -> Callable[
|
| 724 |
+
[cloud_speech.StreamingRecognizeRequest],
|
| 725 |
+
cloud_speech.StreamingRecognizeResponse,
|
| 726 |
+
]:
|
| 727 |
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
| 728 |
+
# In C++ this would require a dynamic_cast
|
| 729 |
+
return self._StreamingRecognize(self._session, self._host, self._interceptor) # type: ignore
|
| 730 |
+
|
| 731 |
+
@property
|
| 732 |
+
def get_operation(self):
|
| 733 |
+
return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore
|
| 734 |
+
|
| 735 |
+
class _GetOperation(_BaseSpeechRestTransport._BaseGetOperation, SpeechRestStub):
|
| 736 |
+
def __hash__(self):
|
| 737 |
+
return hash("SpeechRestTransport.GetOperation")
|
| 738 |
+
|
| 739 |
+
@staticmethod
|
| 740 |
+
def _get_response(
|
| 741 |
+
host,
|
| 742 |
+
metadata,
|
| 743 |
+
query_params,
|
| 744 |
+
session,
|
| 745 |
+
timeout,
|
| 746 |
+
transcoded_request,
|
| 747 |
+
body=None,
|
| 748 |
+
):
|
| 749 |
+
uri = transcoded_request["uri"]
|
| 750 |
+
method = transcoded_request["method"]
|
| 751 |
+
headers = dict(metadata)
|
| 752 |
+
headers["Content-Type"] = "application/json"
|
| 753 |
+
response = getattr(session, method)(
|
| 754 |
+
"{host}{uri}".format(host=host, uri=uri),
|
| 755 |
+
timeout=timeout,
|
| 756 |
+
headers=headers,
|
| 757 |
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
| 758 |
+
)
|
| 759 |
+
return response
|
| 760 |
+
|
| 761 |
+
def __call__(
|
| 762 |
+
self,
|
| 763 |
+
request: operations_pb2.GetOperationRequest,
|
| 764 |
+
*,
|
| 765 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 766 |
+
timeout: Optional[float] = None,
|
| 767 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 768 |
+
) -> operations_pb2.Operation:
|
| 769 |
+
r"""Call the get operation method over HTTP.
|
| 770 |
+
|
| 771 |
+
Args:
|
| 772 |
+
request (operations_pb2.GetOperationRequest):
|
| 773 |
+
The request object for GetOperation method.
|
| 774 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 775 |
+
should be retried.
|
| 776 |
+
timeout (float): The timeout for this request.
|
| 777 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 778 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 779 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 780 |
+
be of type `bytes`.
|
| 781 |
+
|
| 782 |
+
Returns:
|
| 783 |
+
operations_pb2.Operation: Response from GetOperation method.
|
| 784 |
+
"""
|
| 785 |
+
|
| 786 |
+
http_options = (
|
| 787 |
+
_BaseSpeechRestTransport._BaseGetOperation._get_http_options()
|
| 788 |
+
)
|
| 789 |
+
|
| 790 |
+
request, metadata = self._interceptor.pre_get_operation(request, metadata)
|
| 791 |
+
transcoded_request = (
|
| 792 |
+
_BaseSpeechRestTransport._BaseGetOperation._get_transcoded_request(
|
| 793 |
+
http_options, request
|
| 794 |
+
)
|
| 795 |
+
)
|
| 796 |
+
|
| 797 |
+
# Jsonify the query params
|
| 798 |
+
query_params = (
|
| 799 |
+
_BaseSpeechRestTransport._BaseGetOperation._get_query_params_json(
|
| 800 |
+
transcoded_request
|
| 801 |
+
)
|
| 802 |
+
)
|
| 803 |
+
|
| 804 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 805 |
+
logging.DEBUG
|
| 806 |
+
): # pragma: NO COVER
|
| 807 |
+
request_url = "{host}{uri}".format(
|
| 808 |
+
host=self._host, uri=transcoded_request["uri"]
|
| 809 |
+
)
|
| 810 |
+
method = transcoded_request["method"]
|
| 811 |
+
try:
|
| 812 |
+
request_payload = json_format.MessageToJson(request)
|
| 813 |
+
except:
|
| 814 |
+
request_payload = None
|
| 815 |
+
http_request = {
|
| 816 |
+
"payload": request_payload,
|
| 817 |
+
"requestMethod": method,
|
| 818 |
+
"requestUrl": request_url,
|
| 819 |
+
"headers": dict(metadata),
|
| 820 |
+
}
|
| 821 |
+
_LOGGER.debug(
|
| 822 |
+
f"Sending request for google.cloud.speech_v1.SpeechClient.GetOperation",
|
| 823 |
+
extra={
|
| 824 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 825 |
+
"rpcName": "GetOperation",
|
| 826 |
+
"httpRequest": http_request,
|
| 827 |
+
"metadata": http_request["headers"],
|
| 828 |
+
},
|
| 829 |
+
)
|
| 830 |
+
|
| 831 |
+
# Send the request
|
| 832 |
+
response = SpeechRestTransport._GetOperation._get_response(
|
| 833 |
+
self._host,
|
| 834 |
+
metadata,
|
| 835 |
+
query_params,
|
| 836 |
+
self._session,
|
| 837 |
+
timeout,
|
| 838 |
+
transcoded_request,
|
| 839 |
+
)
|
| 840 |
+
|
| 841 |
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
| 842 |
+
# subclass.
|
| 843 |
+
if response.status_code >= 400:
|
| 844 |
+
raise core_exceptions.from_http_response(response)
|
| 845 |
+
|
| 846 |
+
content = response.content.decode("utf-8")
|
| 847 |
+
resp = operations_pb2.Operation()
|
| 848 |
+
resp = json_format.Parse(content, resp)
|
| 849 |
+
resp = self._interceptor.post_get_operation(resp)
|
| 850 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 851 |
+
logging.DEBUG
|
| 852 |
+
): # pragma: NO COVER
|
| 853 |
+
try:
|
| 854 |
+
response_payload = json_format.MessageToJson(resp)
|
| 855 |
+
except:
|
| 856 |
+
response_payload = None
|
| 857 |
+
http_response = {
|
| 858 |
+
"payload": response_payload,
|
| 859 |
+
"headers": dict(response.headers),
|
| 860 |
+
"status": response.status_code,
|
| 861 |
+
}
|
| 862 |
+
_LOGGER.debug(
|
| 863 |
+
"Received response for google.cloud.speech_v1.SpeechAsyncClient.GetOperation",
|
| 864 |
+
extra={
|
| 865 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 866 |
+
"rpcName": "GetOperation",
|
| 867 |
+
"httpResponse": http_response,
|
| 868 |
+
"metadata": http_response["headers"],
|
| 869 |
+
},
|
| 870 |
+
)
|
| 871 |
+
return resp
|
| 872 |
+
|
| 873 |
+
@property
|
| 874 |
+
def list_operations(self):
|
| 875 |
+
return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore
|
| 876 |
+
|
| 877 |
+
class _ListOperations(_BaseSpeechRestTransport._BaseListOperations, SpeechRestStub):
|
| 878 |
+
def __hash__(self):
|
| 879 |
+
return hash("SpeechRestTransport.ListOperations")
|
| 880 |
+
|
| 881 |
+
@staticmethod
|
| 882 |
+
def _get_response(
|
| 883 |
+
host,
|
| 884 |
+
metadata,
|
| 885 |
+
query_params,
|
| 886 |
+
session,
|
| 887 |
+
timeout,
|
| 888 |
+
transcoded_request,
|
| 889 |
+
body=None,
|
| 890 |
+
):
|
| 891 |
+
uri = transcoded_request["uri"]
|
| 892 |
+
method = transcoded_request["method"]
|
| 893 |
+
headers = dict(metadata)
|
| 894 |
+
headers["Content-Type"] = "application/json"
|
| 895 |
+
response = getattr(session, method)(
|
| 896 |
+
"{host}{uri}".format(host=host, uri=uri),
|
| 897 |
+
timeout=timeout,
|
| 898 |
+
headers=headers,
|
| 899 |
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
| 900 |
+
)
|
| 901 |
+
return response
|
| 902 |
+
|
| 903 |
+
def __call__(
|
| 904 |
+
self,
|
| 905 |
+
request: operations_pb2.ListOperationsRequest,
|
| 906 |
+
*,
|
| 907 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 908 |
+
timeout: Optional[float] = None,
|
| 909 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 910 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 911 |
+
r"""Call the list operations method over HTTP.
|
| 912 |
+
|
| 913 |
+
Args:
|
| 914 |
+
request (operations_pb2.ListOperationsRequest):
|
| 915 |
+
The request object for ListOperations method.
|
| 916 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 917 |
+
should be retried.
|
| 918 |
+
timeout (float): The timeout for this request.
|
| 919 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 920 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 921 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 922 |
+
be of type `bytes`.
|
| 923 |
+
|
| 924 |
+
Returns:
|
| 925 |
+
operations_pb2.ListOperationsResponse: Response from ListOperations method.
|
| 926 |
+
"""
|
| 927 |
+
|
| 928 |
+
http_options = (
|
| 929 |
+
_BaseSpeechRestTransport._BaseListOperations._get_http_options()
|
| 930 |
+
)
|
| 931 |
+
|
| 932 |
+
request, metadata = self._interceptor.pre_list_operations(request, metadata)
|
| 933 |
+
transcoded_request = (
|
| 934 |
+
_BaseSpeechRestTransport._BaseListOperations._get_transcoded_request(
|
| 935 |
+
http_options, request
|
| 936 |
+
)
|
| 937 |
+
)
|
| 938 |
+
|
| 939 |
+
# Jsonify the query params
|
| 940 |
+
query_params = (
|
| 941 |
+
_BaseSpeechRestTransport._BaseListOperations._get_query_params_json(
|
| 942 |
+
transcoded_request
|
| 943 |
+
)
|
| 944 |
+
)
|
| 945 |
+
|
| 946 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 947 |
+
logging.DEBUG
|
| 948 |
+
): # pragma: NO COVER
|
| 949 |
+
request_url = "{host}{uri}".format(
|
| 950 |
+
host=self._host, uri=transcoded_request["uri"]
|
| 951 |
+
)
|
| 952 |
+
method = transcoded_request["method"]
|
| 953 |
+
try:
|
| 954 |
+
request_payload = json_format.MessageToJson(request)
|
| 955 |
+
except:
|
| 956 |
+
request_payload = None
|
| 957 |
+
http_request = {
|
| 958 |
+
"payload": request_payload,
|
| 959 |
+
"requestMethod": method,
|
| 960 |
+
"requestUrl": request_url,
|
| 961 |
+
"headers": dict(metadata),
|
| 962 |
+
}
|
| 963 |
+
_LOGGER.debug(
|
| 964 |
+
f"Sending request for google.cloud.speech_v1.SpeechClient.ListOperations",
|
| 965 |
+
extra={
|
| 966 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 967 |
+
"rpcName": "ListOperations",
|
| 968 |
+
"httpRequest": http_request,
|
| 969 |
+
"metadata": http_request["headers"],
|
| 970 |
+
},
|
| 971 |
+
)
|
| 972 |
+
|
| 973 |
+
# Send the request
|
| 974 |
+
response = SpeechRestTransport._ListOperations._get_response(
|
| 975 |
+
self._host,
|
| 976 |
+
metadata,
|
| 977 |
+
query_params,
|
| 978 |
+
self._session,
|
| 979 |
+
timeout,
|
| 980 |
+
transcoded_request,
|
| 981 |
+
)
|
| 982 |
+
|
| 983 |
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
| 984 |
+
# subclass.
|
| 985 |
+
if response.status_code >= 400:
|
| 986 |
+
raise core_exceptions.from_http_response(response)
|
| 987 |
+
|
| 988 |
+
content = response.content.decode("utf-8")
|
| 989 |
+
resp = operations_pb2.ListOperationsResponse()
|
| 990 |
+
resp = json_format.Parse(content, resp)
|
| 991 |
+
resp = self._interceptor.post_list_operations(resp)
|
| 992 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 993 |
+
logging.DEBUG
|
| 994 |
+
): # pragma: NO COVER
|
| 995 |
+
try:
|
| 996 |
+
response_payload = json_format.MessageToJson(resp)
|
| 997 |
+
except:
|
| 998 |
+
response_payload = None
|
| 999 |
+
http_response = {
|
| 1000 |
+
"payload": response_payload,
|
| 1001 |
+
"headers": dict(response.headers),
|
| 1002 |
+
"status": response.status_code,
|
| 1003 |
+
}
|
| 1004 |
+
_LOGGER.debug(
|
| 1005 |
+
"Received response for google.cloud.speech_v1.SpeechAsyncClient.ListOperations",
|
| 1006 |
+
extra={
|
| 1007 |
+
"serviceName": "google.cloud.speech.v1.Speech",
|
| 1008 |
+
"rpcName": "ListOperations",
|
| 1009 |
+
"httpResponse": http_response,
|
| 1010 |
+
"metadata": http_response["headers"],
|
| 1011 |
+
},
|
| 1012 |
+
)
|
| 1013 |
+
return resp
|
| 1014 |
+
|
| 1015 |
+
@property
|
| 1016 |
+
def kind(self) -> str:
|
| 1017 |
+
return "rest"
|
| 1018 |
+
|
| 1019 |
+
def close(self):
|
| 1020 |
+
self._session.close()
|
| 1021 |
+
|
| 1022 |
+
|
| 1023 |
+
__all__ = ("SpeechRestTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/services/speech/transports/rest_base.py
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json # type: ignore
|
| 17 |
+
import re
|
| 18 |
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
| 19 |
+
|
| 20 |
+
from google.api_core import gapic_v1, path_template
|
| 21 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 22 |
+
from google.protobuf import json_format
|
| 23 |
+
|
| 24 |
+
from google.cloud.speech_v1.types import cloud_speech
|
| 25 |
+
|
| 26 |
+
from .base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class _BaseSpeechRestTransport(SpeechTransport):
|
| 30 |
+
"""Base REST backend transport for Speech.
|
| 31 |
+
|
| 32 |
+
Note: This class is not meant to be used directly. Use its sync and
|
| 33 |
+
async sub-classes instead.
|
| 34 |
+
|
| 35 |
+
This class defines the same methods as the primary client, so the
|
| 36 |
+
primary client can load the underlying transport implementation
|
| 37 |
+
and call it.
|
| 38 |
+
|
| 39 |
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
def __init__(
|
| 43 |
+
self,
|
| 44 |
+
*,
|
| 45 |
+
host: str = "speech.googleapis.com",
|
| 46 |
+
credentials: Optional[Any] = None,
|
| 47 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 48 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 49 |
+
url_scheme: str = "https",
|
| 50 |
+
api_audience: Optional[str] = None,
|
| 51 |
+
) -> None:
|
| 52 |
+
"""Instantiate the transport.
|
| 53 |
+
Args:
|
| 54 |
+
host (Optional[str]):
|
| 55 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 56 |
+
credentials (Optional[Any]): The
|
| 57 |
+
authorization credentials to attach to requests. These
|
| 58 |
+
credentials identify the application to the service; if none
|
| 59 |
+
are specified, the client will attempt to ascertain the
|
| 60 |
+
credentials from the environment.
|
| 61 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 62 |
+
The client info used to send a user-agent string along with
|
| 63 |
+
API requests. If ``None``, then default info will be used.
|
| 64 |
+
Generally, you only need to set this if you are developing
|
| 65 |
+
your own client library.
|
| 66 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 67 |
+
be used for service account credentials.
|
| 68 |
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
| 69 |
+
"https", but for testing or local servers,
|
| 70 |
+
"http" can be specified.
|
| 71 |
+
"""
|
| 72 |
+
# Run the base constructor
|
| 73 |
+
maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
|
| 74 |
+
if maybe_url_match is None:
|
| 75 |
+
raise ValueError(
|
| 76 |
+
f"Unexpected hostname structure: {host}"
|
| 77 |
+
) # pragma: NO COVER
|
| 78 |
+
|
| 79 |
+
url_match_items = maybe_url_match.groupdict()
|
| 80 |
+
|
| 81 |
+
host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host
|
| 82 |
+
|
| 83 |
+
super().__init__(
|
| 84 |
+
host=host,
|
| 85 |
+
credentials=credentials,
|
| 86 |
+
client_info=client_info,
|
| 87 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 88 |
+
api_audience=api_audience,
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
class _BaseLongRunningRecognize:
|
| 92 |
+
def __hash__(self): # pragma: NO COVER
|
| 93 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 94 |
+
|
| 95 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 96 |
+
|
| 97 |
+
@classmethod
|
| 98 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 99 |
+
return {
|
| 100 |
+
k: v
|
| 101 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 102 |
+
if k not in message_dict
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
@staticmethod
|
| 106 |
+
def _get_http_options():
|
| 107 |
+
http_options: List[Dict[str, str]] = [
|
| 108 |
+
{
|
| 109 |
+
"method": "post",
|
| 110 |
+
"uri": "/v1/speech:longrunningrecognize",
|
| 111 |
+
"body": "*",
|
| 112 |
+
},
|
| 113 |
+
]
|
| 114 |
+
return http_options
|
| 115 |
+
|
| 116 |
+
@staticmethod
|
| 117 |
+
def _get_transcoded_request(http_options, request):
|
| 118 |
+
pb_request = cloud_speech.LongRunningRecognizeRequest.pb(request)
|
| 119 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 120 |
+
return transcoded_request
|
| 121 |
+
|
| 122 |
+
@staticmethod
|
| 123 |
+
def _get_request_body_json(transcoded_request):
|
| 124 |
+
# Jsonify the request body
|
| 125 |
+
|
| 126 |
+
body = json_format.MessageToJson(
|
| 127 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 128 |
+
)
|
| 129 |
+
return body
|
| 130 |
+
|
| 131 |
+
@staticmethod
|
| 132 |
+
def _get_query_params_json(transcoded_request):
|
| 133 |
+
query_params = json.loads(
|
| 134 |
+
json_format.MessageToJson(
|
| 135 |
+
transcoded_request["query_params"],
|
| 136 |
+
use_integers_for_enums=True,
|
| 137 |
+
)
|
| 138 |
+
)
|
| 139 |
+
query_params.update(
|
| 140 |
+
_BaseSpeechRestTransport._BaseLongRunningRecognize._get_unset_required_fields(
|
| 141 |
+
query_params
|
| 142 |
+
)
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 146 |
+
return query_params
|
| 147 |
+
|
| 148 |
+
class _BaseRecognize:
|
| 149 |
+
def __hash__(self): # pragma: NO COVER
|
| 150 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 151 |
+
|
| 152 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 153 |
+
|
| 154 |
+
@classmethod
|
| 155 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 156 |
+
return {
|
| 157 |
+
k: v
|
| 158 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 159 |
+
if k not in message_dict
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
@staticmethod
|
| 163 |
+
def _get_http_options():
|
| 164 |
+
http_options: List[Dict[str, str]] = [
|
| 165 |
+
{
|
| 166 |
+
"method": "post",
|
| 167 |
+
"uri": "/v1/speech:recognize",
|
| 168 |
+
"body": "*",
|
| 169 |
+
},
|
| 170 |
+
]
|
| 171 |
+
return http_options
|
| 172 |
+
|
| 173 |
+
@staticmethod
|
| 174 |
+
def _get_transcoded_request(http_options, request):
|
| 175 |
+
pb_request = cloud_speech.RecognizeRequest.pb(request)
|
| 176 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 177 |
+
return transcoded_request
|
| 178 |
+
|
| 179 |
+
@staticmethod
|
| 180 |
+
def _get_request_body_json(transcoded_request):
|
| 181 |
+
# Jsonify the request body
|
| 182 |
+
|
| 183 |
+
body = json_format.MessageToJson(
|
| 184 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 185 |
+
)
|
| 186 |
+
return body
|
| 187 |
+
|
| 188 |
+
@staticmethod
|
| 189 |
+
def _get_query_params_json(transcoded_request):
|
| 190 |
+
query_params = json.loads(
|
| 191 |
+
json_format.MessageToJson(
|
| 192 |
+
transcoded_request["query_params"],
|
| 193 |
+
use_integers_for_enums=True,
|
| 194 |
+
)
|
| 195 |
+
)
|
| 196 |
+
query_params.update(
|
| 197 |
+
_BaseSpeechRestTransport._BaseRecognize._get_unset_required_fields(
|
| 198 |
+
query_params
|
| 199 |
+
)
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 203 |
+
return query_params
|
| 204 |
+
|
| 205 |
+
class _BaseStreamingRecognize:
|
| 206 |
+
def __hash__(self): # pragma: NO COVER
|
| 207 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 208 |
+
|
| 209 |
+
class _BaseGetOperation:
|
| 210 |
+
def __hash__(self): # pragma: NO COVER
|
| 211 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 212 |
+
|
| 213 |
+
@staticmethod
|
| 214 |
+
def _get_http_options():
|
| 215 |
+
http_options: List[Dict[str, str]] = [
|
| 216 |
+
{
|
| 217 |
+
"method": "get",
|
| 218 |
+
"uri": "/v1/operations/{name=**}",
|
| 219 |
+
},
|
| 220 |
+
]
|
| 221 |
+
return http_options
|
| 222 |
+
|
| 223 |
+
@staticmethod
|
| 224 |
+
def _get_transcoded_request(http_options, request):
|
| 225 |
+
request_kwargs = json_format.MessageToDict(request)
|
| 226 |
+
transcoded_request = path_template.transcode(http_options, **request_kwargs)
|
| 227 |
+
return transcoded_request
|
| 228 |
+
|
| 229 |
+
@staticmethod
|
| 230 |
+
def _get_query_params_json(transcoded_request):
|
| 231 |
+
query_params = json.loads(json.dumps(transcoded_request["query_params"]))
|
| 232 |
+
return query_params
|
| 233 |
+
|
| 234 |
+
class _BaseListOperations:
|
| 235 |
+
def __hash__(self): # pragma: NO COVER
|
| 236 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 237 |
+
|
| 238 |
+
@staticmethod
|
| 239 |
+
def _get_http_options():
|
| 240 |
+
http_options: List[Dict[str, str]] = [
|
| 241 |
+
{
|
| 242 |
+
"method": "get",
|
| 243 |
+
"uri": "/v1/operations",
|
| 244 |
+
},
|
| 245 |
+
]
|
| 246 |
+
return http_options
|
| 247 |
+
|
| 248 |
+
@staticmethod
|
| 249 |
+
def _get_transcoded_request(http_options, request):
|
| 250 |
+
request_kwargs = json_format.MessageToDict(request)
|
| 251 |
+
transcoded_request = path_template.transcode(http_options, **request_kwargs)
|
| 252 |
+
return transcoded_request
|
| 253 |
+
|
| 254 |
+
@staticmethod
|
| 255 |
+
def _get_query_params_json(transcoded_request):
|
| 256 |
+
query_params = json.loads(json.dumps(transcoded_request["query_params"]))
|
| 257 |
+
return query_params
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
__all__ = ("_BaseSpeechRestTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/types/__init__.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from .cloud_speech import (
|
| 17 |
+
LongRunningRecognizeMetadata,
|
| 18 |
+
LongRunningRecognizeRequest,
|
| 19 |
+
LongRunningRecognizeResponse,
|
| 20 |
+
RecognitionAudio,
|
| 21 |
+
RecognitionConfig,
|
| 22 |
+
RecognitionMetadata,
|
| 23 |
+
RecognizeRequest,
|
| 24 |
+
RecognizeResponse,
|
| 25 |
+
SpeakerDiarizationConfig,
|
| 26 |
+
SpeechAdaptationInfo,
|
| 27 |
+
SpeechContext,
|
| 28 |
+
SpeechRecognitionAlternative,
|
| 29 |
+
SpeechRecognitionResult,
|
| 30 |
+
StreamingRecognitionConfig,
|
| 31 |
+
StreamingRecognitionResult,
|
| 32 |
+
StreamingRecognizeRequest,
|
| 33 |
+
StreamingRecognizeResponse,
|
| 34 |
+
TranscriptOutputConfig,
|
| 35 |
+
WordInfo,
|
| 36 |
+
)
|
| 37 |
+
from .cloud_speech_adaptation import (
|
| 38 |
+
CreateCustomClassRequest,
|
| 39 |
+
CreatePhraseSetRequest,
|
| 40 |
+
DeleteCustomClassRequest,
|
| 41 |
+
DeletePhraseSetRequest,
|
| 42 |
+
GetCustomClassRequest,
|
| 43 |
+
GetPhraseSetRequest,
|
| 44 |
+
ListCustomClassesRequest,
|
| 45 |
+
ListCustomClassesResponse,
|
| 46 |
+
ListPhraseSetRequest,
|
| 47 |
+
ListPhraseSetResponse,
|
| 48 |
+
UpdateCustomClassRequest,
|
| 49 |
+
UpdatePhraseSetRequest,
|
| 50 |
+
)
|
| 51 |
+
from .resource import (
|
| 52 |
+
CustomClass,
|
| 53 |
+
PhraseSet,
|
| 54 |
+
SpeechAdaptation,
|
| 55 |
+
TranscriptNormalization,
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
__all__ = (
|
| 59 |
+
"LongRunningRecognizeMetadata",
|
| 60 |
+
"LongRunningRecognizeRequest",
|
| 61 |
+
"LongRunningRecognizeResponse",
|
| 62 |
+
"RecognitionAudio",
|
| 63 |
+
"RecognitionConfig",
|
| 64 |
+
"RecognitionMetadata",
|
| 65 |
+
"RecognizeRequest",
|
| 66 |
+
"RecognizeResponse",
|
| 67 |
+
"SpeakerDiarizationConfig",
|
| 68 |
+
"SpeechAdaptationInfo",
|
| 69 |
+
"SpeechContext",
|
| 70 |
+
"SpeechRecognitionAlternative",
|
| 71 |
+
"SpeechRecognitionResult",
|
| 72 |
+
"StreamingRecognitionConfig",
|
| 73 |
+
"StreamingRecognitionResult",
|
| 74 |
+
"StreamingRecognizeRequest",
|
| 75 |
+
"StreamingRecognizeResponse",
|
| 76 |
+
"TranscriptOutputConfig",
|
| 77 |
+
"WordInfo",
|
| 78 |
+
"CreateCustomClassRequest",
|
| 79 |
+
"CreatePhraseSetRequest",
|
| 80 |
+
"DeleteCustomClassRequest",
|
| 81 |
+
"DeletePhraseSetRequest",
|
| 82 |
+
"GetCustomClassRequest",
|
| 83 |
+
"GetPhraseSetRequest",
|
| 84 |
+
"ListCustomClassesRequest",
|
| 85 |
+
"ListCustomClassesResponse",
|
| 86 |
+
"ListPhraseSetRequest",
|
| 87 |
+
"ListPhraseSetResponse",
|
| 88 |
+
"UpdateCustomClassRequest",
|
| 89 |
+
"UpdatePhraseSetRequest",
|
| 90 |
+
"CustomClass",
|
| 91 |
+
"PhraseSet",
|
| 92 |
+
"SpeechAdaptation",
|
| 93 |
+
"TranscriptNormalization",
|
| 94 |
+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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
from typing import MutableMapping, MutableSequence
|
| 19 |
+
|
| 20 |
+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
|
| 21 |
+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
|
| 22 |
+
import google.protobuf.wrappers_pb2 as wrappers_pb2 # type: ignore
|
| 23 |
+
import google.rpc.status_pb2 as status_pb2 # type: ignore
|
| 24 |
+
import proto # type: ignore
|
| 25 |
+
|
| 26 |
+
from google.cloud.speech_v1.types import resource
|
| 27 |
+
|
| 28 |
+
__protobuf__ = proto.module(
|
| 29 |
+
package="google.cloud.speech.v1",
|
| 30 |
+
manifest={
|
| 31 |
+
"RecognizeRequest",
|
| 32 |
+
"LongRunningRecognizeRequest",
|
| 33 |
+
"TranscriptOutputConfig",
|
| 34 |
+
"StreamingRecognizeRequest",
|
| 35 |
+
"StreamingRecognitionConfig",
|
| 36 |
+
"RecognitionConfig",
|
| 37 |
+
"SpeakerDiarizationConfig",
|
| 38 |
+
"RecognitionMetadata",
|
| 39 |
+
"SpeechContext",
|
| 40 |
+
"RecognitionAudio",
|
| 41 |
+
"RecognizeResponse",
|
| 42 |
+
"LongRunningRecognizeResponse",
|
| 43 |
+
"LongRunningRecognizeMetadata",
|
| 44 |
+
"StreamingRecognizeResponse",
|
| 45 |
+
"StreamingRecognitionResult",
|
| 46 |
+
"SpeechRecognitionResult",
|
| 47 |
+
"SpeechRecognitionAlternative",
|
| 48 |
+
"WordInfo",
|
| 49 |
+
"SpeechAdaptationInfo",
|
| 50 |
+
},
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class RecognizeRequest(proto.Message):
|
| 55 |
+
r"""The top-level message sent by the client for the ``Recognize``
|
| 56 |
+
method.
|
| 57 |
+
|
| 58 |
+
Attributes:
|
| 59 |
+
config (google.cloud.speech_v1.types.RecognitionConfig):
|
| 60 |
+
Required. Provides information to the
|
| 61 |
+
recognizer that specifies how to process the
|
| 62 |
+
request.
|
| 63 |
+
audio (google.cloud.speech_v1.types.RecognitionAudio):
|
| 64 |
+
Required. The audio data to be recognized.
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
config: "RecognitionConfig" = proto.Field(
|
| 68 |
+
proto.MESSAGE,
|
| 69 |
+
number=1,
|
| 70 |
+
message="RecognitionConfig",
|
| 71 |
+
)
|
| 72 |
+
audio: "RecognitionAudio" = proto.Field(
|
| 73 |
+
proto.MESSAGE,
|
| 74 |
+
number=2,
|
| 75 |
+
message="RecognitionAudio",
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class LongRunningRecognizeRequest(proto.Message):
|
| 80 |
+
r"""The top-level message sent by the client for the
|
| 81 |
+
``LongRunningRecognize`` method.
|
| 82 |
+
|
| 83 |
+
Attributes:
|
| 84 |
+
config (google.cloud.speech_v1.types.RecognitionConfig):
|
| 85 |
+
Required. Provides information to the
|
| 86 |
+
recognizer that specifies how to process the
|
| 87 |
+
request.
|
| 88 |
+
audio (google.cloud.speech_v1.types.RecognitionAudio):
|
| 89 |
+
Required. The audio data to be recognized.
|
| 90 |
+
output_config (google.cloud.speech_v1.types.TranscriptOutputConfig):
|
| 91 |
+
Optional. Specifies an optional destination
|
| 92 |
+
for the recognition results.
|
| 93 |
+
"""
|
| 94 |
+
|
| 95 |
+
config: "RecognitionConfig" = proto.Field(
|
| 96 |
+
proto.MESSAGE,
|
| 97 |
+
number=1,
|
| 98 |
+
message="RecognitionConfig",
|
| 99 |
+
)
|
| 100 |
+
audio: "RecognitionAudio" = proto.Field(
|
| 101 |
+
proto.MESSAGE,
|
| 102 |
+
number=2,
|
| 103 |
+
message="RecognitionAudio",
|
| 104 |
+
)
|
| 105 |
+
output_config: "TranscriptOutputConfig" = proto.Field(
|
| 106 |
+
proto.MESSAGE,
|
| 107 |
+
number=4,
|
| 108 |
+
message="TranscriptOutputConfig",
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class TranscriptOutputConfig(proto.Message):
|
| 113 |
+
r"""Specifies an optional destination for the recognition
|
| 114 |
+
results.
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
| 118 |
+
|
| 119 |
+
Attributes:
|
| 120 |
+
gcs_uri (str):
|
| 121 |
+
Specifies a Cloud Storage URI for the recognition results.
|
| 122 |
+
Must be specified in the format:
|
| 123 |
+
``gs://bucket_name/object_name``, and the bucket must
|
| 124 |
+
already exist.
|
| 125 |
+
|
| 126 |
+
This field is a member of `oneof`_ ``output_type``.
|
| 127 |
+
"""
|
| 128 |
+
|
| 129 |
+
gcs_uri: str = proto.Field(
|
| 130 |
+
proto.STRING,
|
| 131 |
+
number=1,
|
| 132 |
+
oneof="output_type",
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
class StreamingRecognizeRequest(proto.Message):
|
| 137 |
+
r"""The top-level message sent by the client for the
|
| 138 |
+
``StreamingRecognize`` method. Multiple
|
| 139 |
+
``StreamingRecognizeRequest`` messages are sent. The first message
|
| 140 |
+
must contain a ``streaming_config`` message and must not contain
|
| 141 |
+
``audio_content``. All subsequent messages must contain
|
| 142 |
+
``audio_content`` and must not contain a ``streaming_config``
|
| 143 |
+
message.
|
| 144 |
+
|
| 145 |
+
This message has `oneof`_ fields (mutually exclusive fields).
|
| 146 |
+
For each oneof, at most one member field can be set at the same time.
|
| 147 |
+
Setting any member of the oneof automatically clears all other
|
| 148 |
+
members.
|
| 149 |
+
|
| 150 |
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
| 151 |
+
|
| 152 |
+
Attributes:
|
| 153 |
+
streaming_config (google.cloud.speech_v1.types.StreamingRecognitionConfig):
|
| 154 |
+
Provides information to the recognizer that specifies how to
|
| 155 |
+
process the request. The first ``StreamingRecognizeRequest``
|
| 156 |
+
message must contain a ``streaming_config`` message.
|
| 157 |
+
|
| 158 |
+
This field is a member of `oneof`_ ``streaming_request``.
|
| 159 |
+
audio_content (bytes):
|
| 160 |
+
The audio data to be recognized. Sequential chunks of audio
|
| 161 |
+
data are sent in sequential ``StreamingRecognizeRequest``
|
| 162 |
+
messages. The first ``StreamingRecognizeRequest`` message
|
| 163 |
+
must not contain ``audio_content`` data and all subsequent
|
| 164 |
+
``StreamingRecognizeRequest`` messages must contain
|
| 165 |
+
``audio_content`` data. The audio bytes must be encoded as
|
| 166 |
+
specified in ``RecognitionConfig``. Note: as with all bytes
|
| 167 |
+
fields, proto buffers use a pure binary representation (not
|
| 168 |
+
base64). See `content
|
| 169 |
+
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
|
| 170 |
+
|
| 171 |
+
This field is a member of `oneof`_ ``streaming_request``.
|
| 172 |
+
"""
|
| 173 |
+
|
| 174 |
+
streaming_config: "StreamingRecognitionConfig" = proto.Field(
|
| 175 |
+
proto.MESSAGE,
|
| 176 |
+
number=1,
|
| 177 |
+
oneof="streaming_request",
|
| 178 |
+
message="StreamingRecognitionConfig",
|
| 179 |
+
)
|
| 180 |
+
audio_content: bytes = proto.Field(
|
| 181 |
+
proto.BYTES,
|
| 182 |
+
number=2,
|
| 183 |
+
oneof="streaming_request",
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
class StreamingRecognitionConfig(proto.Message):
|
| 188 |
+
r"""Provides information to the recognizer that specifies how to
|
| 189 |
+
process the request.
|
| 190 |
+
|
| 191 |
+
Attributes:
|
| 192 |
+
config (google.cloud.speech_v1.types.RecognitionConfig):
|
| 193 |
+
Required. Provides information to the
|
| 194 |
+
recognizer that specifies how to process the
|
| 195 |
+
request.
|
| 196 |
+
single_utterance (bool):
|
| 197 |
+
If ``false`` or omitted, the recognizer will perform
|
| 198 |
+
continuous recognition (continuing to wait for and process
|
| 199 |
+
audio even if the user pauses speaking) until the client
|
| 200 |
+
closes the input stream (gRPC API) or until the maximum time
|
| 201 |
+
limit has been reached. May return multiple
|
| 202 |
+
``StreamingRecognitionResult``\ s with the ``is_final`` flag
|
| 203 |
+
set to ``true``.
|
| 204 |
+
|
| 205 |
+
If ``true``, the recognizer will detect a single spoken
|
| 206 |
+
utterance. When it detects that the user has paused or
|
| 207 |
+
stopped speaking, it will return an
|
| 208 |
+
``END_OF_SINGLE_UTTERANCE`` event and cease recognition. It
|
| 209 |
+
will return no more than one ``StreamingRecognitionResult``
|
| 210 |
+
with the ``is_final`` flag set to ``true``.
|
| 211 |
+
|
| 212 |
+
The ``single_utterance`` field can only be used with
|
| 213 |
+
specified models, otherwise an error is thrown. The
|
| 214 |
+
``model`` field in [``RecognitionConfig``][] must be set to:
|
| 215 |
+
|
| 216 |
+
- ``command_and_search``
|
| 217 |
+
- ``phone_call`` AND additional field
|
| 218 |
+
``useEnhanced``\ =\ ``true``
|
| 219 |
+
- The ``model`` field is left undefined. In this case the
|
| 220 |
+
API auto-selects a model based on any other parameters
|
| 221 |
+
that you set in ``RecognitionConfig``.
|
| 222 |
+
interim_results (bool):
|
| 223 |
+
If ``true``, interim results (tentative hypotheses) may be
|
| 224 |
+
returned as they become available (these interim results are
|
| 225 |
+
indicated with the ``is_final=false`` flag). If ``false`` or
|
| 226 |
+
omitted, only ``is_final=true`` result(s) are returned.
|
| 227 |
+
enable_voice_activity_events (bool):
|
| 228 |
+
If ``true``, responses with voice activity speech events
|
| 229 |
+
will be returned as they are detected.
|
| 230 |
+
voice_activity_timeout (google.cloud.speech_v1.types.StreamingRecognitionConfig.VoiceActivityTimeout):
|
| 231 |
+
If set, the server will automatically close the stream after
|
| 232 |
+
the specified duration has elapsed after the last
|
| 233 |
+
VOICE_ACTIVITY speech event has been sent. The field
|
| 234 |
+
``voice_activity_events`` must also be set to true.
|
| 235 |
+
"""
|
| 236 |
+
|
| 237 |
+
class VoiceActivityTimeout(proto.Message):
|
| 238 |
+
r"""Events that a timeout can be set on for voice activity.
|
| 239 |
+
|
| 240 |
+
Attributes:
|
| 241 |
+
speech_start_timeout (google.protobuf.duration_pb2.Duration):
|
| 242 |
+
Duration to timeout the stream if no speech
|
| 243 |
+
begins.
|
| 244 |
+
speech_end_timeout (google.protobuf.duration_pb2.Duration):
|
| 245 |
+
Duration to timeout the stream after speech
|
| 246 |
+
ends.
|
| 247 |
+
"""
|
| 248 |
+
|
| 249 |
+
speech_start_timeout: duration_pb2.Duration = proto.Field(
|
| 250 |
+
proto.MESSAGE,
|
| 251 |
+
number=1,
|
| 252 |
+
message=duration_pb2.Duration,
|
| 253 |
+
)
|
| 254 |
+
speech_end_timeout: duration_pb2.Duration = proto.Field(
|
| 255 |
+
proto.MESSAGE,
|
| 256 |
+
number=2,
|
| 257 |
+
message=duration_pb2.Duration,
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
config: "RecognitionConfig" = proto.Field(
|
| 261 |
+
proto.MESSAGE,
|
| 262 |
+
number=1,
|
| 263 |
+
message="RecognitionConfig",
|
| 264 |
+
)
|
| 265 |
+
single_utterance: bool = proto.Field(
|
| 266 |
+
proto.BOOL,
|
| 267 |
+
number=2,
|
| 268 |
+
)
|
| 269 |
+
interim_results: bool = proto.Field(
|
| 270 |
+
proto.BOOL,
|
| 271 |
+
number=3,
|
| 272 |
+
)
|
| 273 |
+
enable_voice_activity_events: bool = proto.Field(
|
| 274 |
+
proto.BOOL,
|
| 275 |
+
number=5,
|
| 276 |
+
)
|
| 277 |
+
voice_activity_timeout: VoiceActivityTimeout = proto.Field(
|
| 278 |
+
proto.MESSAGE,
|
| 279 |
+
number=6,
|
| 280 |
+
message=VoiceActivityTimeout,
|
| 281 |
+
)
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
class RecognitionConfig(proto.Message):
|
| 285 |
+
r"""Provides information to the recognizer that specifies how to
|
| 286 |
+
process the request.
|
| 287 |
+
|
| 288 |
+
Attributes:
|
| 289 |
+
encoding (google.cloud.speech_v1.types.RecognitionConfig.AudioEncoding):
|
| 290 |
+
Encoding of audio data sent in all ``RecognitionAudio``
|
| 291 |
+
messages. This field is optional for ``FLAC`` and ``WAV``
|
| 292 |
+
audio files and required for all other audio formats. For
|
| 293 |
+
details, see
|
| 294 |
+
[AudioEncoding][google.cloud.speech.v1.RecognitionConfig.AudioEncoding].
|
| 295 |
+
sample_rate_hertz (int):
|
| 296 |
+
Sample rate in Hertz of the audio data sent in all
|
| 297 |
+
``RecognitionAudio`` messages. Valid values are: 8000-48000.
|
| 298 |
+
16000 is optimal. For best results, set the sampling rate of
|
| 299 |
+
the audio source to 16000 Hz. If that's not possible, use
|
| 300 |
+
the native sample rate of the audio source (instead of
|
| 301 |
+
re-sampling). This field is optional for FLAC and WAV audio
|
| 302 |
+
files, but is required for all other audio formats. For
|
| 303 |
+
details, see
|
| 304 |
+
[AudioEncoding][google.cloud.speech.v1.RecognitionConfig.AudioEncoding].
|
| 305 |
+
audio_channel_count (int):
|
| 306 |
+
The number of channels in the input audio data. ONLY set
|
| 307 |
+
this for MULTI-CHANNEL recognition. Valid values for
|
| 308 |
+
LINEAR16, OGG_OPUS and FLAC are ``1``-``8``. Valid value for
|
| 309 |
+
MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only ``1``.
|
| 310 |
+
If ``0`` or omitted, defaults to one channel (mono). Note:
|
| 311 |
+
We only recognize the first channel by default. To perform
|
| 312 |
+
independent recognition on each channel set
|
| 313 |
+
``enable_separate_recognition_per_channel`` to 'true'.
|
| 314 |
+
enable_separate_recognition_per_channel (bool):
|
| 315 |
+
This needs to be set to ``true`` explicitly and
|
| 316 |
+
``audio_channel_count`` > 1 to get each channel recognized
|
| 317 |
+
separately. The recognition result will contain a
|
| 318 |
+
``channel_tag`` field to state which channel that result
|
| 319 |
+
belongs to. If this is not true, we will only recognize the
|
| 320 |
+
first channel. The request is billed cumulatively for all
|
| 321 |
+
channels recognized: ``audio_channel_count`` multiplied by
|
| 322 |
+
the length of the audio.
|
| 323 |
+
language_code (str):
|
| 324 |
+
Required. The language of the supplied audio as a
|
| 325 |
+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
|
| 326 |
+
language tag. Example: "en-US". See `Language
|
| 327 |
+
Support <https://cloud.google.com/speech-to-text/docs/languages>`__
|
| 328 |
+
for a list of the currently supported language codes.
|
| 329 |
+
alternative_language_codes (MutableSequence[str]):
|
| 330 |
+
A list of up to 3 additional
|
| 331 |
+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
|
| 332 |
+
language tags, listing possible alternative languages of the
|
| 333 |
+
supplied audio. See `Language
|
| 334 |
+
Support <https://cloud.google.com/speech-to-text/docs/languages>`__
|
| 335 |
+
for a list of the currently supported language codes. If
|
| 336 |
+
alternative languages are listed, recognition result will
|
| 337 |
+
contain recognition in the most likely language detected
|
| 338 |
+
including the main language_code. The recognition result
|
| 339 |
+
will include the language tag of the language detected in
|
| 340 |
+
the audio. Note: This feature is only supported for Voice
|
| 341 |
+
Command and Voice Search use cases and performance may vary
|
| 342 |
+
for other use cases (e.g., phone call transcription).
|
| 343 |
+
max_alternatives (int):
|
| 344 |
+
Maximum number of recognition hypotheses to be returned.
|
| 345 |
+
Specifically, the maximum number of
|
| 346 |
+
``SpeechRecognitionAlternative`` messages within each
|
| 347 |
+
``SpeechRecognitionResult``. The server may return fewer
|
| 348 |
+
than ``max_alternatives``. Valid values are ``0``-``30``. A
|
| 349 |
+
value of ``0`` or ``1`` will return a maximum of one. If
|
| 350 |
+
omitted, will return a maximum of one.
|
| 351 |
+
profanity_filter (bool):
|
| 352 |
+
If set to ``true``, the server will attempt to filter out
|
| 353 |
+
profanities, replacing all but the initial character in each
|
| 354 |
+
filtered word with asterisks, e.g. "f**\*". If set to
|
| 355 |
+
``false`` or omitted, profanities won't be filtered out.
|
| 356 |
+
adaptation (google.cloud.speech_v1.types.SpeechAdaptation):
|
| 357 |
+
Speech adaptation configuration improves the accuracy of
|
| 358 |
+
speech recognition. For more information, see the `speech
|
| 359 |
+
adaptation <https://cloud.google.com/speech-to-text/docs/adaptation>`__
|
| 360 |
+
documentation. When speech adaptation is set it supersedes
|
| 361 |
+
the ``speech_contexts`` field.
|
| 362 |
+
transcript_normalization (google.cloud.speech_v1.types.TranscriptNormalization):
|
| 363 |
+
Optional. Use transcription normalization to
|
| 364 |
+
automatically replace parts of the transcript
|
| 365 |
+
with phrases of your choosing. For
|
| 366 |
+
StreamingRecognize, this normalization only
|
| 367 |
+
applies to stable partial transcripts (stability
|
| 368 |
+
> 0.8) and final transcripts.
|
| 369 |
+
speech_contexts (MutableSequence[google.cloud.speech_v1.types.SpeechContext]):
|
| 370 |
+
Array of
|
| 371 |
+
[SpeechContext][google.cloud.speech.v1.SpeechContext]. A
|
| 372 |
+
means to provide context to assist the speech recognition.
|
| 373 |
+
For more information, see `speech
|
| 374 |
+
adaptation <https://cloud.google.com/speech-to-text/docs/adaptation>`__.
|
| 375 |
+
enable_word_time_offsets (bool):
|
| 376 |
+
If ``true``, the top result includes a list of words and the
|
| 377 |
+
start and end time offsets (timestamps) for those words. If
|
| 378 |
+
``false``, no word-level time offset information is
|
| 379 |
+
returned. The default is ``false``.
|
| 380 |
+
enable_word_confidence (bool):
|
| 381 |
+
If ``true``, the top result includes a list of words and the
|
| 382 |
+
confidence for those words. If ``false``, no word-level
|
| 383 |
+
confidence information is returned. The default is
|
| 384 |
+
``false``.
|
| 385 |
+
enable_automatic_punctuation (bool):
|
| 386 |
+
If 'true', adds punctuation to recognition
|
| 387 |
+
result hypotheses. This feature is only
|
| 388 |
+
available in select languages. Setting this for
|
| 389 |
+
requests in other languages has no effect at
|
| 390 |
+
all. The default 'false' value does not add
|
| 391 |
+
punctuation to result hypotheses.
|
| 392 |
+
enable_spoken_punctuation (google.protobuf.wrappers_pb2.BoolValue):
|
| 393 |
+
The spoken punctuation behavior for the call If not set,
|
| 394 |
+
uses default behavior based on model of choice e.g.
|
| 395 |
+
command_and_search will enable spoken punctuation by default
|
| 396 |
+
If 'true', replaces spoken punctuation with the
|
| 397 |
+
corresponding symbols in the request. For example, "how are
|
| 398 |
+
you question mark" becomes "how are you?". See
|
| 399 |
+
https://cloud.google.com/speech-to-text/docs/spoken-punctuation
|
| 400 |
+
for support. If 'false', spoken punctuation is not replaced.
|
| 401 |
+
enable_spoken_emojis (google.protobuf.wrappers_pb2.BoolValue):
|
| 402 |
+
The spoken emoji behavior for the call
|
| 403 |
+
If not set, uses default behavior based on model
|
| 404 |
+
of choice If 'true', adds spoken emoji
|
| 405 |
+
formatting for the request. This will replace
|
| 406 |
+
spoken emojis with the corresponding Unicode
|
| 407 |
+
symbols in the final transcript. If 'false',
|
| 408 |
+
spoken emojis are not replaced.
|
| 409 |
+
diarization_config (google.cloud.speech_v1.types.SpeakerDiarizationConfig):
|
| 410 |
+
Config to enable speaker diarization and set
|
| 411 |
+
additional parameters to make diarization better
|
| 412 |
+
suited for your application. Note: When this is
|
| 413 |
+
enabled, we send all the words from the
|
| 414 |
+
beginning of the audio for the top alternative
|
| 415 |
+
in every consecutive STREAMING responses. This
|
| 416 |
+
is done in order to improve our speaker tags as
|
| 417 |
+
our models learn to identify the speakers in the
|
| 418 |
+
conversation over time. For non-streaming
|
| 419 |
+
requests, the diarization results will be
|
| 420 |
+
provided only in the top alternative of the
|
| 421 |
+
FINAL SpeechRecognitionResult.
|
| 422 |
+
metadata (google.cloud.speech_v1.types.RecognitionMetadata):
|
| 423 |
+
Metadata regarding this request.
|
| 424 |
+
model (str):
|
| 425 |
+
Which model to select for the given request. Select the
|
| 426 |
+
model best suited to your domain to get best results. If a
|
| 427 |
+
model is not explicitly specified, then we auto-select a
|
| 428 |
+
model based on the parameters in the RecognitionConfig.
|
| 429 |
+
|
| 430 |
+
.. raw:: html
|
| 431 |
+
|
| 432 |
+
<table>
|
| 433 |
+
<tr>
|
| 434 |
+
<td><b>Model</b></td>
|
| 435 |
+
<td><b>Description</b></td>
|
| 436 |
+
</tr>
|
| 437 |
+
<tr>
|
| 438 |
+
<td><code>latest_long</code></td>
|
| 439 |
+
<td>Best for long form content like media or conversation.</td>
|
| 440 |
+
</tr>
|
| 441 |
+
<tr>
|
| 442 |
+
<td><code>latest_short</code></td>
|
| 443 |
+
<td>Best for short form content like commands or single shot directed
|
| 444 |
+
speech.</td>
|
| 445 |
+
</tr>
|
| 446 |
+
<tr>
|
| 447 |
+
<td><code>command_and_search</code></td>
|
| 448 |
+
<td>Best for short queries such as voice commands or voice search.</td>
|
| 449 |
+
</tr>
|
| 450 |
+
<tr>
|
| 451 |
+
<td><code>phone_call</code></td>
|
| 452 |
+
<td>Best for audio that originated from a phone call (typically
|
| 453 |
+
recorded at an 8khz sampling rate).</td>
|
| 454 |
+
</tr>
|
| 455 |
+
<tr>
|
| 456 |
+
<td><code>video</code></td>
|
| 457 |
+
<td>Best for audio that originated from video or includes multiple
|
| 458 |
+
speakers. Ideally the audio is recorded at a 16khz or greater
|
| 459 |
+
sampling rate. This is a premium model that costs more than the
|
| 460 |
+
standard rate.</td>
|
| 461 |
+
</tr>
|
| 462 |
+
<tr>
|
| 463 |
+
<td><code>default</code></td>
|
| 464 |
+
<td>Best for audio that is not one of the specific audio models.
|
| 465 |
+
For example, long-form audio. Ideally the audio is high-fidelity,
|
| 466 |
+
recorded at a 16khz or greater sampling rate.</td>
|
| 467 |
+
</tr>
|
| 468 |
+
<tr>
|
| 469 |
+
<td><code>medical_conversation</code></td>
|
| 470 |
+
<td>Best for audio that originated from a conversation between a
|
| 471 |
+
medical provider and patient.</td>
|
| 472 |
+
</tr>
|
| 473 |
+
<tr>
|
| 474 |
+
<td><code>medical_dictation</code></td>
|
| 475 |
+
<td>Best for audio that originated from dictation notes by a medical
|
| 476 |
+
provider.</td>
|
| 477 |
+
</tr>
|
| 478 |
+
</table>
|
| 479 |
+
use_enhanced (bool):
|
| 480 |
+
Set to true to use an enhanced model for speech recognition.
|
| 481 |
+
If ``use_enhanced`` is set to true and the ``model`` field
|
| 482 |
+
is not set, then an appropriate enhanced model is chosen if
|
| 483 |
+
an enhanced model exists for the audio.
|
| 484 |
+
|
| 485 |
+
If ``use_enhanced`` is true and an enhanced version of the
|
| 486 |
+
specified model does not exist, then the speech is
|
| 487 |
+
recognized using the standard version of the specified
|
| 488 |
+
model.
|
| 489 |
+
"""
|
| 490 |
+
|
| 491 |
+
class AudioEncoding(proto.Enum):
|
| 492 |
+
r"""The encoding of the audio data sent in the request.
|
| 493 |
+
|
| 494 |
+
All encodings support only 1 channel (mono) audio, unless the
|
| 495 |
+
``audio_channel_count`` and
|
| 496 |
+
``enable_separate_recognition_per_channel`` fields are set.
|
| 497 |
+
|
| 498 |
+
For best results, the audio source should be captured and
|
| 499 |
+
transmitted using a lossless encoding (``FLAC`` or ``LINEAR16``).
|
| 500 |
+
The accuracy of the speech recognition can be reduced if lossy
|
| 501 |
+
codecs are used to capture or transmit audio, particularly if
|
| 502 |
+
background noise is present. Lossy codecs include ``MULAW``,
|
| 503 |
+
``AMR``, ``AMR_WB``, ``OGG_OPUS``, ``SPEEX_WITH_HEADER_BYTE``,
|
| 504 |
+
``MP3``, and ``WEBM_OPUS``.
|
| 505 |
+
|
| 506 |
+
The ``FLAC`` and ``WAV`` audio file formats include a header that
|
| 507 |
+
describes the included audio content. You can request recognition
|
| 508 |
+
for ``WAV`` files that contain either ``LINEAR16`` or ``MULAW``
|
| 509 |
+
encoded audio. If you send ``FLAC`` or ``WAV`` audio file format in
|
| 510 |
+
your request, you do not need to specify an ``AudioEncoding``; the
|
| 511 |
+
audio encoding format is determined from the file header. If you
|
| 512 |
+
specify an ``AudioEncoding`` when you send send ``FLAC`` or ``WAV``
|
| 513 |
+
audio, the encoding configuration must match the encoding described
|
| 514 |
+
in the audio header; otherwise the request returns an
|
| 515 |
+
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]
|
| 516 |
+
error code.
|
| 517 |
+
|
| 518 |
+
Values:
|
| 519 |
+
ENCODING_UNSPECIFIED (0):
|
| 520 |
+
Not specified.
|
| 521 |
+
LINEAR16 (1):
|
| 522 |
+
Uncompressed 16-bit signed little-endian
|
| 523 |
+
samples (Linear PCM).
|
| 524 |
+
FLAC (2):
|
| 525 |
+
``FLAC`` (Free Lossless Audio Codec) is the recommended
|
| 526 |
+
encoding because it is lossless--therefore recognition is
|
| 527 |
+
not compromised--and requires only about half the bandwidth
|
| 528 |
+
of ``LINEAR16``. ``FLAC`` stream encoding supports 16-bit
|
| 529 |
+
and 24-bit samples, however, not all fields in
|
| 530 |
+
``STREAMINFO`` are supported.
|
| 531 |
+
MULAW (3):
|
| 532 |
+
8-bit samples that compand 14-bit audio
|
| 533 |
+
samples using G.711 PCMU/mu-law.
|
| 534 |
+
AMR (4):
|
| 535 |
+
Adaptive Multi-Rate Narrowband codec. ``sample_rate_hertz``
|
| 536 |
+
must be 8000.
|
| 537 |
+
AMR_WB (5):
|
| 538 |
+
Adaptive Multi-Rate Wideband codec. ``sample_rate_hertz``
|
| 539 |
+
must be 16000.
|
| 540 |
+
OGG_OPUS (6):
|
| 541 |
+
Opus encoded audio frames in Ogg container
|
| 542 |
+
(`OggOpus <https://wiki.xiph.org/OggOpus>`__).
|
| 543 |
+
``sample_rate_hertz`` must be one of 8000, 12000, 16000,
|
| 544 |
+
24000, or 48000.
|
| 545 |
+
SPEEX_WITH_HEADER_BYTE (7):
|
| 546 |
+
Although the use of lossy encodings is not recommended, if a
|
| 547 |
+
very low bitrate encoding is required, ``OGG_OPUS`` is
|
| 548 |
+
highly preferred over Speex encoding. The
|
| 549 |
+
`Speex <https://speex.org/>`__ encoding supported by Cloud
|
| 550 |
+
Speech API has a header byte in each block, as in MIME type
|
| 551 |
+
``audio/x-speex-with-header-byte``. It is a variant of the
|
| 552 |
+
RTP Speex encoding defined in `RFC
|
| 553 |
+
5574 <https://tools.ietf.org/html/rfc5574>`__. The stream is
|
| 554 |
+
a sequence of blocks, one block per RTP packet. Each block
|
| 555 |
+
starts with a byte containing the length of the block, in
|
| 556 |
+
bytes, followed by one or more frames of Speex data, padded
|
| 557 |
+
to an integral number of bytes (octets) as specified in RFC
|
| 558 |
+
5574. In other words, each RTP header is replaced with a
|
| 559 |
+
single byte containing the block length. Only Speex wideband
|
| 560 |
+
is supported. ``sample_rate_hertz`` must be 16000.
|
| 561 |
+
MP3 (8):
|
| 562 |
+
MP3 audio. MP3 encoding is a Beta feature and only available
|
| 563 |
+
in v1p1beta1. Support all standard MP3 bitrates (which range
|
| 564 |
+
from 32-320 kbps). When using this encoding,
|
| 565 |
+
``sample_rate_hertz`` has to match the sample rate of the
|
| 566 |
+
file being used.
|
| 567 |
+
WEBM_OPUS (9):
|
| 568 |
+
Opus encoded audio frames in WebM container
|
| 569 |
+
(`OggOpus <https://wiki.xiph.org/OggOpus>`__).
|
| 570 |
+
``sample_rate_hertz`` must be one of 8000, 12000, 16000,
|
| 571 |
+
24000, or 48000.
|
| 572 |
+
"""
|
| 573 |
+
|
| 574 |
+
ENCODING_UNSPECIFIED = 0
|
| 575 |
+
LINEAR16 = 1
|
| 576 |
+
FLAC = 2
|
| 577 |
+
MULAW = 3
|
| 578 |
+
AMR = 4
|
| 579 |
+
AMR_WB = 5
|
| 580 |
+
OGG_OPUS = 6
|
| 581 |
+
SPEEX_WITH_HEADER_BYTE = 7
|
| 582 |
+
MP3 = 8
|
| 583 |
+
WEBM_OPUS = 9
|
| 584 |
+
|
| 585 |
+
encoding: AudioEncoding = proto.Field(
|
| 586 |
+
proto.ENUM,
|
| 587 |
+
number=1,
|
| 588 |
+
enum=AudioEncoding,
|
| 589 |
+
)
|
| 590 |
+
sample_rate_hertz: int = proto.Field(
|
| 591 |
+
proto.INT32,
|
| 592 |
+
number=2,
|
| 593 |
+
)
|
| 594 |
+
audio_channel_count: int = proto.Field(
|
| 595 |
+
proto.INT32,
|
| 596 |
+
number=7,
|
| 597 |
+
)
|
| 598 |
+
enable_separate_recognition_per_channel: bool = proto.Field(
|
| 599 |
+
proto.BOOL,
|
| 600 |
+
number=12,
|
| 601 |
+
)
|
| 602 |
+
language_code: str = proto.Field(
|
| 603 |
+
proto.STRING,
|
| 604 |
+
number=3,
|
| 605 |
+
)
|
| 606 |
+
alternative_language_codes: MutableSequence[str] = proto.RepeatedField(
|
| 607 |
+
proto.STRING,
|
| 608 |
+
number=18,
|
| 609 |
+
)
|
| 610 |
+
max_alternatives: int = proto.Field(
|
| 611 |
+
proto.INT32,
|
| 612 |
+
number=4,
|
| 613 |
+
)
|
| 614 |
+
profanity_filter: bool = proto.Field(
|
| 615 |
+
proto.BOOL,
|
| 616 |
+
number=5,
|
| 617 |
+
)
|
| 618 |
+
adaptation: resource.SpeechAdaptation = proto.Field(
|
| 619 |
+
proto.MESSAGE,
|
| 620 |
+
number=20,
|
| 621 |
+
message=resource.SpeechAdaptation,
|
| 622 |
+
)
|
| 623 |
+
transcript_normalization: resource.TranscriptNormalization = proto.Field(
|
| 624 |
+
proto.MESSAGE,
|
| 625 |
+
number=24,
|
| 626 |
+
message=resource.TranscriptNormalization,
|
| 627 |
+
)
|
| 628 |
+
speech_contexts: MutableSequence["SpeechContext"] = proto.RepeatedField(
|
| 629 |
+
proto.MESSAGE,
|
| 630 |
+
number=6,
|
| 631 |
+
message="SpeechContext",
|
| 632 |
+
)
|
| 633 |
+
enable_word_time_offsets: bool = proto.Field(
|
| 634 |
+
proto.BOOL,
|
| 635 |
+
number=8,
|
| 636 |
+
)
|
| 637 |
+
enable_word_confidence: bool = proto.Field(
|
| 638 |
+
proto.BOOL,
|
| 639 |
+
number=15,
|
| 640 |
+
)
|
| 641 |
+
enable_automatic_punctuation: bool = proto.Field(
|
| 642 |
+
proto.BOOL,
|
| 643 |
+
number=11,
|
| 644 |
+
)
|
| 645 |
+
enable_spoken_punctuation: wrappers_pb2.BoolValue = proto.Field(
|
| 646 |
+
proto.MESSAGE,
|
| 647 |
+
number=22,
|
| 648 |
+
message=wrappers_pb2.BoolValue,
|
| 649 |
+
)
|
| 650 |
+
enable_spoken_emojis: wrappers_pb2.BoolValue = proto.Field(
|
| 651 |
+
proto.MESSAGE,
|
| 652 |
+
number=23,
|
| 653 |
+
message=wrappers_pb2.BoolValue,
|
| 654 |
+
)
|
| 655 |
+
diarization_config: "SpeakerDiarizationConfig" = proto.Field(
|
| 656 |
+
proto.MESSAGE,
|
| 657 |
+
number=19,
|
| 658 |
+
message="SpeakerDiarizationConfig",
|
| 659 |
+
)
|
| 660 |
+
metadata: "RecognitionMetadata" = proto.Field(
|
| 661 |
+
proto.MESSAGE,
|
| 662 |
+
number=9,
|
| 663 |
+
message="RecognitionMetadata",
|
| 664 |
+
)
|
| 665 |
+
model: str = proto.Field(
|
| 666 |
+
proto.STRING,
|
| 667 |
+
number=13,
|
| 668 |
+
)
|
| 669 |
+
use_enhanced: bool = proto.Field(
|
| 670 |
+
proto.BOOL,
|
| 671 |
+
number=14,
|
| 672 |
+
)
|
| 673 |
+
|
| 674 |
+
|
| 675 |
+
class SpeakerDiarizationConfig(proto.Message):
|
| 676 |
+
r"""Config to enable speaker diarization.
|
| 677 |
+
|
| 678 |
+
Attributes:
|
| 679 |
+
enable_speaker_diarization (bool):
|
| 680 |
+
If 'true', enables speaker detection for each recognized
|
| 681 |
+
word in the top alternative of the recognition result using
|
| 682 |
+
a speaker_label provided in the WordInfo.
|
| 683 |
+
min_speaker_count (int):
|
| 684 |
+
Minimum number of speakers in the
|
| 685 |
+
conversation. This range gives you more
|
| 686 |
+
flexibility by allowing the system to
|
| 687 |
+
automatically determine the correct number of
|
| 688 |
+
speakers. If not set, the default value is 2.
|
| 689 |
+
max_speaker_count (int):
|
| 690 |
+
Maximum number of speakers in the
|
| 691 |
+
conversation. This range gives you more
|
| 692 |
+
flexibility by allowing the system to
|
| 693 |
+
automatically determine the correct number of
|
| 694 |
+
speakers. If not set, the default value is 6.
|
| 695 |
+
speaker_tag (int):
|
| 696 |
+
Output only. Unused.
|
| 697 |
+
"""
|
| 698 |
+
|
| 699 |
+
enable_speaker_diarization: bool = proto.Field(
|
| 700 |
+
proto.BOOL,
|
| 701 |
+
number=1,
|
| 702 |
+
)
|
| 703 |
+
min_speaker_count: int = proto.Field(
|
| 704 |
+
proto.INT32,
|
| 705 |
+
number=2,
|
| 706 |
+
)
|
| 707 |
+
max_speaker_count: int = proto.Field(
|
| 708 |
+
proto.INT32,
|
| 709 |
+
number=3,
|
| 710 |
+
)
|
| 711 |
+
speaker_tag: int = proto.Field(
|
| 712 |
+
proto.INT32,
|
| 713 |
+
number=5,
|
| 714 |
+
)
|
| 715 |
+
|
| 716 |
+
|
| 717 |
+
class RecognitionMetadata(proto.Message):
|
| 718 |
+
r"""Description of audio data to be recognized.
|
| 719 |
+
|
| 720 |
+
Attributes:
|
| 721 |
+
interaction_type (google.cloud.speech_v1.types.RecognitionMetadata.InteractionType):
|
| 722 |
+
The use case most closely describing the
|
| 723 |
+
audio content to be recognized.
|
| 724 |
+
industry_naics_code_of_audio (int):
|
| 725 |
+
The industry vertical to which this speech
|
| 726 |
+
recognition request most closely applies. This
|
| 727 |
+
is most indicative of the topics contained in
|
| 728 |
+
the audio. Use the 6-digit NAICS code to
|
| 729 |
+
identify the industry vertical - see
|
| 730 |
+
https://www.naics.com/search/.
|
| 731 |
+
microphone_distance (google.cloud.speech_v1.types.RecognitionMetadata.MicrophoneDistance):
|
| 732 |
+
The audio type that most closely describes
|
| 733 |
+
the audio being recognized.
|
| 734 |
+
original_media_type (google.cloud.speech_v1.types.RecognitionMetadata.OriginalMediaType):
|
| 735 |
+
The original media the speech was recorded
|
| 736 |
+
on.
|
| 737 |
+
recording_device_type (google.cloud.speech_v1.types.RecognitionMetadata.RecordingDeviceType):
|
| 738 |
+
The type of device the speech was recorded
|
| 739 |
+
with.
|
| 740 |
+
recording_device_name (str):
|
| 741 |
+
The device used to make the recording.
|
| 742 |
+
Examples 'Nexus 5X' or 'Polycom SoundStation IP
|
| 743 |
+
6000' or 'POTS' or 'VoIP' or 'Cardioid
|
| 744 |
+
Microphone'.
|
| 745 |
+
original_mime_type (str):
|
| 746 |
+
Mime type of the original audio file. For example
|
| 747 |
+
``audio/m4a``, ``audio/x-alaw-basic``, ``audio/mp3``,
|
| 748 |
+
``audio/3gpp``. A list of possible audio mime types is
|
| 749 |
+
maintained at
|
| 750 |
+
http://www.iana.org/assignments/media-types/media-types.xhtml#audio
|
| 751 |
+
audio_topic (str):
|
| 752 |
+
Description of the content. Eg. "Recordings
|
| 753 |
+
of federal supreme court hearings from 2012".
|
| 754 |
+
"""
|
| 755 |
+
|
| 756 |
+
class InteractionType(proto.Enum):
|
| 757 |
+
r"""Use case categories that the audio recognition request can be
|
| 758 |
+
described by.
|
| 759 |
+
|
| 760 |
+
Values:
|
| 761 |
+
INTERACTION_TYPE_UNSPECIFIED (0):
|
| 762 |
+
Use case is either unknown or is something
|
| 763 |
+
other than one of the other values below.
|
| 764 |
+
DISCUSSION (1):
|
| 765 |
+
Multiple people in a conversation or discussion. For example
|
| 766 |
+
in a meeting with two or more people actively participating.
|
| 767 |
+
Typically all the primary people speaking would be in the
|
| 768 |
+
same room (if not, see PHONE_CALL)
|
| 769 |
+
PRESENTATION (2):
|
| 770 |
+
One or more persons lecturing or presenting
|
| 771 |
+
to others, mostly uninterrupted.
|
| 772 |
+
PHONE_CALL (3):
|
| 773 |
+
A phone-call or video-conference in which two
|
| 774 |
+
or more people, who are not in the same room,
|
| 775 |
+
are actively participating.
|
| 776 |
+
VOICEMAIL (4):
|
| 777 |
+
A recorded message intended for another
|
| 778 |
+
person to listen to.
|
| 779 |
+
PROFESSIONALLY_PRODUCED (5):
|
| 780 |
+
Professionally produced audio (eg. TV Show,
|
| 781 |
+
Podcast).
|
| 782 |
+
VOICE_SEARCH (6):
|
| 783 |
+
Transcribe spoken questions and queries into
|
| 784 |
+
text.
|
| 785 |
+
VOICE_COMMAND (7):
|
| 786 |
+
Transcribe voice commands, such as for
|
| 787 |
+
controlling a device.
|
| 788 |
+
DICTATION (8):
|
| 789 |
+
Transcribe speech to text to create a written
|
| 790 |
+
document, such as a text-message, email or
|
| 791 |
+
report.
|
| 792 |
+
"""
|
| 793 |
+
|
| 794 |
+
INTERACTION_TYPE_UNSPECIFIED = 0
|
| 795 |
+
DISCUSSION = 1
|
| 796 |
+
PRESENTATION = 2
|
| 797 |
+
PHONE_CALL = 3
|
| 798 |
+
VOICEMAIL = 4
|
| 799 |
+
PROFESSIONALLY_PRODUCED = 5
|
| 800 |
+
VOICE_SEARCH = 6
|
| 801 |
+
VOICE_COMMAND = 7
|
| 802 |
+
DICTATION = 8
|
| 803 |
+
|
| 804 |
+
class MicrophoneDistance(proto.Enum):
|
| 805 |
+
r"""Enumerates the types of capture settings describing an audio
|
| 806 |
+
file.
|
| 807 |
+
|
| 808 |
+
Values:
|
| 809 |
+
MICROPHONE_DISTANCE_UNSPECIFIED (0):
|
| 810 |
+
Audio type is not known.
|
| 811 |
+
NEARFIELD (1):
|
| 812 |
+
The audio was captured from a closely placed
|
| 813 |
+
microphone. Eg. phone, dictaphone, or handheld
|
| 814 |
+
microphone. Generally if there speaker is within
|
| 815 |
+
1 meter of the microphone.
|
| 816 |
+
MIDFIELD (2):
|
| 817 |
+
The speaker if within 3 meters of the
|
| 818 |
+
microphone.
|
| 819 |
+
FARFIELD (3):
|
| 820 |
+
The speaker is more than 3 meters away from
|
| 821 |
+
the microphone.
|
| 822 |
+
"""
|
| 823 |
+
|
| 824 |
+
MICROPHONE_DISTANCE_UNSPECIFIED = 0
|
| 825 |
+
NEARFIELD = 1
|
| 826 |
+
MIDFIELD = 2
|
| 827 |
+
FARFIELD = 3
|
| 828 |
+
|
| 829 |
+
class OriginalMediaType(proto.Enum):
|
| 830 |
+
r"""The original media the speech was recorded on.
|
| 831 |
+
|
| 832 |
+
Values:
|
| 833 |
+
ORIGINAL_MEDIA_TYPE_UNSPECIFIED (0):
|
| 834 |
+
Unknown original media type.
|
| 835 |
+
AUDIO (1):
|
| 836 |
+
The speech data is an audio recording.
|
| 837 |
+
VIDEO (2):
|
| 838 |
+
The speech data originally recorded on a
|
| 839 |
+
video.
|
| 840 |
+
"""
|
| 841 |
+
|
| 842 |
+
ORIGINAL_MEDIA_TYPE_UNSPECIFIED = 0
|
| 843 |
+
AUDIO = 1
|
| 844 |
+
VIDEO = 2
|
| 845 |
+
|
| 846 |
+
class RecordingDeviceType(proto.Enum):
|
| 847 |
+
r"""The type of device the speech was recorded with.
|
| 848 |
+
|
| 849 |
+
Values:
|
| 850 |
+
RECORDING_DEVICE_TYPE_UNSPECIFIED (0):
|
| 851 |
+
The recording device is unknown.
|
| 852 |
+
SMARTPHONE (1):
|
| 853 |
+
Speech was recorded on a smartphone.
|
| 854 |
+
PC (2):
|
| 855 |
+
Speech was recorded using a personal computer
|
| 856 |
+
or tablet.
|
| 857 |
+
PHONE_LINE (3):
|
| 858 |
+
Speech was recorded over a phone line.
|
| 859 |
+
VEHICLE (4):
|
| 860 |
+
Speech was recorded in a vehicle.
|
| 861 |
+
OTHER_OUTDOOR_DEVICE (5):
|
| 862 |
+
Speech was recorded outdoors.
|
| 863 |
+
OTHER_INDOOR_DEVICE (6):
|
| 864 |
+
Speech was recorded indoors.
|
| 865 |
+
"""
|
| 866 |
+
|
| 867 |
+
RECORDING_DEVICE_TYPE_UNSPECIFIED = 0
|
| 868 |
+
SMARTPHONE = 1
|
| 869 |
+
PC = 2
|
| 870 |
+
PHONE_LINE = 3
|
| 871 |
+
VEHICLE = 4
|
| 872 |
+
OTHER_OUTDOOR_DEVICE = 5
|
| 873 |
+
OTHER_INDOOR_DEVICE = 6
|
| 874 |
+
|
| 875 |
+
interaction_type: InteractionType = proto.Field(
|
| 876 |
+
proto.ENUM,
|
| 877 |
+
number=1,
|
| 878 |
+
enum=InteractionType,
|
| 879 |
+
)
|
| 880 |
+
industry_naics_code_of_audio: int = proto.Field(
|
| 881 |
+
proto.UINT32,
|
| 882 |
+
number=3,
|
| 883 |
+
)
|
| 884 |
+
microphone_distance: MicrophoneDistance = proto.Field(
|
| 885 |
+
proto.ENUM,
|
| 886 |
+
number=4,
|
| 887 |
+
enum=MicrophoneDistance,
|
| 888 |
+
)
|
| 889 |
+
original_media_type: OriginalMediaType = proto.Field(
|
| 890 |
+
proto.ENUM,
|
| 891 |
+
number=5,
|
| 892 |
+
enum=OriginalMediaType,
|
| 893 |
+
)
|
| 894 |
+
recording_device_type: RecordingDeviceType = proto.Field(
|
| 895 |
+
proto.ENUM,
|
| 896 |
+
number=6,
|
| 897 |
+
enum=RecordingDeviceType,
|
| 898 |
+
)
|
| 899 |
+
recording_device_name: str = proto.Field(
|
| 900 |
+
proto.STRING,
|
| 901 |
+
number=7,
|
| 902 |
+
)
|
| 903 |
+
original_mime_type: str = proto.Field(
|
| 904 |
+
proto.STRING,
|
| 905 |
+
number=8,
|
| 906 |
+
)
|
| 907 |
+
audio_topic: str = proto.Field(
|
| 908 |
+
proto.STRING,
|
| 909 |
+
number=10,
|
| 910 |
+
)
|
| 911 |
+
|
| 912 |
+
|
| 913 |
+
class SpeechContext(proto.Message):
|
| 914 |
+
r"""Provides "hints" to the speech recognizer to favor specific
|
| 915 |
+
words and phrases in the results.
|
| 916 |
+
|
| 917 |
+
Attributes:
|
| 918 |
+
phrases (MutableSequence[str]):
|
| 919 |
+
A list of strings containing words and phrases "hints" so
|
| 920 |
+
that the speech recognition is more likely to recognize
|
| 921 |
+
them. This can be used to improve the accuracy for specific
|
| 922 |
+
words and phrases, for example, if specific commands are
|
| 923 |
+
typically spoken by the user. This can also be used to add
|
| 924 |
+
additional words to the vocabulary of the recognizer. See
|
| 925 |
+
`usage
|
| 926 |
+
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
|
| 927 |
+
|
| 928 |
+
List items can also be set to classes for groups of words
|
| 929 |
+
that represent common concepts that occur in natural
|
| 930 |
+
language. For example, rather than providing phrase hints
|
| 931 |
+
for every month of the year, using the $MONTH class improves
|
| 932 |
+
the likelihood of correctly transcribing audio that includes
|
| 933 |
+
months.
|
| 934 |
+
boost (float):
|
| 935 |
+
Hint Boost. Positive value will increase the probability
|
| 936 |
+
that a specific phrase will be recognized over other similar
|
| 937 |
+
sounding phrases. The higher the boost, the higher the
|
| 938 |
+
chance of false positive recognition as well. Negative boost
|
| 939 |
+
values would correspond to anti-biasing. Anti-biasing is not
|
| 940 |
+
enabled, so negative boost will simply be ignored. Though
|
| 941 |
+
``boost`` can accept a wide range of positive values, most
|
| 942 |
+
use cases are best served with values between 0 and 20. We
|
| 943 |
+
recommend using a binary search approach to finding the
|
| 944 |
+
optimal value for your use case.
|
| 945 |
+
"""
|
| 946 |
+
|
| 947 |
+
phrases: MutableSequence[str] = proto.RepeatedField(
|
| 948 |
+
proto.STRING,
|
| 949 |
+
number=1,
|
| 950 |
+
)
|
| 951 |
+
boost: float = proto.Field(
|
| 952 |
+
proto.FLOAT,
|
| 953 |
+
number=4,
|
| 954 |
+
)
|
| 955 |
+
|
| 956 |
+
|
| 957 |
+
class RecognitionAudio(proto.Message):
|
| 958 |
+
r"""Contains audio data in the encoding specified in the
|
| 959 |
+
``RecognitionConfig``. Either ``content`` or ``uri`` must be
|
| 960 |
+
supplied. Supplying both or neither returns
|
| 961 |
+
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].
|
| 962 |
+
See `content
|
| 963 |
+
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
|
| 964 |
+
|
| 965 |
+
This message has `oneof`_ fields (mutually exclusive fields).
|
| 966 |
+
For each oneof, at most one member field can be set at the same time.
|
| 967 |
+
Setting any member of the oneof automatically clears all other
|
| 968 |
+
members.
|
| 969 |
+
|
| 970 |
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
| 971 |
+
|
| 972 |
+
Attributes:
|
| 973 |
+
content (bytes):
|
| 974 |
+
The audio data bytes encoded as specified in
|
| 975 |
+
``RecognitionConfig``. Note: as with all bytes fields, proto
|
| 976 |
+
buffers use a pure binary representation, whereas JSON
|
| 977 |
+
representations use base64.
|
| 978 |
+
|
| 979 |
+
This field is a member of `oneof`_ ``audio_source``.
|
| 980 |
+
uri (str):
|
| 981 |
+
URI that points to a file that contains audio data bytes as
|
| 982 |
+
specified in ``RecognitionConfig``. The file must not be
|
| 983 |
+
compressed (for example, gzip). Currently, only Google Cloud
|
| 984 |
+
Storage URIs are supported, which must be specified in the
|
| 985 |
+
following format: ``gs://bucket_name/object_name`` (other
|
| 986 |
+
URI formats return
|
| 987 |
+
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]).
|
| 988 |
+
For more information, see `Request
|
| 989 |
+
URIs <https://cloud.google.com/storage/docs/reference-uris>`__.
|
| 990 |
+
|
| 991 |
+
This field is a member of `oneof`_ ``audio_source``.
|
| 992 |
+
"""
|
| 993 |
+
|
| 994 |
+
content: bytes = proto.Field(
|
| 995 |
+
proto.BYTES,
|
| 996 |
+
number=1,
|
| 997 |
+
oneof="audio_source",
|
| 998 |
+
)
|
| 999 |
+
uri: str = proto.Field(
|
| 1000 |
+
proto.STRING,
|
| 1001 |
+
number=2,
|
| 1002 |
+
oneof="audio_source",
|
| 1003 |
+
)
|
| 1004 |
+
|
| 1005 |
+
|
| 1006 |
+
class RecognizeResponse(proto.Message):
|
| 1007 |
+
r"""The only message returned to the client by the ``Recognize`` method.
|
| 1008 |
+
It contains the result as zero or more sequential
|
| 1009 |
+
``SpeechRecognitionResult`` messages.
|
| 1010 |
+
|
| 1011 |
+
Attributes:
|
| 1012 |
+
results (MutableSequence[google.cloud.speech_v1.types.SpeechRecognitionResult]):
|
| 1013 |
+
Sequential list of transcription results
|
| 1014 |
+
corresponding to sequential portions of audio.
|
| 1015 |
+
total_billed_time (google.protobuf.duration_pb2.Duration):
|
| 1016 |
+
When available, billed audio seconds for the
|
| 1017 |
+
corresponding request.
|
| 1018 |
+
speech_adaptation_info (google.cloud.speech_v1.types.SpeechAdaptationInfo):
|
| 1019 |
+
Provides information on adaptation behavior
|
| 1020 |
+
in response
|
| 1021 |
+
request_id (int):
|
| 1022 |
+
The ID associated with the request. This is a
|
| 1023 |
+
unique ID specific only to the given request.
|
| 1024 |
+
"""
|
| 1025 |
+
|
| 1026 |
+
results: MutableSequence["SpeechRecognitionResult"] = proto.RepeatedField(
|
| 1027 |
+
proto.MESSAGE,
|
| 1028 |
+
number=2,
|
| 1029 |
+
message="SpeechRecognitionResult",
|
| 1030 |
+
)
|
| 1031 |
+
total_billed_time: duration_pb2.Duration = proto.Field(
|
| 1032 |
+
proto.MESSAGE,
|
| 1033 |
+
number=3,
|
| 1034 |
+
message=duration_pb2.Duration,
|
| 1035 |
+
)
|
| 1036 |
+
speech_adaptation_info: "SpeechAdaptationInfo" = proto.Field(
|
| 1037 |
+
proto.MESSAGE,
|
| 1038 |
+
number=7,
|
| 1039 |
+
message="SpeechAdaptationInfo",
|
| 1040 |
+
)
|
| 1041 |
+
request_id: int = proto.Field(
|
| 1042 |
+
proto.INT64,
|
| 1043 |
+
number=8,
|
| 1044 |
+
)
|
| 1045 |
+
|
| 1046 |
+
|
| 1047 |
+
class LongRunningRecognizeResponse(proto.Message):
|
| 1048 |
+
r"""The only message returned to the client by the
|
| 1049 |
+
``LongRunningRecognize`` method. It contains the result as zero or
|
| 1050 |
+
more sequential ``SpeechRecognitionResult`` messages. It is included
|
| 1051 |
+
in the ``result.response`` field of the ``Operation`` returned by
|
| 1052 |
+
the ``GetOperation`` call of the ``google::longrunning::Operations``
|
| 1053 |
+
service.
|
| 1054 |
+
|
| 1055 |
+
Attributes:
|
| 1056 |
+
results (MutableSequence[google.cloud.speech_v1.types.SpeechRecognitionResult]):
|
| 1057 |
+
Sequential list of transcription results
|
| 1058 |
+
corresponding to sequential portions of audio.
|
| 1059 |
+
total_billed_time (google.protobuf.duration_pb2.Duration):
|
| 1060 |
+
When available, billed audio seconds for the
|
| 1061 |
+
corresponding request.
|
| 1062 |
+
output_config (google.cloud.speech_v1.types.TranscriptOutputConfig):
|
| 1063 |
+
Original output config if present in the
|
| 1064 |
+
request.
|
| 1065 |
+
output_error (google.rpc.status_pb2.Status):
|
| 1066 |
+
If the transcript output fails this field
|
| 1067 |
+
contains the relevant error.
|
| 1068 |
+
speech_adaptation_info (google.cloud.speech_v1.types.SpeechAdaptationInfo):
|
| 1069 |
+
Provides information on speech adaptation
|
| 1070 |
+
behavior in response
|
| 1071 |
+
request_id (int):
|
| 1072 |
+
The ID associated with the request. This is a
|
| 1073 |
+
unique ID specific only to the given request.
|
| 1074 |
+
"""
|
| 1075 |
+
|
| 1076 |
+
results: MutableSequence["SpeechRecognitionResult"] = proto.RepeatedField(
|
| 1077 |
+
proto.MESSAGE,
|
| 1078 |
+
number=2,
|
| 1079 |
+
message="SpeechRecognitionResult",
|
| 1080 |
+
)
|
| 1081 |
+
total_billed_time: duration_pb2.Duration = proto.Field(
|
| 1082 |
+
proto.MESSAGE,
|
| 1083 |
+
number=3,
|
| 1084 |
+
message=duration_pb2.Duration,
|
| 1085 |
+
)
|
| 1086 |
+
output_config: "TranscriptOutputConfig" = proto.Field(
|
| 1087 |
+
proto.MESSAGE,
|
| 1088 |
+
number=6,
|
| 1089 |
+
message="TranscriptOutputConfig",
|
| 1090 |
+
)
|
| 1091 |
+
output_error: status_pb2.Status = proto.Field(
|
| 1092 |
+
proto.MESSAGE,
|
| 1093 |
+
number=7,
|
| 1094 |
+
message=status_pb2.Status,
|
| 1095 |
+
)
|
| 1096 |
+
speech_adaptation_info: "SpeechAdaptationInfo" = proto.Field(
|
| 1097 |
+
proto.MESSAGE,
|
| 1098 |
+
number=8,
|
| 1099 |
+
message="SpeechAdaptationInfo",
|
| 1100 |
+
)
|
| 1101 |
+
request_id: int = proto.Field(
|
| 1102 |
+
proto.INT64,
|
| 1103 |
+
number=9,
|
| 1104 |
+
)
|
| 1105 |
+
|
| 1106 |
+
|
| 1107 |
+
class LongRunningRecognizeMetadata(proto.Message):
|
| 1108 |
+
r"""Describes the progress of a long-running ``LongRunningRecognize``
|
| 1109 |
+
call. It is included in the ``metadata`` field of the ``Operation``
|
| 1110 |
+
returned by the ``GetOperation`` call of the
|
| 1111 |
+
``google::longrunning::Operations`` service.
|
| 1112 |
+
|
| 1113 |
+
Attributes:
|
| 1114 |
+
progress_percent (int):
|
| 1115 |
+
Approximate percentage of audio processed
|
| 1116 |
+
thus far. Guaranteed to be 100 when the audio is
|
| 1117 |
+
fully processed and the results are available.
|
| 1118 |
+
start_time (google.protobuf.timestamp_pb2.Timestamp):
|
| 1119 |
+
Time when the request was received.
|
| 1120 |
+
last_update_time (google.protobuf.timestamp_pb2.Timestamp):
|
| 1121 |
+
Time of the most recent processing update.
|
| 1122 |
+
uri (str):
|
| 1123 |
+
Output only. The URI of the audio file being
|
| 1124 |
+
transcribed. Empty if the audio was sent as byte
|
| 1125 |
+
content.
|
| 1126 |
+
"""
|
| 1127 |
+
|
| 1128 |
+
progress_percent: int = proto.Field(
|
| 1129 |
+
proto.INT32,
|
| 1130 |
+
number=1,
|
| 1131 |
+
)
|
| 1132 |
+
start_time: timestamp_pb2.Timestamp = proto.Field(
|
| 1133 |
+
proto.MESSAGE,
|
| 1134 |
+
number=2,
|
| 1135 |
+
message=timestamp_pb2.Timestamp,
|
| 1136 |
+
)
|
| 1137 |
+
last_update_time: timestamp_pb2.Timestamp = proto.Field(
|
| 1138 |
+
proto.MESSAGE,
|
| 1139 |
+
number=3,
|
| 1140 |
+
message=timestamp_pb2.Timestamp,
|
| 1141 |
+
)
|
| 1142 |
+
uri: str = proto.Field(
|
| 1143 |
+
proto.STRING,
|
| 1144 |
+
number=4,
|
| 1145 |
+
)
|
| 1146 |
+
|
| 1147 |
+
|
| 1148 |
+
class StreamingRecognizeResponse(proto.Message):
|
| 1149 |
+
r"""``StreamingRecognizeResponse`` is the only message returned to the
|
| 1150 |
+
client by ``StreamingRecognize``. A series of zero or more
|
| 1151 |
+
``StreamingRecognizeResponse`` messages are streamed back to the
|
| 1152 |
+
client. If there is no recognizable audio, and ``single_utterance``
|
| 1153 |
+
is set to false, then no messages are streamed back to the client.
|
| 1154 |
+
|
| 1155 |
+
Here's an example of a series of ``StreamingRecognizeResponse``\ s
|
| 1156 |
+
that might be returned while processing audio:
|
| 1157 |
+
|
| 1158 |
+
1. results { alternatives { transcript: "tube" } stability: 0.01 }
|
| 1159 |
+
|
| 1160 |
+
2. results { alternatives { transcript: "to be a" } stability: 0.01
|
| 1161 |
+
}
|
| 1162 |
+
|
| 1163 |
+
3. results { alternatives { transcript: "to be" } stability: 0.9 }
|
| 1164 |
+
results { alternatives { transcript: " or not to be" } stability:
|
| 1165 |
+
0.01 }
|
| 1166 |
+
|
| 1167 |
+
4. results { alternatives { transcript: "to be or not to be"
|
| 1168 |
+
confidence: 0.92 } alternatives { transcript: "to bee or not to
|
| 1169 |
+
bee" } is_final: true }
|
| 1170 |
+
|
| 1171 |
+
5. results { alternatives { transcript: " that's" } stability: 0.01
|
| 1172 |
+
}
|
| 1173 |
+
|
| 1174 |
+
6. results { alternatives { transcript: " that is" } stability: 0.9
|
| 1175 |
+
} results { alternatives { transcript: " the question" }
|
| 1176 |
+
stability: 0.01 }
|
| 1177 |
+
|
| 1178 |
+
7. results { alternatives { transcript: " that is the question"
|
| 1179 |
+
confidence: 0.98 } alternatives { transcript: " that was the
|
| 1180 |
+
question" } is_final: true }
|
| 1181 |
+
|
| 1182 |
+
Notes:
|
| 1183 |
+
|
| 1184 |
+
- Only two of the above responses #4 and #7 contain final results;
|
| 1185 |
+
they are indicated by ``is_final: true``. Concatenating these
|
| 1186 |
+
together generates the full transcript: "to be or not to be that
|
| 1187 |
+
is the question".
|
| 1188 |
+
|
| 1189 |
+
- The others contain interim ``results``. #3 and #6 contain two
|
| 1190 |
+
interim ``results``: the first portion has a high stability and is
|
| 1191 |
+
less likely to change; the second portion has a low stability and
|
| 1192 |
+
is very likely to change. A UI designer might choose to show only
|
| 1193 |
+
high stability ``results``.
|
| 1194 |
+
|
| 1195 |
+
- The specific ``stability`` and ``confidence`` values shown above
|
| 1196 |
+
are only for illustrative purposes. Actual values may vary.
|
| 1197 |
+
|
| 1198 |
+
- In each response, only one of these fields will be set: ``error``,
|
| 1199 |
+
``speech_event_type``, or one or more (repeated) ``results``.
|
| 1200 |
+
|
| 1201 |
+
Attributes:
|
| 1202 |
+
error (google.rpc.status_pb2.Status):
|
| 1203 |
+
If set, returns a [google.rpc.Status][google.rpc.Status]
|
| 1204 |
+
message that specifies the error for the operation.
|
| 1205 |
+
results (MutableSequence[google.cloud.speech_v1.types.StreamingRecognitionResult]):
|
| 1206 |
+
This repeated list contains zero or more results that
|
| 1207 |
+
correspond to consecutive portions of the audio currently
|
| 1208 |
+
being processed. It contains zero or one ``is_final=true``
|
| 1209 |
+
result (the newly settled portion), followed by zero or more
|
| 1210 |
+
``is_final=false`` results (the interim results).
|
| 1211 |
+
speech_event_type (google.cloud.speech_v1.types.StreamingRecognizeResponse.SpeechEventType):
|
| 1212 |
+
Indicates the type of speech event.
|
| 1213 |
+
speech_event_time (google.protobuf.duration_pb2.Duration):
|
| 1214 |
+
Time offset between the beginning of the
|
| 1215 |
+
audio and event emission.
|
| 1216 |
+
total_billed_time (google.protobuf.duration_pb2.Duration):
|
| 1217 |
+
When available, billed audio seconds for the
|
| 1218 |
+
stream. Set only if this is the last response in
|
| 1219 |
+
the stream.
|
| 1220 |
+
speech_adaptation_info (google.cloud.speech_v1.types.SpeechAdaptationInfo):
|
| 1221 |
+
Provides information on adaptation behavior
|
| 1222 |
+
in response
|
| 1223 |
+
request_id (int):
|
| 1224 |
+
The ID associated with the request. This is a
|
| 1225 |
+
unique ID specific only to the given request.
|
| 1226 |
+
"""
|
| 1227 |
+
|
| 1228 |
+
class SpeechEventType(proto.Enum):
|
| 1229 |
+
r"""Indicates the type of speech event.
|
| 1230 |
+
|
| 1231 |
+
Values:
|
| 1232 |
+
SPEECH_EVENT_UNSPECIFIED (0):
|
| 1233 |
+
No speech event specified.
|
| 1234 |
+
END_OF_SINGLE_UTTERANCE (1):
|
| 1235 |
+
This event indicates that the server has detected the end of
|
| 1236 |
+
the user's speech utterance and expects no additional
|
| 1237 |
+
speech. Therefore, the server will not process additional
|
| 1238 |
+
audio (although it may subsequently return additional
|
| 1239 |
+
results). The client should stop sending additional audio
|
| 1240 |
+
data, half-close the gRPC connection, and wait for any
|
| 1241 |
+
additional results until the server closes the gRPC
|
| 1242 |
+
connection. This event is only sent if ``single_utterance``
|
| 1243 |
+
was set to ``true``, and is not used otherwise.
|
| 1244 |
+
SPEECH_ACTIVITY_BEGIN (2):
|
| 1245 |
+
This event indicates that the server has detected the
|
| 1246 |
+
beginning of human voice activity in the stream. This event
|
| 1247 |
+
can be returned multiple times if speech starts and stops
|
| 1248 |
+
repeatedly throughout the stream. This event is only sent if
|
| 1249 |
+
``voice_activity_events`` is set to true.
|
| 1250 |
+
SPEECH_ACTIVITY_END (3):
|
| 1251 |
+
This event indicates that the server has detected the end of
|
| 1252 |
+
human voice activity in the stream. This event can be
|
| 1253 |
+
returned multiple times if speech starts and stops
|
| 1254 |
+
repeatedly throughout the stream. This event is only sent if
|
| 1255 |
+
``voice_activity_events`` is set to true.
|
| 1256 |
+
SPEECH_ACTIVITY_TIMEOUT (4):
|
| 1257 |
+
This event indicates that the user-set
|
| 1258 |
+
timeout for speech activity begin or end has
|
| 1259 |
+
exceeded. Upon receiving this event, the client
|
| 1260 |
+
is expected to send a half close. Further audio
|
| 1261 |
+
will not be processed.
|
| 1262 |
+
"""
|
| 1263 |
+
|
| 1264 |
+
SPEECH_EVENT_UNSPECIFIED = 0
|
| 1265 |
+
END_OF_SINGLE_UTTERANCE = 1
|
| 1266 |
+
SPEECH_ACTIVITY_BEGIN = 2
|
| 1267 |
+
SPEECH_ACTIVITY_END = 3
|
| 1268 |
+
SPEECH_ACTIVITY_TIMEOUT = 4
|
| 1269 |
+
|
| 1270 |
+
error: status_pb2.Status = proto.Field(
|
| 1271 |
+
proto.MESSAGE,
|
| 1272 |
+
number=1,
|
| 1273 |
+
message=status_pb2.Status,
|
| 1274 |
+
)
|
| 1275 |
+
results: MutableSequence["StreamingRecognitionResult"] = proto.RepeatedField(
|
| 1276 |
+
proto.MESSAGE,
|
| 1277 |
+
number=2,
|
| 1278 |
+
message="StreamingRecognitionResult",
|
| 1279 |
+
)
|
| 1280 |
+
speech_event_type: SpeechEventType = proto.Field(
|
| 1281 |
+
proto.ENUM,
|
| 1282 |
+
number=4,
|
| 1283 |
+
enum=SpeechEventType,
|
| 1284 |
+
)
|
| 1285 |
+
speech_event_time: duration_pb2.Duration = proto.Field(
|
| 1286 |
+
proto.MESSAGE,
|
| 1287 |
+
number=8,
|
| 1288 |
+
message=duration_pb2.Duration,
|
| 1289 |
+
)
|
| 1290 |
+
total_billed_time: duration_pb2.Duration = proto.Field(
|
| 1291 |
+
proto.MESSAGE,
|
| 1292 |
+
number=5,
|
| 1293 |
+
message=duration_pb2.Duration,
|
| 1294 |
+
)
|
| 1295 |
+
speech_adaptation_info: "SpeechAdaptationInfo" = proto.Field(
|
| 1296 |
+
proto.MESSAGE,
|
| 1297 |
+
number=9,
|
| 1298 |
+
message="SpeechAdaptationInfo",
|
| 1299 |
+
)
|
| 1300 |
+
request_id: int = proto.Field(
|
| 1301 |
+
proto.INT64,
|
| 1302 |
+
number=10,
|
| 1303 |
+
)
|
| 1304 |
+
|
| 1305 |
+
|
| 1306 |
+
class StreamingRecognitionResult(proto.Message):
|
| 1307 |
+
r"""A streaming speech recognition result corresponding to a
|
| 1308 |
+
portion of the audio that is currently being processed.
|
| 1309 |
+
|
| 1310 |
+
Attributes:
|
| 1311 |
+
alternatives (MutableSequence[google.cloud.speech_v1.types.SpeechRecognitionAlternative]):
|
| 1312 |
+
May contain one or more recognition hypotheses (up to the
|
| 1313 |
+
maximum specified in ``max_alternatives``). These
|
| 1314 |
+
alternatives are ordered in terms of accuracy, with the top
|
| 1315 |
+
(first) alternative being the most probable, as ranked by
|
| 1316 |
+
the recognizer.
|
| 1317 |
+
is_final (bool):
|
| 1318 |
+
If ``false``, this ``StreamingRecognitionResult`` represents
|
| 1319 |
+
an interim result that may change. If ``true``, this is the
|
| 1320 |
+
final time the speech service will return this particular
|
| 1321 |
+
``StreamingRecognitionResult``, the recognizer will not
|
| 1322 |
+
return any further hypotheses for this portion of the
|
| 1323 |
+
transcript and corresponding audio.
|
| 1324 |
+
stability (float):
|
| 1325 |
+
An estimate of the likelihood that the recognizer will not
|
| 1326 |
+
change its guess about this interim result. Values range
|
| 1327 |
+
from 0.0 (completely unstable) to 1.0 (completely stable).
|
| 1328 |
+
This field is only provided for interim results
|
| 1329 |
+
(``is_final=false``). The default of 0.0 is a sentinel value
|
| 1330 |
+
indicating ``stability`` was not set.
|
| 1331 |
+
result_end_time (google.protobuf.duration_pb2.Duration):
|
| 1332 |
+
Time offset of the end of this result
|
| 1333 |
+
relative to the beginning of the audio.
|
| 1334 |
+
channel_tag (int):
|
| 1335 |
+
For multi-channel audio, this is the channel number
|
| 1336 |
+
corresponding to the recognized result for the audio from
|
| 1337 |
+
that channel. For audio_channel_count = N, its output values
|
| 1338 |
+
can range from '1' to 'N'.
|
| 1339 |
+
language_code (str):
|
| 1340 |
+
Output only. The
|
| 1341 |
+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
|
| 1342 |
+
language tag of the language in this result. This language
|
| 1343 |
+
code was detected to have the most likelihood of being
|
| 1344 |
+
spoken in the audio.
|
| 1345 |
+
"""
|
| 1346 |
+
|
| 1347 |
+
alternatives: MutableSequence["SpeechRecognitionAlternative"] = proto.RepeatedField(
|
| 1348 |
+
proto.MESSAGE,
|
| 1349 |
+
number=1,
|
| 1350 |
+
message="SpeechRecognitionAlternative",
|
| 1351 |
+
)
|
| 1352 |
+
is_final: bool = proto.Field(
|
| 1353 |
+
proto.BOOL,
|
| 1354 |
+
number=2,
|
| 1355 |
+
)
|
| 1356 |
+
stability: float = proto.Field(
|
| 1357 |
+
proto.FLOAT,
|
| 1358 |
+
number=3,
|
| 1359 |
+
)
|
| 1360 |
+
result_end_time: duration_pb2.Duration = proto.Field(
|
| 1361 |
+
proto.MESSAGE,
|
| 1362 |
+
number=4,
|
| 1363 |
+
message=duration_pb2.Duration,
|
| 1364 |
+
)
|
| 1365 |
+
channel_tag: int = proto.Field(
|
| 1366 |
+
proto.INT32,
|
| 1367 |
+
number=5,
|
| 1368 |
+
)
|
| 1369 |
+
language_code: str = proto.Field(
|
| 1370 |
+
proto.STRING,
|
| 1371 |
+
number=6,
|
| 1372 |
+
)
|
| 1373 |
+
|
| 1374 |
+
|
| 1375 |
+
class SpeechRecognitionResult(proto.Message):
|
| 1376 |
+
r"""A speech recognition result corresponding to a portion of the
|
| 1377 |
+
audio.
|
| 1378 |
+
|
| 1379 |
+
Attributes:
|
| 1380 |
+
alternatives (MutableSequence[google.cloud.speech_v1.types.SpeechRecognitionAlternative]):
|
| 1381 |
+
May contain one or more recognition hypotheses (up to the
|
| 1382 |
+
maximum specified in ``max_alternatives``). These
|
| 1383 |
+
alternatives are ordered in terms of accuracy, with the top
|
| 1384 |
+
(first) alternative being the most probable, as ranked by
|
| 1385 |
+
the recognizer.
|
| 1386 |
+
channel_tag (int):
|
| 1387 |
+
For multi-channel audio, this is the channel number
|
| 1388 |
+
corresponding to the recognized result for the audio from
|
| 1389 |
+
that channel. For audio_channel_count = N, its output values
|
| 1390 |
+
can range from '1' to 'N'.
|
| 1391 |
+
result_end_time (google.protobuf.duration_pb2.Duration):
|
| 1392 |
+
Time offset of the end of this result
|
| 1393 |
+
relative to the beginning of the audio.
|
| 1394 |
+
language_code (str):
|
| 1395 |
+
Output only. The
|
| 1396 |
+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
|
| 1397 |
+
language tag of the language in this result. This language
|
| 1398 |
+
code was detected to have the most likelihood of being
|
| 1399 |
+
spoken in the audio.
|
| 1400 |
+
"""
|
| 1401 |
+
|
| 1402 |
+
alternatives: MutableSequence["SpeechRecognitionAlternative"] = proto.RepeatedField(
|
| 1403 |
+
proto.MESSAGE,
|
| 1404 |
+
number=1,
|
| 1405 |
+
message="SpeechRecognitionAlternative",
|
| 1406 |
+
)
|
| 1407 |
+
channel_tag: int = proto.Field(
|
| 1408 |
+
proto.INT32,
|
| 1409 |
+
number=2,
|
| 1410 |
+
)
|
| 1411 |
+
result_end_time: duration_pb2.Duration = proto.Field(
|
| 1412 |
+
proto.MESSAGE,
|
| 1413 |
+
number=4,
|
| 1414 |
+
message=duration_pb2.Duration,
|
| 1415 |
+
)
|
| 1416 |
+
language_code: str = proto.Field(
|
| 1417 |
+
proto.STRING,
|
| 1418 |
+
number=5,
|
| 1419 |
+
)
|
| 1420 |
+
|
| 1421 |
+
|
| 1422 |
+
class SpeechRecognitionAlternative(proto.Message):
|
| 1423 |
+
r"""Alternative hypotheses (a.k.a. n-best list).
|
| 1424 |
+
|
| 1425 |
+
Attributes:
|
| 1426 |
+
transcript (str):
|
| 1427 |
+
Transcript text representing the words that
|
| 1428 |
+
the user spoke. In languages that use spaces to
|
| 1429 |
+
separate words, the transcript might have a
|
| 1430 |
+
leading space if it isn't the first result. You
|
| 1431 |
+
can concatenate each result to obtain the full
|
| 1432 |
+
transcript without using a separator.
|
| 1433 |
+
confidence (float):
|
| 1434 |
+
The confidence estimate between 0.0 and 1.0. A higher number
|
| 1435 |
+
indicates an estimated greater likelihood that the
|
| 1436 |
+
recognized words are correct. This field is set only for the
|
| 1437 |
+
top alternative of a non-streaming result or, of a streaming
|
| 1438 |
+
result where ``is_final=true``. This field is not guaranteed
|
| 1439 |
+
to be accurate and users should not rely on it to be always
|
| 1440 |
+
provided. The default of 0.0 is a sentinel value indicating
|
| 1441 |
+
``confidence`` was not set.
|
| 1442 |
+
words (MutableSequence[google.cloud.speech_v1.types.WordInfo]):
|
| 1443 |
+
A list of word-specific information for each recognized
|
| 1444 |
+
word. Note: When ``enable_speaker_diarization`` is true, you
|
| 1445 |
+
will see all the words from the beginning of the audio.
|
| 1446 |
+
"""
|
| 1447 |
+
|
| 1448 |
+
transcript: str = proto.Field(
|
| 1449 |
+
proto.STRING,
|
| 1450 |
+
number=1,
|
| 1451 |
+
)
|
| 1452 |
+
confidence: float = proto.Field(
|
| 1453 |
+
proto.FLOAT,
|
| 1454 |
+
number=2,
|
| 1455 |
+
)
|
| 1456 |
+
words: MutableSequence["WordInfo"] = proto.RepeatedField(
|
| 1457 |
+
proto.MESSAGE,
|
| 1458 |
+
number=3,
|
| 1459 |
+
message="WordInfo",
|
| 1460 |
+
)
|
| 1461 |
+
|
| 1462 |
+
|
| 1463 |
+
class WordInfo(proto.Message):
|
| 1464 |
+
r"""Word-specific information for recognized words.
|
| 1465 |
+
|
| 1466 |
+
Attributes:
|
| 1467 |
+
start_time (google.protobuf.duration_pb2.Duration):
|
| 1468 |
+
Time offset relative to the beginning of the audio, and
|
| 1469 |
+
corresponding to the start of the spoken word. This field is
|
| 1470 |
+
only set if ``enable_word_time_offsets=true`` and only in
|
| 1471 |
+
the top hypothesis. This is an experimental feature and the
|
| 1472 |
+
accuracy of the time offset can vary.
|
| 1473 |
+
end_time (google.protobuf.duration_pb2.Duration):
|
| 1474 |
+
Time offset relative to the beginning of the audio, and
|
| 1475 |
+
corresponding to the end of the spoken word. This field is
|
| 1476 |
+
only set if ``enable_word_time_offsets=true`` and only in
|
| 1477 |
+
the top hypothesis. This is an experimental feature and the
|
| 1478 |
+
accuracy of the time offset can vary.
|
| 1479 |
+
word (str):
|
| 1480 |
+
The word corresponding to this set of
|
| 1481 |
+
information.
|
| 1482 |
+
confidence (float):
|
| 1483 |
+
The confidence estimate between 0.0 and 1.0. A higher number
|
| 1484 |
+
indicates an estimated greater likelihood that the
|
| 1485 |
+
recognized words are correct. This field is set only for the
|
| 1486 |
+
top alternative of a non-streaming result or, of a streaming
|
| 1487 |
+
result where ``is_final=true``. This field is not guaranteed
|
| 1488 |
+
to be accurate and users should not rely on it to be always
|
| 1489 |
+
provided. The default of 0.0 is a sentinel value indicating
|
| 1490 |
+
``confidence`` was not set.
|
| 1491 |
+
speaker_tag (int):
|
| 1492 |
+
Output only. A distinct integer value is assigned for every
|
| 1493 |
+
speaker within the audio. This field specifies which one of
|
| 1494 |
+
those speakers was detected to have spoken this word. Value
|
| 1495 |
+
ranges from '1' to diarization_speaker_count. speaker_tag is
|
| 1496 |
+
set if enable_speaker_diarization = 'true' and only for the
|
| 1497 |
+
top alternative. Note: Use speaker_label instead.
|
| 1498 |
+
speaker_label (str):
|
| 1499 |
+
Output only. A label value assigned for every unique speaker
|
| 1500 |
+
within the audio. This field specifies which speaker was
|
| 1501 |
+
detected to have spoken this word. For some models, like
|
| 1502 |
+
medical_conversation this can be actual speaker role, for
|
| 1503 |
+
example "patient" or "provider", but generally this would be
|
| 1504 |
+
a number identifying a speaker. This field is only set if
|
| 1505 |
+
enable_speaker_diarization = 'true' and only for the top
|
| 1506 |
+
alternative.
|
| 1507 |
+
"""
|
| 1508 |
+
|
| 1509 |
+
start_time: duration_pb2.Duration = proto.Field(
|
| 1510 |
+
proto.MESSAGE,
|
| 1511 |
+
number=1,
|
| 1512 |
+
message=duration_pb2.Duration,
|
| 1513 |
+
)
|
| 1514 |
+
end_time: duration_pb2.Duration = proto.Field(
|
| 1515 |
+
proto.MESSAGE,
|
| 1516 |
+
number=2,
|
| 1517 |
+
message=duration_pb2.Duration,
|
| 1518 |
+
)
|
| 1519 |
+
word: str = proto.Field(
|
| 1520 |
+
proto.STRING,
|
| 1521 |
+
number=3,
|
| 1522 |
+
)
|
| 1523 |
+
confidence: float = proto.Field(
|
| 1524 |
+
proto.FLOAT,
|
| 1525 |
+
number=4,
|
| 1526 |
+
)
|
| 1527 |
+
speaker_tag: int = proto.Field(
|
| 1528 |
+
proto.INT32,
|
| 1529 |
+
number=5,
|
| 1530 |
+
)
|
| 1531 |
+
speaker_label: str = proto.Field(
|
| 1532 |
+
proto.STRING,
|
| 1533 |
+
number=6,
|
| 1534 |
+
)
|
| 1535 |
+
|
| 1536 |
+
|
| 1537 |
+
class SpeechAdaptationInfo(proto.Message):
|
| 1538 |
+
r"""Information on speech adaptation use in results
|
| 1539 |
+
|
| 1540 |
+
Attributes:
|
| 1541 |
+
adaptation_timeout (bool):
|
| 1542 |
+
Whether there was a timeout when applying
|
| 1543 |
+
speech adaptation. If true, adaptation had no
|
| 1544 |
+
effect in the response transcript.
|
| 1545 |
+
timeout_message (str):
|
| 1546 |
+
If set, returns a message specifying which
|
| 1547 |
+
part of the speech adaptation request timed out.
|
| 1548 |
+
"""
|
| 1549 |
+
|
| 1550 |
+
adaptation_timeout: bool = proto.Field(
|
| 1551 |
+
proto.BOOL,
|
| 1552 |
+
number=1,
|
| 1553 |
+
)
|
| 1554 |
+
timeout_message: str = proto.Field(
|
| 1555 |
+
proto.STRING,
|
| 1556 |
+
number=4,
|
| 1557 |
+
)
|
| 1558 |
+
|
| 1559 |
+
|
| 1560 |
+
__all__ = tuple(sorted(__protobuf__.manifest))
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/types/cloud_speech_adaptation.py
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
from typing import MutableMapping, MutableSequence
|
| 19 |
+
|
| 20 |
+
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
|
| 21 |
+
import proto # type: ignore
|
| 22 |
+
|
| 23 |
+
from google.cloud.speech_v1.types import resource
|
| 24 |
+
|
| 25 |
+
__protobuf__ = proto.module(
|
| 26 |
+
package="google.cloud.speech.v1",
|
| 27 |
+
manifest={
|
| 28 |
+
"CreatePhraseSetRequest",
|
| 29 |
+
"UpdatePhraseSetRequest",
|
| 30 |
+
"GetPhraseSetRequest",
|
| 31 |
+
"ListPhraseSetRequest",
|
| 32 |
+
"ListPhraseSetResponse",
|
| 33 |
+
"DeletePhraseSetRequest",
|
| 34 |
+
"CreateCustomClassRequest",
|
| 35 |
+
"UpdateCustomClassRequest",
|
| 36 |
+
"GetCustomClassRequest",
|
| 37 |
+
"ListCustomClassesRequest",
|
| 38 |
+
"ListCustomClassesResponse",
|
| 39 |
+
"DeleteCustomClassRequest",
|
| 40 |
+
},
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class CreatePhraseSetRequest(proto.Message):
|
| 45 |
+
r"""Message sent by the client for the ``CreatePhraseSet`` method.
|
| 46 |
+
|
| 47 |
+
Attributes:
|
| 48 |
+
parent (str):
|
| 49 |
+
Required. The parent resource where this phrase set will be
|
| 50 |
+
created. Format:
|
| 51 |
+
|
| 52 |
+
``projects/{project}/locations/{location}``
|
| 53 |
+
|
| 54 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 55 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 56 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 57 |
+
location. To specify a region, use a `regional
|
| 58 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 59 |
+
with matching ``us`` or ``eu`` location value.
|
| 60 |
+
phrase_set_id (str):
|
| 61 |
+
Required. The ID to use for the phrase set,
|
| 62 |
+
which will become the final component of the
|
| 63 |
+
phrase set's resource name.
|
| 64 |
+
|
| 65 |
+
This value should restrict to letters, numbers,
|
| 66 |
+
and hyphens, with the first character a letter,
|
| 67 |
+
the last a letter or a number, and be 4-63
|
| 68 |
+
characters.
|
| 69 |
+
phrase_set (google.cloud.speech_v1.types.PhraseSet):
|
| 70 |
+
Required. The phrase set to create.
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
parent: str = proto.Field(
|
| 74 |
+
proto.STRING,
|
| 75 |
+
number=1,
|
| 76 |
+
)
|
| 77 |
+
phrase_set_id: str = proto.Field(
|
| 78 |
+
proto.STRING,
|
| 79 |
+
number=2,
|
| 80 |
+
)
|
| 81 |
+
phrase_set: resource.PhraseSet = proto.Field(
|
| 82 |
+
proto.MESSAGE,
|
| 83 |
+
number=3,
|
| 84 |
+
message=resource.PhraseSet,
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class UpdatePhraseSetRequest(proto.Message):
|
| 89 |
+
r"""Message sent by the client for the ``UpdatePhraseSet`` method.
|
| 90 |
+
|
| 91 |
+
Attributes:
|
| 92 |
+
phrase_set (google.cloud.speech_v1.types.PhraseSet):
|
| 93 |
+
Required. The phrase set to update.
|
| 94 |
+
|
| 95 |
+
The phrase set's ``name`` field is used to identify the set
|
| 96 |
+
to be updated. Format:
|
| 97 |
+
|
| 98 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 99 |
+
|
| 100 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 101 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 102 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 103 |
+
location. To specify a region, use a `regional
|
| 104 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 105 |
+
with matching ``us`` or ``eu`` location value.
|
| 106 |
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
| 107 |
+
The list of fields to be updated.
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
phrase_set: resource.PhraseSet = proto.Field(
|
| 111 |
+
proto.MESSAGE,
|
| 112 |
+
number=1,
|
| 113 |
+
message=resource.PhraseSet,
|
| 114 |
+
)
|
| 115 |
+
update_mask: field_mask_pb2.FieldMask = proto.Field(
|
| 116 |
+
proto.MESSAGE,
|
| 117 |
+
number=2,
|
| 118 |
+
message=field_mask_pb2.FieldMask,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class GetPhraseSetRequest(proto.Message):
|
| 123 |
+
r"""Message sent by the client for the ``GetPhraseSet`` method.
|
| 124 |
+
|
| 125 |
+
Attributes:
|
| 126 |
+
name (str):
|
| 127 |
+
Required. The name of the phrase set to retrieve. Format:
|
| 128 |
+
|
| 129 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 130 |
+
|
| 131 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 132 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 133 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 134 |
+
location. To specify a region, use a `regional
|
| 135 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 136 |
+
with matching ``us`` or ``eu`` location value.
|
| 137 |
+
"""
|
| 138 |
+
|
| 139 |
+
name: str = proto.Field(
|
| 140 |
+
proto.STRING,
|
| 141 |
+
number=1,
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
class ListPhraseSetRequest(proto.Message):
|
| 146 |
+
r"""Message sent by the client for the ``ListPhraseSet`` method.
|
| 147 |
+
|
| 148 |
+
Attributes:
|
| 149 |
+
parent (str):
|
| 150 |
+
Required. The parent, which owns this collection of phrase
|
| 151 |
+
set. Format:
|
| 152 |
+
|
| 153 |
+
``projects/{project}/locations/{location}``
|
| 154 |
+
|
| 155 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 156 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 157 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 158 |
+
location. To specify a region, use a `regional
|
| 159 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 160 |
+
with matching ``us`` or ``eu`` location value.
|
| 161 |
+
page_size (int):
|
| 162 |
+
The maximum number of phrase sets to return.
|
| 163 |
+
The service may return fewer than this value. If
|
| 164 |
+
unspecified, at most 50 phrase sets will be
|
| 165 |
+
returned. The maximum value is 1000; values
|
| 166 |
+
above 1000 will be coerced to 1000.
|
| 167 |
+
page_token (str):
|
| 168 |
+
A page token, received from a previous ``ListPhraseSet``
|
| 169 |
+
call. Provide this to retrieve the subsequent page.
|
| 170 |
+
|
| 171 |
+
When paginating, all other parameters provided to
|
| 172 |
+
``ListPhraseSet`` must match the call that provided the page
|
| 173 |
+
token.
|
| 174 |
+
"""
|
| 175 |
+
|
| 176 |
+
parent: str = proto.Field(
|
| 177 |
+
proto.STRING,
|
| 178 |
+
number=1,
|
| 179 |
+
)
|
| 180 |
+
page_size: int = proto.Field(
|
| 181 |
+
proto.INT32,
|
| 182 |
+
number=2,
|
| 183 |
+
)
|
| 184 |
+
page_token: str = proto.Field(
|
| 185 |
+
proto.STRING,
|
| 186 |
+
number=3,
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
class ListPhraseSetResponse(proto.Message):
|
| 191 |
+
r"""Message returned to the client by the ``ListPhraseSet`` method.
|
| 192 |
+
|
| 193 |
+
Attributes:
|
| 194 |
+
phrase_sets (MutableSequence[google.cloud.speech_v1.types.PhraseSet]):
|
| 195 |
+
The phrase set.
|
| 196 |
+
next_page_token (str):
|
| 197 |
+
A token, which can be sent as ``page_token`` to retrieve the
|
| 198 |
+
next page. If this field is omitted, there are no subsequent
|
| 199 |
+
pages.
|
| 200 |
+
"""
|
| 201 |
+
|
| 202 |
+
@property
|
| 203 |
+
def raw_page(self):
|
| 204 |
+
return self
|
| 205 |
+
|
| 206 |
+
phrase_sets: MutableSequence[resource.PhraseSet] = proto.RepeatedField(
|
| 207 |
+
proto.MESSAGE,
|
| 208 |
+
number=1,
|
| 209 |
+
message=resource.PhraseSet,
|
| 210 |
+
)
|
| 211 |
+
next_page_token: str = proto.Field(
|
| 212 |
+
proto.STRING,
|
| 213 |
+
number=2,
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
class DeletePhraseSetRequest(proto.Message):
|
| 218 |
+
r"""Message sent by the client for the ``DeletePhraseSet`` method.
|
| 219 |
+
|
| 220 |
+
Attributes:
|
| 221 |
+
name (str):
|
| 222 |
+
Required. The name of the phrase set to delete. Format:
|
| 223 |
+
|
| 224 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 225 |
+
"""
|
| 226 |
+
|
| 227 |
+
name: str = proto.Field(
|
| 228 |
+
proto.STRING,
|
| 229 |
+
number=1,
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
class CreateCustomClassRequest(proto.Message):
|
| 234 |
+
r"""Message sent by the client for the ``CreateCustomClass`` method.
|
| 235 |
+
|
| 236 |
+
Attributes:
|
| 237 |
+
parent (str):
|
| 238 |
+
Required. The parent resource where this custom class will
|
| 239 |
+
be created. Format:
|
| 240 |
+
|
| 241 |
+
``projects/{project}/locations/{location}/customClasses``
|
| 242 |
+
|
| 243 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 244 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 245 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 246 |
+
location. To specify a region, use a `regional
|
| 247 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 248 |
+
with matching ``us`` or ``eu`` location value.
|
| 249 |
+
custom_class_id (str):
|
| 250 |
+
Required. The ID to use for the custom class,
|
| 251 |
+
which will become the final component of the
|
| 252 |
+
custom class' resource name.
|
| 253 |
+
|
| 254 |
+
This value should restrict to letters, numbers,
|
| 255 |
+
and hyphens, with the first character a letter,
|
| 256 |
+
the last a letter or a number, and be 4-63
|
| 257 |
+
characters.
|
| 258 |
+
custom_class (google.cloud.speech_v1.types.CustomClass):
|
| 259 |
+
Required. The custom class to create.
|
| 260 |
+
"""
|
| 261 |
+
|
| 262 |
+
parent: str = proto.Field(
|
| 263 |
+
proto.STRING,
|
| 264 |
+
number=1,
|
| 265 |
+
)
|
| 266 |
+
custom_class_id: str = proto.Field(
|
| 267 |
+
proto.STRING,
|
| 268 |
+
number=2,
|
| 269 |
+
)
|
| 270 |
+
custom_class: resource.CustomClass = proto.Field(
|
| 271 |
+
proto.MESSAGE,
|
| 272 |
+
number=3,
|
| 273 |
+
message=resource.CustomClass,
|
| 274 |
+
)
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
class UpdateCustomClassRequest(proto.Message):
|
| 278 |
+
r"""Message sent by the client for the ``UpdateCustomClass`` method.
|
| 279 |
+
|
| 280 |
+
Attributes:
|
| 281 |
+
custom_class (google.cloud.speech_v1.types.CustomClass):
|
| 282 |
+
Required. The custom class to update.
|
| 283 |
+
|
| 284 |
+
The custom class's ``name`` field is used to identify the
|
| 285 |
+
custom class to be updated. Format:
|
| 286 |
+
|
| 287 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 288 |
+
|
| 289 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 290 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 291 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 292 |
+
location. To specify a region, use a `regional
|
| 293 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 294 |
+
with matching ``us`` or ``eu`` location value.
|
| 295 |
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
| 296 |
+
The list of fields to be updated.
|
| 297 |
+
"""
|
| 298 |
+
|
| 299 |
+
custom_class: resource.CustomClass = proto.Field(
|
| 300 |
+
proto.MESSAGE,
|
| 301 |
+
number=1,
|
| 302 |
+
message=resource.CustomClass,
|
| 303 |
+
)
|
| 304 |
+
update_mask: field_mask_pb2.FieldMask = proto.Field(
|
| 305 |
+
proto.MESSAGE,
|
| 306 |
+
number=2,
|
| 307 |
+
message=field_mask_pb2.FieldMask,
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
class GetCustomClassRequest(proto.Message):
|
| 312 |
+
r"""Message sent by the client for the ``GetCustomClass`` method.
|
| 313 |
+
|
| 314 |
+
Attributes:
|
| 315 |
+
name (str):
|
| 316 |
+
Required. The name of the custom class to retrieve. Format:
|
| 317 |
+
|
| 318 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 319 |
+
"""
|
| 320 |
+
|
| 321 |
+
name: str = proto.Field(
|
| 322 |
+
proto.STRING,
|
| 323 |
+
number=1,
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
class ListCustomClassesRequest(proto.Message):
|
| 328 |
+
r"""Message sent by the client for the ``ListCustomClasses`` method.
|
| 329 |
+
|
| 330 |
+
Attributes:
|
| 331 |
+
parent (str):
|
| 332 |
+
Required. The parent, which owns this collection of custom
|
| 333 |
+
classes. Format:
|
| 334 |
+
|
| 335 |
+
``projects/{project}/locations/{location}/customClasses``
|
| 336 |
+
|
| 337 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 338 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 339 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 340 |
+
location. To specify a region, use a `regional
|
| 341 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 342 |
+
with matching ``us`` or ``eu`` location value.
|
| 343 |
+
page_size (int):
|
| 344 |
+
The maximum number of custom classes to
|
| 345 |
+
return. The service may return fewer than this
|
| 346 |
+
value. If unspecified, at most 50 custom classes
|
| 347 |
+
will be returned. The maximum value is 1000;
|
| 348 |
+
values above 1000 will be coerced to 1000.
|
| 349 |
+
page_token (str):
|
| 350 |
+
A page token, received from a previous ``ListCustomClass``
|
| 351 |
+
call. Provide this to retrieve the subsequent page.
|
| 352 |
+
|
| 353 |
+
When paginating, all other parameters provided to
|
| 354 |
+
``ListCustomClass`` must match the call that provided the
|
| 355 |
+
page token.
|
| 356 |
+
"""
|
| 357 |
+
|
| 358 |
+
parent: str = proto.Field(
|
| 359 |
+
proto.STRING,
|
| 360 |
+
number=1,
|
| 361 |
+
)
|
| 362 |
+
page_size: int = proto.Field(
|
| 363 |
+
proto.INT32,
|
| 364 |
+
number=2,
|
| 365 |
+
)
|
| 366 |
+
page_token: str = proto.Field(
|
| 367 |
+
proto.STRING,
|
| 368 |
+
number=3,
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
class ListCustomClassesResponse(proto.Message):
|
| 373 |
+
r"""Message returned to the client by the ``ListCustomClasses`` method.
|
| 374 |
+
|
| 375 |
+
Attributes:
|
| 376 |
+
custom_classes (MutableSequence[google.cloud.speech_v1.types.CustomClass]):
|
| 377 |
+
The custom classes.
|
| 378 |
+
next_page_token (str):
|
| 379 |
+
A token, which can be sent as ``page_token`` to retrieve the
|
| 380 |
+
next page. If this field is omitted, there are no subsequent
|
| 381 |
+
pages.
|
| 382 |
+
"""
|
| 383 |
+
|
| 384 |
+
@property
|
| 385 |
+
def raw_page(self):
|
| 386 |
+
return self
|
| 387 |
+
|
| 388 |
+
custom_classes: MutableSequence[resource.CustomClass] = proto.RepeatedField(
|
| 389 |
+
proto.MESSAGE,
|
| 390 |
+
number=1,
|
| 391 |
+
message=resource.CustomClass,
|
| 392 |
+
)
|
| 393 |
+
next_page_token: str = proto.Field(
|
| 394 |
+
proto.STRING,
|
| 395 |
+
number=2,
|
| 396 |
+
)
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
class DeleteCustomClassRequest(proto.Message):
|
| 400 |
+
r"""Message sent by the client for the ``DeleteCustomClass`` method.
|
| 401 |
+
|
| 402 |
+
Attributes:
|
| 403 |
+
name (str):
|
| 404 |
+
Required. The name of the custom class to delete. Format:
|
| 405 |
+
|
| 406 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 407 |
+
|
| 408 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 409 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 410 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 411 |
+
location. To specify a region, use a `regional
|
| 412 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 413 |
+
with matching ``us`` or ``eu`` location value.
|
| 414 |
+
"""
|
| 415 |
+
|
| 416 |
+
name: str = proto.Field(
|
| 417 |
+
proto.STRING,
|
| 418 |
+
number=1,
|
| 419 |
+
)
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
__all__ = tuple(sorted(__protobuf__.manifest))
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1/types/resource.py
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
from typing import MutableMapping, MutableSequence
|
| 19 |
+
|
| 20 |
+
import proto # type: ignore
|
| 21 |
+
|
| 22 |
+
__protobuf__ = proto.module(
|
| 23 |
+
package="google.cloud.speech.v1",
|
| 24 |
+
manifest={
|
| 25 |
+
"CustomClass",
|
| 26 |
+
"PhraseSet",
|
| 27 |
+
"SpeechAdaptation",
|
| 28 |
+
"TranscriptNormalization",
|
| 29 |
+
},
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class CustomClass(proto.Message):
|
| 34 |
+
r"""A set of words or phrases that represents a common concept
|
| 35 |
+
likely to appear in your audio, for example a list of passenger
|
| 36 |
+
ship names. CustomClass items can be substituted into
|
| 37 |
+
placeholders that you set in PhraseSet phrases.
|
| 38 |
+
|
| 39 |
+
Attributes:
|
| 40 |
+
name (str):
|
| 41 |
+
The resource name of the custom class.
|
| 42 |
+
custom_class_id (str):
|
| 43 |
+
If this custom class is a resource, the custom_class_id is
|
| 44 |
+
the resource id of the CustomClass. Case sensitive.
|
| 45 |
+
items (MutableSequence[google.cloud.speech_v1.types.CustomClass.ClassItem]):
|
| 46 |
+
A collection of class items.
|
| 47 |
+
"""
|
| 48 |
+
|
| 49 |
+
class ClassItem(proto.Message):
|
| 50 |
+
r"""An item of the class.
|
| 51 |
+
|
| 52 |
+
Attributes:
|
| 53 |
+
value (str):
|
| 54 |
+
The class item's value.
|
| 55 |
+
"""
|
| 56 |
+
|
| 57 |
+
value: str = proto.Field(
|
| 58 |
+
proto.STRING,
|
| 59 |
+
number=1,
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
name: str = proto.Field(
|
| 63 |
+
proto.STRING,
|
| 64 |
+
number=1,
|
| 65 |
+
)
|
| 66 |
+
custom_class_id: str = proto.Field(
|
| 67 |
+
proto.STRING,
|
| 68 |
+
number=2,
|
| 69 |
+
)
|
| 70 |
+
items: MutableSequence[ClassItem] = proto.RepeatedField(
|
| 71 |
+
proto.MESSAGE,
|
| 72 |
+
number=3,
|
| 73 |
+
message=ClassItem,
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class PhraseSet(proto.Message):
|
| 78 |
+
r"""Provides "hints" to the speech recognizer to favor specific
|
| 79 |
+
words and phrases in the results.
|
| 80 |
+
|
| 81 |
+
Attributes:
|
| 82 |
+
name (str):
|
| 83 |
+
The resource name of the phrase set.
|
| 84 |
+
phrases (MutableSequence[google.cloud.speech_v1.types.PhraseSet.Phrase]):
|
| 85 |
+
A list of word and phrases.
|
| 86 |
+
boost (float):
|
| 87 |
+
Hint Boost. Positive value will increase the probability
|
| 88 |
+
that a specific phrase will be recognized over other similar
|
| 89 |
+
sounding phrases. The higher the boost, the higher the
|
| 90 |
+
chance of false positive recognition as well. Negative boost
|
| 91 |
+
values would correspond to anti-biasing. Anti-biasing is not
|
| 92 |
+
enabled, so negative boost will simply be ignored. Though
|
| 93 |
+
``boost`` can accept a wide range of positive values, most
|
| 94 |
+
use cases are best served with values between 0 (exclusive)
|
| 95 |
+
and 20. We recommend using a binary search approach to
|
| 96 |
+
finding the optimal value for your use case as well as
|
| 97 |
+
adding phrases both with and without boost to your requests.
|
| 98 |
+
"""
|
| 99 |
+
|
| 100 |
+
class Phrase(proto.Message):
|
| 101 |
+
r"""A phrases containing words and phrase "hints" so that the speech
|
| 102 |
+
recognition is more likely to recognize them. This can be used to
|
| 103 |
+
improve the accuracy for specific words and phrases, for example, if
|
| 104 |
+
specific commands are typically spoken by the user. This can also be
|
| 105 |
+
used to add additional words to the vocabulary of the recognizer.
|
| 106 |
+
See `usage
|
| 107 |
+
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
|
| 108 |
+
|
| 109 |
+
List items can also include pre-built or custom classes containing
|
| 110 |
+
groups of words that represent common concepts that occur in natural
|
| 111 |
+
language. For example, rather than providing a phrase hint for every
|
| 112 |
+
month of the year (e.g. "i was born in january", "i was born in
|
| 113 |
+
febuary", ...), use the pre-built ``$MONTH`` class improves the
|
| 114 |
+
likelihood of correctly transcribing audio that includes months
|
| 115 |
+
(e.g. "i was born in $month"). To refer to pre-built classes, use
|
| 116 |
+
the class' symbol prepended with ``$`` e.g. ``$MONTH``. To refer to
|
| 117 |
+
custom classes that were defined inline in the request, set the
|
| 118 |
+
class's ``custom_class_id`` to a string unique to all class
|
| 119 |
+
resources and inline classes. Then use the class' id wrapped in
|
| 120 |
+
$\ ``{...}`` e.g. "${my-months}". To refer to custom classes
|
| 121 |
+
resources, use the class' id wrapped in ``${}`` (e.g.
|
| 122 |
+
``${my-months}``).
|
| 123 |
+
|
| 124 |
+
Speech-to-Text supports three locations: ``global``, ``us`` (US
|
| 125 |
+
North America), and ``eu`` (Europe). If you are calling the
|
| 126 |
+
``speech.googleapis.com`` endpoint, use the ``global`` location. To
|
| 127 |
+
specify a region, use a `regional
|
| 128 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 129 |
+
with matching ``us`` or ``eu`` location value.
|
| 130 |
+
|
| 131 |
+
Attributes:
|
| 132 |
+
value (str):
|
| 133 |
+
The phrase itself.
|
| 134 |
+
boost (float):
|
| 135 |
+
Hint Boost. Overrides the boost set at the phrase set level.
|
| 136 |
+
Positive value will increase the probability that a specific
|
| 137 |
+
phrase will be recognized over other similar sounding
|
| 138 |
+
phrases. The higher the boost, the higher the chance of
|
| 139 |
+
false positive recognition as well. Negative boost will
|
| 140 |
+
simply be ignored. Though ``boost`` can accept a wide range
|
| 141 |
+
of positive values, most use cases are best served with
|
| 142 |
+
values between 0 and 20. We recommend using a binary search
|
| 143 |
+
approach to finding the optimal value for your use case as
|
| 144 |
+
well as adding phrases both with and without boost to your
|
| 145 |
+
requests.
|
| 146 |
+
"""
|
| 147 |
+
|
| 148 |
+
value: str = proto.Field(
|
| 149 |
+
proto.STRING,
|
| 150 |
+
number=1,
|
| 151 |
+
)
|
| 152 |
+
boost: float = proto.Field(
|
| 153 |
+
proto.FLOAT,
|
| 154 |
+
number=2,
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
name: str = proto.Field(
|
| 158 |
+
proto.STRING,
|
| 159 |
+
number=1,
|
| 160 |
+
)
|
| 161 |
+
phrases: MutableSequence[Phrase] = proto.RepeatedField(
|
| 162 |
+
proto.MESSAGE,
|
| 163 |
+
number=2,
|
| 164 |
+
message=Phrase,
|
| 165 |
+
)
|
| 166 |
+
boost: float = proto.Field(
|
| 167 |
+
proto.FLOAT,
|
| 168 |
+
number=4,
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
class SpeechAdaptation(proto.Message):
|
| 173 |
+
r"""Speech adaptation configuration.
|
| 174 |
+
|
| 175 |
+
Attributes:
|
| 176 |
+
phrase_sets (MutableSequence[google.cloud.speech_v1.types.PhraseSet]):
|
| 177 |
+
A collection of phrase sets. To specify the hints inline,
|
| 178 |
+
leave the phrase set's ``name`` blank and fill in the rest
|
| 179 |
+
of its fields. Any phrase set can use any custom class.
|
| 180 |
+
phrase_set_references (MutableSequence[str]):
|
| 181 |
+
A collection of phrase set resource names to
|
| 182 |
+
use.
|
| 183 |
+
custom_classes (MutableSequence[google.cloud.speech_v1.types.CustomClass]):
|
| 184 |
+
A collection of custom classes. To specify the classes
|
| 185 |
+
inline, leave the class' ``name`` blank and fill in the rest
|
| 186 |
+
of its fields, giving it a unique ``custom_class_id``. Refer
|
| 187 |
+
to the inline defined class in phrase hints by its
|
| 188 |
+
``custom_class_id``.
|
| 189 |
+
abnf_grammar (google.cloud.speech_v1.types.SpeechAdaptation.ABNFGrammar):
|
| 190 |
+
Augmented Backus-Naur form (ABNF) is a
|
| 191 |
+
standardized grammar notation comprised by a set
|
| 192 |
+
of derivation rules. See specifications:
|
| 193 |
+
https://www.w3.org/TR/speech-grammar
|
| 194 |
+
"""
|
| 195 |
+
|
| 196 |
+
class ABNFGrammar(proto.Message):
|
| 197 |
+
r"""
|
| 198 |
+
|
| 199 |
+
Attributes:
|
| 200 |
+
abnf_strings (MutableSequence[str]):
|
| 201 |
+
All declarations and rules of an ABNF grammar
|
| 202 |
+
broken up into multiple strings that will end up
|
| 203 |
+
concatenated.
|
| 204 |
+
"""
|
| 205 |
+
|
| 206 |
+
abnf_strings: MutableSequence[str] = proto.RepeatedField(
|
| 207 |
+
proto.STRING,
|
| 208 |
+
number=1,
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
phrase_sets: MutableSequence["PhraseSet"] = proto.RepeatedField(
|
| 212 |
+
proto.MESSAGE,
|
| 213 |
+
number=1,
|
| 214 |
+
message="PhraseSet",
|
| 215 |
+
)
|
| 216 |
+
phrase_set_references: MutableSequence[str] = proto.RepeatedField(
|
| 217 |
+
proto.STRING,
|
| 218 |
+
number=2,
|
| 219 |
+
)
|
| 220 |
+
custom_classes: MutableSequence["CustomClass"] = proto.RepeatedField(
|
| 221 |
+
proto.MESSAGE,
|
| 222 |
+
number=3,
|
| 223 |
+
message="CustomClass",
|
| 224 |
+
)
|
| 225 |
+
abnf_grammar: ABNFGrammar = proto.Field(
|
| 226 |
+
proto.MESSAGE,
|
| 227 |
+
number=4,
|
| 228 |
+
message=ABNFGrammar,
|
| 229 |
+
)
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
class TranscriptNormalization(proto.Message):
|
| 233 |
+
r"""Transcription normalization configuration. Use transcription
|
| 234 |
+
normalization to automatically replace parts of the transcript
|
| 235 |
+
with phrases of your choosing. For StreamingRecognize, this
|
| 236 |
+
normalization only applies to stable partial transcripts
|
| 237 |
+
(stability > 0.8) and final transcripts.
|
| 238 |
+
|
| 239 |
+
Attributes:
|
| 240 |
+
entries (MutableSequence[google.cloud.speech_v1.types.TranscriptNormalization.Entry]):
|
| 241 |
+
A list of replacement entries. We will perform replacement
|
| 242 |
+
with one entry at a time. For example, the second entry in
|
| 243 |
+
["cat" => "dog", "mountain cat" => "mountain dog"] will
|
| 244 |
+
never be applied because we will always process the first
|
| 245 |
+
entry before it. At most 100 entries.
|
| 246 |
+
"""
|
| 247 |
+
|
| 248 |
+
class Entry(proto.Message):
|
| 249 |
+
r"""A single replacement configuration.
|
| 250 |
+
|
| 251 |
+
Attributes:
|
| 252 |
+
search (str):
|
| 253 |
+
What to replace. Max length is 100
|
| 254 |
+
characters.
|
| 255 |
+
replace (str):
|
| 256 |
+
What to replace with. Max length is 100
|
| 257 |
+
characters.
|
| 258 |
+
case_sensitive (bool):
|
| 259 |
+
Whether the search is case sensitive.
|
| 260 |
+
"""
|
| 261 |
+
|
| 262 |
+
search: str = proto.Field(
|
| 263 |
+
proto.STRING,
|
| 264 |
+
number=1,
|
| 265 |
+
)
|
| 266 |
+
replace: str = proto.Field(
|
| 267 |
+
proto.STRING,
|
| 268 |
+
number=2,
|
| 269 |
+
)
|
| 270 |
+
case_sensitive: bool = proto.Field(
|
| 271 |
+
proto.BOOL,
|
| 272 |
+
number=3,
|
| 273 |
+
)
|
| 274 |
+
|
| 275 |
+
entries: MutableSequence[Entry] = proto.RepeatedField(
|
| 276 |
+
proto.MESSAGE,
|
| 277 |
+
number=1,
|
| 278 |
+
message=Entry,
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
__all__ = tuple(sorted(__protobuf__.manifest))
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/__init__.py
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import sys
|
| 17 |
+
|
| 18 |
+
import google.api_core as api_core
|
| 19 |
+
|
| 20 |
+
from google.cloud.speech_v1p1beta1 import gapic_version as package_version
|
| 21 |
+
|
| 22 |
+
__version__ = package_version.__version__
|
| 23 |
+
|
| 24 |
+
if sys.version_info >= (3, 8): # pragma: NO COVER
|
| 25 |
+
from importlib import metadata
|
| 26 |
+
else: # pragma: NO COVER
|
| 27 |
+
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
|
| 28 |
+
# this code path once we drop support for Python 3.7
|
| 29 |
+
import importlib_metadata as metadata
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
from .services.adaptation import AdaptationAsyncClient, AdaptationClient
|
| 33 |
+
from .services.speech import SpeechAsyncClient, SpeechClient
|
| 34 |
+
from .types.cloud_speech import (
|
| 35 |
+
LongRunningRecognizeMetadata,
|
| 36 |
+
LongRunningRecognizeRequest,
|
| 37 |
+
LongRunningRecognizeResponse,
|
| 38 |
+
RecognitionAudio,
|
| 39 |
+
RecognitionConfig,
|
| 40 |
+
RecognitionMetadata,
|
| 41 |
+
RecognizeRequest,
|
| 42 |
+
RecognizeResponse,
|
| 43 |
+
SpeakerDiarizationConfig,
|
| 44 |
+
SpeechAdaptationInfo,
|
| 45 |
+
SpeechContext,
|
| 46 |
+
SpeechRecognitionAlternative,
|
| 47 |
+
SpeechRecognitionResult,
|
| 48 |
+
StreamingRecognitionConfig,
|
| 49 |
+
StreamingRecognitionResult,
|
| 50 |
+
StreamingRecognizeRequest,
|
| 51 |
+
StreamingRecognizeResponse,
|
| 52 |
+
TranscriptOutputConfig,
|
| 53 |
+
WordInfo,
|
| 54 |
+
)
|
| 55 |
+
from .types.cloud_speech_adaptation import (
|
| 56 |
+
CreateCustomClassRequest,
|
| 57 |
+
CreatePhraseSetRequest,
|
| 58 |
+
DeleteCustomClassRequest,
|
| 59 |
+
DeletePhraseSetRequest,
|
| 60 |
+
GetCustomClassRequest,
|
| 61 |
+
GetPhraseSetRequest,
|
| 62 |
+
ListCustomClassesRequest,
|
| 63 |
+
ListCustomClassesResponse,
|
| 64 |
+
ListPhraseSetRequest,
|
| 65 |
+
ListPhraseSetResponse,
|
| 66 |
+
UpdateCustomClassRequest,
|
| 67 |
+
UpdatePhraseSetRequest,
|
| 68 |
+
)
|
| 69 |
+
from .types.resource import (
|
| 70 |
+
CustomClass,
|
| 71 |
+
PhraseSet,
|
| 72 |
+
SpeechAdaptation,
|
| 73 |
+
TranscriptNormalization,
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
if hasattr(api_core, "check_python_version") and hasattr(
|
| 77 |
+
api_core, "check_dependency_versions"
|
| 78 |
+
): # pragma: NO COVER
|
| 79 |
+
api_core.check_python_version("google.cloud.speech_v1p1beta1") # type: ignore
|
| 80 |
+
api_core.check_dependency_versions("google.cloud.speech_v1p1beta1") # type: ignore
|
| 81 |
+
else: # pragma: NO COVER
|
| 82 |
+
# An older version of api_core is installed which does not define the
|
| 83 |
+
# functions above. We do equivalent checks manually.
|
| 84 |
+
try:
|
| 85 |
+
import sys
|
| 86 |
+
import warnings
|
| 87 |
+
|
| 88 |
+
_py_version_str = sys.version.split()[0]
|
| 89 |
+
_package_label = "google.cloud.speech_v1p1beta1"
|
| 90 |
+
if sys.version_info < (3, 9):
|
| 91 |
+
warnings.warn(
|
| 92 |
+
"You are using a non-supported Python version "
|
| 93 |
+
+ f"({_py_version_str}). Google will not post any further "
|
| 94 |
+
+ f"updates to {_package_label} supporting this Python version. "
|
| 95 |
+
+ "Please upgrade to the latest Python version, or at "
|
| 96 |
+
+ f"least to Python 3.9, and then update {_package_label}.",
|
| 97 |
+
FutureWarning,
|
| 98 |
+
)
|
| 99 |
+
if sys.version_info[:2] == (3, 9):
|
| 100 |
+
warnings.warn(
|
| 101 |
+
f"You are using a Python version ({_py_version_str}) "
|
| 102 |
+
+ f"which Google will stop supporting in {_package_label} in "
|
| 103 |
+
+ "January 2026. Please "
|
| 104 |
+
+ "upgrade to the latest Python version, or at "
|
| 105 |
+
+ "least to Python 3.10, before then, and "
|
| 106 |
+
+ f"then update {_package_label}.",
|
| 107 |
+
FutureWarning,
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
def parse_version_to_tuple(version_string: str):
|
| 111 |
+
"""Safely converts a semantic version string to a comparable tuple of integers.
|
| 112 |
+
Example: "4.25.8" -> (4, 25, 8)
|
| 113 |
+
Ignores non-numeric parts and handles common version formats.
|
| 114 |
+
Args:
|
| 115 |
+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
|
| 116 |
+
Returns:
|
| 117 |
+
Tuple of integers for the parsed version string.
|
| 118 |
+
"""
|
| 119 |
+
parts = []
|
| 120 |
+
for part in version_string.split("."):
|
| 121 |
+
try:
|
| 122 |
+
parts.append(int(part))
|
| 123 |
+
except ValueError:
|
| 124 |
+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
|
| 125 |
+
# This is a simplification compared to 'packaging.parse_version', but sufficient
|
| 126 |
+
# for comparing strictly numeric semantic versions.
|
| 127 |
+
break
|
| 128 |
+
return tuple(parts)
|
| 129 |
+
|
| 130 |
+
def _get_version(dependency_name):
|
| 131 |
+
try:
|
| 132 |
+
version_string: str = metadata.version(dependency_name)
|
| 133 |
+
parsed_version = parse_version_to_tuple(version_string)
|
| 134 |
+
return (parsed_version, version_string)
|
| 135 |
+
except Exception:
|
| 136 |
+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
|
| 137 |
+
# or errors during parse_version_to_tuple
|
| 138 |
+
return (None, "--")
|
| 139 |
+
|
| 140 |
+
_dependency_package = "google.protobuf"
|
| 141 |
+
_next_supported_version = "4.25.8"
|
| 142 |
+
_next_supported_version_tuple = (4, 25, 8)
|
| 143 |
+
_recommendation = " (we recommend 6.x)"
|
| 144 |
+
(_version_used, _version_used_string) = _get_version(_dependency_package)
|
| 145 |
+
if _version_used and _version_used < _next_supported_version_tuple:
|
| 146 |
+
warnings.warn(
|
| 147 |
+
f"Package {_package_label} depends on "
|
| 148 |
+
+ f"{_dependency_package}, currently installed at version "
|
| 149 |
+
+ f"{_version_used_string}. Future updates to "
|
| 150 |
+
+ f"{_package_label} will require {_dependency_package} at "
|
| 151 |
+
+ f"version {_next_supported_version} or higher{_recommendation}."
|
| 152 |
+
+ " Please ensure "
|
| 153 |
+
+ "that either (a) your Python environment doesn't pin the "
|
| 154 |
+
+ f"version of {_dependency_package}, so that updates to "
|
| 155 |
+
+ f"{_package_label} can require the higher version, or "
|
| 156 |
+
+ "(b) you manually update your Python environment to use at "
|
| 157 |
+
+ f"least version {_next_supported_version} of "
|
| 158 |
+
+ f"{_dependency_package}.",
|
| 159 |
+
FutureWarning,
|
| 160 |
+
)
|
| 161 |
+
except Exception:
|
| 162 |
+
warnings.warn(
|
| 163 |
+
"Could not determine the version of Python "
|
| 164 |
+
+ "currently being used. To continue receiving "
|
| 165 |
+
+ "updates for {_package_label}, ensure you are "
|
| 166 |
+
+ "using a supported version of Python; see "
|
| 167 |
+
+ "https://devguide.python.org/versions/"
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
from google.cloud.speech_v1.helpers import SpeechHelpers
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
# This class merges the auto-generated GAPIC client with handwritten helper methods.
|
| 174 |
+
# We ignore [misc] because mypy is flagging that both parent classes have a method
|
| 175 |
+
# named `streaming_recognize`,
|
| 176 |
+
# but their type signatures don't match.
|
| 177 |
+
# We ignore [no-redef] because of the name shadow with SpeechClient. We don't want
|
| 178 |
+
# to expose the GAPIC client without the helpers.
|
| 179 |
+
class SpeechClient(SpeechHelpers, SpeechClient): # type: ignore[no-redef, misc]
|
| 180 |
+
__doc__ = SpeechClient.__doc__
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
__all__ = (
|
| 184 |
+
"AdaptationAsyncClient",
|
| 185 |
+
"SpeechAsyncClient",
|
| 186 |
+
"AdaptationClient",
|
| 187 |
+
"CreateCustomClassRequest",
|
| 188 |
+
"CreatePhraseSetRequest",
|
| 189 |
+
"CustomClass",
|
| 190 |
+
"DeleteCustomClassRequest",
|
| 191 |
+
"DeletePhraseSetRequest",
|
| 192 |
+
"GetCustomClassRequest",
|
| 193 |
+
"GetPhraseSetRequest",
|
| 194 |
+
"ListCustomClassesRequest",
|
| 195 |
+
"ListCustomClassesResponse",
|
| 196 |
+
"ListPhraseSetRequest",
|
| 197 |
+
"ListPhraseSetResponse",
|
| 198 |
+
"LongRunningRecognizeMetadata",
|
| 199 |
+
"LongRunningRecognizeRequest",
|
| 200 |
+
"LongRunningRecognizeResponse",
|
| 201 |
+
"PhraseSet",
|
| 202 |
+
"RecognitionAudio",
|
| 203 |
+
"RecognitionConfig",
|
| 204 |
+
"RecognitionMetadata",
|
| 205 |
+
"RecognizeRequest",
|
| 206 |
+
"RecognizeResponse",
|
| 207 |
+
"SpeakerDiarizationConfig",
|
| 208 |
+
"SpeechAdaptation",
|
| 209 |
+
"SpeechAdaptationInfo",
|
| 210 |
+
"SpeechClient",
|
| 211 |
+
"SpeechContext",
|
| 212 |
+
"SpeechRecognitionAlternative",
|
| 213 |
+
"SpeechRecognitionResult",
|
| 214 |
+
"StreamingRecognitionConfig",
|
| 215 |
+
"StreamingRecognitionResult",
|
| 216 |
+
"StreamingRecognizeRequest",
|
| 217 |
+
"StreamingRecognizeResponse",
|
| 218 |
+
"TranscriptNormalization",
|
| 219 |
+
"TranscriptOutputConfig",
|
| 220 |
+
"UpdateCustomClassRequest",
|
| 221 |
+
"UpdatePhraseSetRequest",
|
| 222 |
+
"WordInfo",
|
| 223 |
+
)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/gapic_metadata.json
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
{
|
| 2 |
+
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
|
| 3 |
+
"language": "python",
|
| 4 |
+
"libraryPackage": "google.cloud.speech_v1p1beta1",
|
| 5 |
+
"protoPackage": "google.cloud.speech.v1p1beta1",
|
| 6 |
+
"schema": "1.0",
|
| 7 |
+
"services": {
|
| 8 |
+
"Adaptation": {
|
| 9 |
+
"clients": {
|
| 10 |
+
"grpc": {
|
| 11 |
+
"libraryClient": "AdaptationClient",
|
| 12 |
+
"rpcs": {
|
| 13 |
+
"CreateCustomClass": {
|
| 14 |
+
"methods": [
|
| 15 |
+
"create_custom_class"
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
"CreatePhraseSet": {
|
| 19 |
+
"methods": [
|
| 20 |
+
"create_phrase_set"
|
| 21 |
+
]
|
| 22 |
+
},
|
| 23 |
+
"DeleteCustomClass": {
|
| 24 |
+
"methods": [
|
| 25 |
+
"delete_custom_class"
|
| 26 |
+
]
|
| 27 |
+
},
|
| 28 |
+
"DeletePhraseSet": {
|
| 29 |
+
"methods": [
|
| 30 |
+
"delete_phrase_set"
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
"GetCustomClass": {
|
| 34 |
+
"methods": [
|
| 35 |
+
"get_custom_class"
|
| 36 |
+
]
|
| 37 |
+
},
|
| 38 |
+
"GetPhraseSet": {
|
| 39 |
+
"methods": [
|
| 40 |
+
"get_phrase_set"
|
| 41 |
+
]
|
| 42 |
+
},
|
| 43 |
+
"ListCustomClasses": {
|
| 44 |
+
"methods": [
|
| 45 |
+
"list_custom_classes"
|
| 46 |
+
]
|
| 47 |
+
},
|
| 48 |
+
"ListPhraseSet": {
|
| 49 |
+
"methods": [
|
| 50 |
+
"list_phrase_set"
|
| 51 |
+
]
|
| 52 |
+
},
|
| 53 |
+
"UpdateCustomClass": {
|
| 54 |
+
"methods": [
|
| 55 |
+
"update_custom_class"
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"UpdatePhraseSet": {
|
| 59 |
+
"methods": [
|
| 60 |
+
"update_phrase_set"
|
| 61 |
+
]
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
"grpc-async": {
|
| 66 |
+
"libraryClient": "AdaptationAsyncClient",
|
| 67 |
+
"rpcs": {
|
| 68 |
+
"CreateCustomClass": {
|
| 69 |
+
"methods": [
|
| 70 |
+
"create_custom_class"
|
| 71 |
+
]
|
| 72 |
+
},
|
| 73 |
+
"CreatePhraseSet": {
|
| 74 |
+
"methods": [
|
| 75 |
+
"create_phrase_set"
|
| 76 |
+
]
|
| 77 |
+
},
|
| 78 |
+
"DeleteCustomClass": {
|
| 79 |
+
"methods": [
|
| 80 |
+
"delete_custom_class"
|
| 81 |
+
]
|
| 82 |
+
},
|
| 83 |
+
"DeletePhraseSet": {
|
| 84 |
+
"methods": [
|
| 85 |
+
"delete_phrase_set"
|
| 86 |
+
]
|
| 87 |
+
},
|
| 88 |
+
"GetCustomClass": {
|
| 89 |
+
"methods": [
|
| 90 |
+
"get_custom_class"
|
| 91 |
+
]
|
| 92 |
+
},
|
| 93 |
+
"GetPhraseSet": {
|
| 94 |
+
"methods": [
|
| 95 |
+
"get_phrase_set"
|
| 96 |
+
]
|
| 97 |
+
},
|
| 98 |
+
"ListCustomClasses": {
|
| 99 |
+
"methods": [
|
| 100 |
+
"list_custom_classes"
|
| 101 |
+
]
|
| 102 |
+
},
|
| 103 |
+
"ListPhraseSet": {
|
| 104 |
+
"methods": [
|
| 105 |
+
"list_phrase_set"
|
| 106 |
+
]
|
| 107 |
+
},
|
| 108 |
+
"UpdateCustomClass": {
|
| 109 |
+
"methods": [
|
| 110 |
+
"update_custom_class"
|
| 111 |
+
]
|
| 112 |
+
},
|
| 113 |
+
"UpdatePhraseSet": {
|
| 114 |
+
"methods": [
|
| 115 |
+
"update_phrase_set"
|
| 116 |
+
]
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
},
|
| 120 |
+
"rest": {
|
| 121 |
+
"libraryClient": "AdaptationClient",
|
| 122 |
+
"rpcs": {
|
| 123 |
+
"CreateCustomClass": {
|
| 124 |
+
"methods": [
|
| 125 |
+
"create_custom_class"
|
| 126 |
+
]
|
| 127 |
+
},
|
| 128 |
+
"CreatePhraseSet": {
|
| 129 |
+
"methods": [
|
| 130 |
+
"create_phrase_set"
|
| 131 |
+
]
|
| 132 |
+
},
|
| 133 |
+
"DeleteCustomClass": {
|
| 134 |
+
"methods": [
|
| 135 |
+
"delete_custom_class"
|
| 136 |
+
]
|
| 137 |
+
},
|
| 138 |
+
"DeletePhraseSet": {
|
| 139 |
+
"methods": [
|
| 140 |
+
"delete_phrase_set"
|
| 141 |
+
]
|
| 142 |
+
},
|
| 143 |
+
"GetCustomClass": {
|
| 144 |
+
"methods": [
|
| 145 |
+
"get_custom_class"
|
| 146 |
+
]
|
| 147 |
+
},
|
| 148 |
+
"GetPhraseSet": {
|
| 149 |
+
"methods": [
|
| 150 |
+
"get_phrase_set"
|
| 151 |
+
]
|
| 152 |
+
},
|
| 153 |
+
"ListCustomClasses": {
|
| 154 |
+
"methods": [
|
| 155 |
+
"list_custom_classes"
|
| 156 |
+
]
|
| 157 |
+
},
|
| 158 |
+
"ListPhraseSet": {
|
| 159 |
+
"methods": [
|
| 160 |
+
"list_phrase_set"
|
| 161 |
+
]
|
| 162 |
+
},
|
| 163 |
+
"UpdateCustomClass": {
|
| 164 |
+
"methods": [
|
| 165 |
+
"update_custom_class"
|
| 166 |
+
]
|
| 167 |
+
},
|
| 168 |
+
"UpdatePhraseSet": {
|
| 169 |
+
"methods": [
|
| 170 |
+
"update_phrase_set"
|
| 171 |
+
]
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
},
|
| 177 |
+
"Speech": {
|
| 178 |
+
"clients": {
|
| 179 |
+
"grpc": {
|
| 180 |
+
"libraryClient": "SpeechClient",
|
| 181 |
+
"rpcs": {
|
| 182 |
+
"LongRunningRecognize": {
|
| 183 |
+
"methods": [
|
| 184 |
+
"long_running_recognize"
|
| 185 |
+
]
|
| 186 |
+
},
|
| 187 |
+
"Recognize": {
|
| 188 |
+
"methods": [
|
| 189 |
+
"recognize"
|
| 190 |
+
]
|
| 191 |
+
},
|
| 192 |
+
"StreamingRecognize": {
|
| 193 |
+
"methods": [
|
| 194 |
+
"streaming_recognize"
|
| 195 |
+
]
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
},
|
| 199 |
+
"grpc-async": {
|
| 200 |
+
"libraryClient": "SpeechAsyncClient",
|
| 201 |
+
"rpcs": {
|
| 202 |
+
"LongRunningRecognize": {
|
| 203 |
+
"methods": [
|
| 204 |
+
"long_running_recognize"
|
| 205 |
+
]
|
| 206 |
+
},
|
| 207 |
+
"Recognize": {
|
| 208 |
+
"methods": [
|
| 209 |
+
"recognize"
|
| 210 |
+
]
|
| 211 |
+
},
|
| 212 |
+
"StreamingRecognize": {
|
| 213 |
+
"methods": [
|
| 214 |
+
"streaming_recognize"
|
| 215 |
+
]
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
},
|
| 219 |
+
"rest": {
|
| 220 |
+
"libraryClient": "SpeechClient",
|
| 221 |
+
"rpcs": {
|
| 222 |
+
"LongRunningRecognize": {
|
| 223 |
+
"methods": [
|
| 224 |
+
"long_running_recognize"
|
| 225 |
+
]
|
| 226 |
+
},
|
| 227 |
+
"Recognize": {
|
| 228 |
+
"methods": [
|
| 229 |
+
"recognize"
|
| 230 |
+
]
|
| 231 |
+
},
|
| 232 |
+
"StreamingRecognize": {
|
| 233 |
+
"methods": [
|
| 234 |
+
"streaming_recognize"
|
| 235 |
+
]
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
}
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/gapic_version.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
__version__ = "2.38.0" # {x-release-please-version}
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/py.typed
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Marker file for PEP 561.
|
| 2 |
+
# The google-cloud-speech package uses inline types.
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from .async_client import AdaptationAsyncClient
|
| 17 |
+
from .client import AdaptationClient
|
| 18 |
+
|
| 19 |
+
__all__ = (
|
| 20 |
+
"AdaptationClient",
|
| 21 |
+
"AdaptationAsyncClient",
|
| 22 |
+
)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/async_client.py
ADDED
|
@@ -0,0 +1,1749 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import logging as std_logging
|
| 17 |
+
import re
|
| 18 |
+
from collections import OrderedDict
|
| 19 |
+
from typing import (
|
| 20 |
+
Callable,
|
| 21 |
+
Dict,
|
| 22 |
+
Mapping,
|
| 23 |
+
MutableMapping,
|
| 24 |
+
MutableSequence,
|
| 25 |
+
Optional,
|
| 26 |
+
Sequence,
|
| 27 |
+
Tuple,
|
| 28 |
+
Type,
|
| 29 |
+
Union,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
import google.protobuf
|
| 33 |
+
from google.api_core import exceptions as core_exceptions
|
| 34 |
+
from google.api_core import gapic_v1
|
| 35 |
+
from google.api_core import retry_async as retries
|
| 36 |
+
from google.api_core.client_options import ClientOptions
|
| 37 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 38 |
+
from google.oauth2 import service_account # type: ignore
|
| 39 |
+
|
| 40 |
+
from google.cloud.speech_v1p1beta1 import gapic_version as package_version
|
| 41 |
+
|
| 42 |
+
try:
|
| 43 |
+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
|
| 44 |
+
except AttributeError: # pragma: NO COVER
|
| 45 |
+
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
| 46 |
+
|
| 47 |
+
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
|
| 48 |
+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
|
| 49 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 50 |
+
|
| 51 |
+
from google.cloud.speech_v1p1beta1.services.adaptation import pagers
|
| 52 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
|
| 53 |
+
|
| 54 |
+
from .client import AdaptationClient
|
| 55 |
+
from .transports.base import DEFAULT_CLIENT_INFO, AdaptationTransport
|
| 56 |
+
from .transports.grpc_asyncio import AdaptationGrpcAsyncIOTransport
|
| 57 |
+
|
| 58 |
+
try:
|
| 59 |
+
from google.api_core import client_logging # type: ignore
|
| 60 |
+
|
| 61 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 62 |
+
except ImportError: # pragma: NO COVER
|
| 63 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 64 |
+
|
| 65 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class AdaptationAsyncClient:
|
| 69 |
+
"""Service that implements Google Cloud Speech Adaptation API."""
|
| 70 |
+
|
| 71 |
+
_client: AdaptationClient
|
| 72 |
+
|
| 73 |
+
# Copy defaults from the synchronous client for use here.
|
| 74 |
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
| 75 |
+
DEFAULT_ENDPOINT = AdaptationClient.DEFAULT_ENDPOINT
|
| 76 |
+
DEFAULT_MTLS_ENDPOINT = AdaptationClient.DEFAULT_MTLS_ENDPOINT
|
| 77 |
+
_DEFAULT_ENDPOINT_TEMPLATE = AdaptationClient._DEFAULT_ENDPOINT_TEMPLATE
|
| 78 |
+
_DEFAULT_UNIVERSE = AdaptationClient._DEFAULT_UNIVERSE
|
| 79 |
+
|
| 80 |
+
crypto_key_path = staticmethod(AdaptationClient.crypto_key_path)
|
| 81 |
+
parse_crypto_key_path = staticmethod(AdaptationClient.parse_crypto_key_path)
|
| 82 |
+
crypto_key_version_path = staticmethod(AdaptationClient.crypto_key_version_path)
|
| 83 |
+
parse_crypto_key_version_path = staticmethod(
|
| 84 |
+
AdaptationClient.parse_crypto_key_version_path
|
| 85 |
+
)
|
| 86 |
+
custom_class_path = staticmethod(AdaptationClient.custom_class_path)
|
| 87 |
+
parse_custom_class_path = staticmethod(AdaptationClient.parse_custom_class_path)
|
| 88 |
+
phrase_set_path = staticmethod(AdaptationClient.phrase_set_path)
|
| 89 |
+
parse_phrase_set_path = staticmethod(AdaptationClient.parse_phrase_set_path)
|
| 90 |
+
common_billing_account_path = staticmethod(
|
| 91 |
+
AdaptationClient.common_billing_account_path
|
| 92 |
+
)
|
| 93 |
+
parse_common_billing_account_path = staticmethod(
|
| 94 |
+
AdaptationClient.parse_common_billing_account_path
|
| 95 |
+
)
|
| 96 |
+
common_folder_path = staticmethod(AdaptationClient.common_folder_path)
|
| 97 |
+
parse_common_folder_path = staticmethod(AdaptationClient.parse_common_folder_path)
|
| 98 |
+
common_organization_path = staticmethod(AdaptationClient.common_organization_path)
|
| 99 |
+
parse_common_organization_path = staticmethod(
|
| 100 |
+
AdaptationClient.parse_common_organization_path
|
| 101 |
+
)
|
| 102 |
+
common_project_path = staticmethod(AdaptationClient.common_project_path)
|
| 103 |
+
parse_common_project_path = staticmethod(AdaptationClient.parse_common_project_path)
|
| 104 |
+
common_location_path = staticmethod(AdaptationClient.common_location_path)
|
| 105 |
+
parse_common_location_path = staticmethod(
|
| 106 |
+
AdaptationClient.parse_common_location_path
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
@classmethod
|
| 110 |
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
| 111 |
+
"""Creates an instance of this client using the provided credentials
|
| 112 |
+
info.
|
| 113 |
+
|
| 114 |
+
Args:
|
| 115 |
+
info (dict): The service account private key info.
|
| 116 |
+
args: Additional arguments to pass to the constructor.
|
| 117 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 118 |
+
|
| 119 |
+
Returns:
|
| 120 |
+
AdaptationAsyncClient: The constructed client.
|
| 121 |
+
"""
|
| 122 |
+
sa_info_func = (
|
| 123 |
+
AdaptationClient.from_service_account_info.__func__ # type: ignore
|
| 124 |
+
)
|
| 125 |
+
return sa_info_func(AdaptationAsyncClient, info, *args, **kwargs)
|
| 126 |
+
|
| 127 |
+
@classmethod
|
| 128 |
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
| 129 |
+
"""Creates an instance of this client using the provided credentials
|
| 130 |
+
file.
|
| 131 |
+
|
| 132 |
+
Args:
|
| 133 |
+
filename (str): The path to the service account private key json
|
| 134 |
+
file.
|
| 135 |
+
args: Additional arguments to pass to the constructor.
|
| 136 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 137 |
+
|
| 138 |
+
Returns:
|
| 139 |
+
AdaptationAsyncClient: The constructed client.
|
| 140 |
+
"""
|
| 141 |
+
sa_file_func = (
|
| 142 |
+
AdaptationClient.from_service_account_file.__func__ # type: ignore
|
| 143 |
+
)
|
| 144 |
+
return sa_file_func(AdaptationAsyncClient, filename, *args, **kwargs)
|
| 145 |
+
|
| 146 |
+
from_service_account_json = from_service_account_file
|
| 147 |
+
|
| 148 |
+
@classmethod
|
| 149 |
+
def get_mtls_endpoint_and_cert_source(
|
| 150 |
+
cls, client_options: Optional[ClientOptions] = None
|
| 151 |
+
):
|
| 152 |
+
"""Return the API endpoint and client cert source for mutual TLS.
|
| 153 |
+
|
| 154 |
+
The client cert source is determined in the following order:
|
| 155 |
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
| 156 |
+
client cert source is None.
|
| 157 |
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
| 158 |
+
default client cert source exists, use the default one; otherwise the client cert
|
| 159 |
+
source is None.
|
| 160 |
+
|
| 161 |
+
The API endpoint is determined in the following order:
|
| 162 |
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
| 163 |
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
| 164 |
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
| 165 |
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
| 166 |
+
use the default API endpoint.
|
| 167 |
+
|
| 168 |
+
More details can be found at https://google.aip.dev/auth/4114.
|
| 169 |
+
|
| 170 |
+
Args:
|
| 171 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 172 |
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
| 173 |
+
in this method.
|
| 174 |
+
|
| 175 |
+
Returns:
|
| 176 |
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
| 177 |
+
client cert source to use.
|
| 178 |
+
|
| 179 |
+
Raises:
|
| 180 |
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
| 181 |
+
"""
|
| 182 |
+
return AdaptationClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
|
| 183 |
+
|
| 184 |
+
@property
|
| 185 |
+
def transport(self) -> AdaptationTransport:
|
| 186 |
+
"""Returns the transport used by the client instance.
|
| 187 |
+
|
| 188 |
+
Returns:
|
| 189 |
+
AdaptationTransport: The transport used by the client instance.
|
| 190 |
+
"""
|
| 191 |
+
return self._client.transport
|
| 192 |
+
|
| 193 |
+
@property
|
| 194 |
+
def api_endpoint(self) -> str:
|
| 195 |
+
"""Return the API endpoint used by the client instance.
|
| 196 |
+
|
| 197 |
+
Returns:
|
| 198 |
+
str: The API endpoint used by the client instance.
|
| 199 |
+
"""
|
| 200 |
+
return self._client._api_endpoint
|
| 201 |
+
|
| 202 |
+
@property
|
| 203 |
+
def universe_domain(self) -> str:
|
| 204 |
+
"""Return the universe domain used by the client instance.
|
| 205 |
+
|
| 206 |
+
Returns:
|
| 207 |
+
str: The universe domain used
|
| 208 |
+
by the client instance.
|
| 209 |
+
"""
|
| 210 |
+
return self._client._universe_domain
|
| 211 |
+
|
| 212 |
+
get_transport_class = AdaptationClient.get_transport_class
|
| 213 |
+
|
| 214 |
+
def __init__(
|
| 215 |
+
self,
|
| 216 |
+
*,
|
| 217 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 218 |
+
transport: Optional[
|
| 219 |
+
Union[str, AdaptationTransport, Callable[..., AdaptationTransport]]
|
| 220 |
+
] = "grpc_asyncio",
|
| 221 |
+
client_options: Optional[ClientOptions] = None,
|
| 222 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 223 |
+
) -> None:
|
| 224 |
+
"""Instantiates the adaptation async client.
|
| 225 |
+
|
| 226 |
+
Args:
|
| 227 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 228 |
+
authorization credentials to attach to requests. These
|
| 229 |
+
credentials identify the application to the service; if none
|
| 230 |
+
are specified, the client will attempt to ascertain the
|
| 231 |
+
credentials from the environment.
|
| 232 |
+
transport (Optional[Union[str,AdaptationTransport,Callable[..., AdaptationTransport]]]):
|
| 233 |
+
The transport to use, or a Callable that constructs and returns a new transport to use.
|
| 234 |
+
If a Callable is given, it will be called with the same set of initialization
|
| 235 |
+
arguments as used in the AdaptationTransport constructor.
|
| 236 |
+
If set to None, a transport is chosen automatically.
|
| 237 |
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
| 238 |
+
Custom options for the client.
|
| 239 |
+
|
| 240 |
+
1. The ``api_endpoint`` property can be used to override the
|
| 241 |
+
default endpoint provided by the client when ``transport`` is
|
| 242 |
+
not explicitly provided. Only if this property is not set and
|
| 243 |
+
``transport`` was not explicitly provided, the endpoint is
|
| 244 |
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
| 245 |
+
variable, which have one of the following values:
|
| 246 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 247 |
+
use the default regular endpoint) and "auto" (auto-switch to the
|
| 248 |
+
default mTLS endpoint if client certificate is present; this is
|
| 249 |
+
the default value).
|
| 250 |
+
|
| 251 |
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 252 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 253 |
+
to provide a client certificate for mTLS transport. If
|
| 254 |
+
not provided, the default SSL client certificate will be used if
|
| 255 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 256 |
+
set, no client certificate will be used.
|
| 257 |
+
|
| 258 |
+
3. The ``universe_domain`` property can be used to override the
|
| 259 |
+
default "googleapis.com" universe. Note that ``api_endpoint``
|
| 260 |
+
property still takes precedence; and ``universe_domain`` is
|
| 261 |
+
currently not supported for mTLS.
|
| 262 |
+
|
| 263 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 264 |
+
The client info used to send a user-agent string along with
|
| 265 |
+
API requests. If ``None``, then default info will be used.
|
| 266 |
+
Generally, you only need to set this if you're developing
|
| 267 |
+
your own client library.
|
| 268 |
+
|
| 269 |
+
Raises:
|
| 270 |
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
| 271 |
+
creation failed for any reason.
|
| 272 |
+
"""
|
| 273 |
+
self._client = AdaptationClient(
|
| 274 |
+
credentials=credentials,
|
| 275 |
+
transport=transport,
|
| 276 |
+
client_options=client_options,
|
| 277 |
+
client_info=client_info,
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 281 |
+
std_logging.DEBUG
|
| 282 |
+
): # pragma: NO COVER
|
| 283 |
+
_LOGGER.debug(
|
| 284 |
+
"Created client `google.cloud.speech_v1p1beta1.AdaptationAsyncClient`.",
|
| 285 |
+
extra={
|
| 286 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Adaptation",
|
| 287 |
+
"universeDomain": getattr(
|
| 288 |
+
self._client._transport._credentials, "universe_domain", ""
|
| 289 |
+
),
|
| 290 |
+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
|
| 291 |
+
"credentialsInfo": getattr(
|
| 292 |
+
self.transport._credentials, "get_cred_info", lambda: None
|
| 293 |
+
)(),
|
| 294 |
+
}
|
| 295 |
+
if hasattr(self._client._transport, "_credentials")
|
| 296 |
+
else {
|
| 297 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Adaptation",
|
| 298 |
+
"credentialsType": None,
|
| 299 |
+
},
|
| 300 |
+
)
|
| 301 |
+
|
| 302 |
+
async def create_phrase_set(
|
| 303 |
+
self,
|
| 304 |
+
request: Optional[
|
| 305 |
+
Union[cloud_speech_adaptation.CreatePhraseSetRequest, dict]
|
| 306 |
+
] = None,
|
| 307 |
+
*,
|
| 308 |
+
parent: Optional[str] = None,
|
| 309 |
+
phrase_set: Optional[resource.PhraseSet] = None,
|
| 310 |
+
phrase_set_id: Optional[str] = None,
|
| 311 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 312 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 313 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 314 |
+
) -> resource.PhraseSet:
|
| 315 |
+
r"""Create a set of phrase hints. Each item in the set
|
| 316 |
+
can be a single word or a multi-word phrase. The items
|
| 317 |
+
in the PhraseSet are favored by the recognition model
|
| 318 |
+
when you send a call that includes the PhraseSet.
|
| 319 |
+
|
| 320 |
+
.. code-block:: python
|
| 321 |
+
|
| 322 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 323 |
+
# code template only.
|
| 324 |
+
# It will require modifications to work:
|
| 325 |
+
# - It may require correct/in-range values for request initialization.
|
| 326 |
+
# - It may require specifying regional endpoints when creating the service
|
| 327 |
+
# client as shown in:
|
| 328 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 329 |
+
from google.cloud import speech_v1p1beta1
|
| 330 |
+
|
| 331 |
+
async def sample_create_phrase_set():
|
| 332 |
+
# Create a client
|
| 333 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 334 |
+
|
| 335 |
+
# Initialize request argument(s)
|
| 336 |
+
request = speech_v1p1beta1.CreatePhraseSetRequest(
|
| 337 |
+
parent="parent_value",
|
| 338 |
+
phrase_set_id="phrase_set_id_value",
|
| 339 |
+
)
|
| 340 |
+
|
| 341 |
+
# Make the request
|
| 342 |
+
response = await client.create_phrase_set(request=request)
|
| 343 |
+
|
| 344 |
+
# Handle the response
|
| 345 |
+
print(response)
|
| 346 |
+
|
| 347 |
+
Args:
|
| 348 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.CreatePhraseSetRequest, dict]]):
|
| 349 |
+
The request object. Message sent by the client for the ``CreatePhraseSet``
|
| 350 |
+
method.
|
| 351 |
+
parent (:class:`str`):
|
| 352 |
+
Required. The parent resource where this phrase set will
|
| 353 |
+
be created. Format:
|
| 354 |
+
|
| 355 |
+
``projects/{project}/locations/{location}``
|
| 356 |
+
|
| 357 |
+
Speech-to-Text supports three locations: ``global``,
|
| 358 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 359 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 360 |
+
the ``global`` location. To specify a region, use a
|
| 361 |
+
`regional
|
| 362 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 363 |
+
with matching ``us`` or ``eu`` location value.
|
| 364 |
+
|
| 365 |
+
This corresponds to the ``parent`` field
|
| 366 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 367 |
+
should not be set.
|
| 368 |
+
phrase_set (:class:`google.cloud.speech_v1p1beta1.types.PhraseSet`):
|
| 369 |
+
Required. The phrase set to create.
|
| 370 |
+
This corresponds to the ``phrase_set`` field
|
| 371 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 372 |
+
should not be set.
|
| 373 |
+
phrase_set_id (:class:`str`):
|
| 374 |
+
Required. The ID to use for the
|
| 375 |
+
phrase set, which will become the final
|
| 376 |
+
component of the phrase set's resource
|
| 377 |
+
name.
|
| 378 |
+
|
| 379 |
+
This value should restrict to letters,
|
| 380 |
+
numbers, and hyphens, with the first
|
| 381 |
+
character a letter, the last a letter or
|
| 382 |
+
a number, and be 4-63 characters.
|
| 383 |
+
|
| 384 |
+
This corresponds to the ``phrase_set_id`` field
|
| 385 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 386 |
+
should not be set.
|
| 387 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 388 |
+
should be retried.
|
| 389 |
+
timeout (float): The timeout for this request.
|
| 390 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 391 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 392 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 393 |
+
be of type `bytes`.
|
| 394 |
+
|
| 395 |
+
Returns:
|
| 396 |
+
google.cloud.speech_v1p1beta1.types.PhraseSet:
|
| 397 |
+
Provides "hints" to the speech
|
| 398 |
+
recognizer to favor specific words and
|
| 399 |
+
phrases in the results.
|
| 400 |
+
|
| 401 |
+
"""
|
| 402 |
+
# Create or coerce a protobuf request object.
|
| 403 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 404 |
+
# gotten any keyword arguments that map to the request.
|
| 405 |
+
flattened_params = [parent, phrase_set, phrase_set_id]
|
| 406 |
+
has_flattened_params = (
|
| 407 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 408 |
+
)
|
| 409 |
+
if request is not None and has_flattened_params:
|
| 410 |
+
raise ValueError(
|
| 411 |
+
"If the `request` argument is set, then none of "
|
| 412 |
+
"the individual field arguments should be set."
|
| 413 |
+
)
|
| 414 |
+
|
| 415 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 416 |
+
# there are no flattened fields), or create one.
|
| 417 |
+
if not isinstance(request, cloud_speech_adaptation.CreatePhraseSetRequest):
|
| 418 |
+
request = cloud_speech_adaptation.CreatePhraseSetRequest(request)
|
| 419 |
+
|
| 420 |
+
# If we have keyword arguments corresponding to fields on the
|
| 421 |
+
# request, apply these.
|
| 422 |
+
if parent is not None:
|
| 423 |
+
request.parent = parent
|
| 424 |
+
if phrase_set is not None:
|
| 425 |
+
request.phrase_set = phrase_set
|
| 426 |
+
if phrase_set_id is not None:
|
| 427 |
+
request.phrase_set_id = phrase_set_id
|
| 428 |
+
|
| 429 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 430 |
+
# and friendly error handling.
|
| 431 |
+
rpc = self._client._transport._wrapped_methods[
|
| 432 |
+
self._client._transport.create_phrase_set
|
| 433 |
+
]
|
| 434 |
+
|
| 435 |
+
# Certain fields should be provided within the metadata header;
|
| 436 |
+
# add these here.
|
| 437 |
+
metadata = tuple(metadata) + (
|
| 438 |
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
| 439 |
+
)
|
| 440 |
+
|
| 441 |
+
# Validate the universe domain.
|
| 442 |
+
self._client._validate_universe_domain()
|
| 443 |
+
|
| 444 |
+
# Send the request.
|
| 445 |
+
response = await rpc(
|
| 446 |
+
request,
|
| 447 |
+
retry=retry,
|
| 448 |
+
timeout=timeout,
|
| 449 |
+
metadata=metadata,
|
| 450 |
+
)
|
| 451 |
+
|
| 452 |
+
# Done; return the response.
|
| 453 |
+
return response
|
| 454 |
+
|
| 455 |
+
async def get_phrase_set(
|
| 456 |
+
self,
|
| 457 |
+
request: Optional[
|
| 458 |
+
Union[cloud_speech_adaptation.GetPhraseSetRequest, dict]
|
| 459 |
+
] = None,
|
| 460 |
+
*,
|
| 461 |
+
name: Optional[str] = None,
|
| 462 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 463 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 464 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 465 |
+
) -> resource.PhraseSet:
|
| 466 |
+
r"""Get a phrase set.
|
| 467 |
+
|
| 468 |
+
.. code-block:: python
|
| 469 |
+
|
| 470 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 471 |
+
# code template only.
|
| 472 |
+
# It will require modifications to work:
|
| 473 |
+
# - It may require correct/in-range values for request initialization.
|
| 474 |
+
# - It may require specifying regional endpoints when creating the service
|
| 475 |
+
# client as shown in:
|
| 476 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 477 |
+
from google.cloud import speech_v1p1beta1
|
| 478 |
+
|
| 479 |
+
async def sample_get_phrase_set():
|
| 480 |
+
# Create a client
|
| 481 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 482 |
+
|
| 483 |
+
# Initialize request argument(s)
|
| 484 |
+
request = speech_v1p1beta1.GetPhraseSetRequest(
|
| 485 |
+
name="name_value",
|
| 486 |
+
)
|
| 487 |
+
|
| 488 |
+
# Make the request
|
| 489 |
+
response = await client.get_phrase_set(request=request)
|
| 490 |
+
|
| 491 |
+
# Handle the response
|
| 492 |
+
print(response)
|
| 493 |
+
|
| 494 |
+
Args:
|
| 495 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.GetPhraseSetRequest, dict]]):
|
| 496 |
+
The request object. Message sent by the client for the ``GetPhraseSet``
|
| 497 |
+
method.
|
| 498 |
+
name (:class:`str`):
|
| 499 |
+
Required. The name of the phrase set to retrieve.
|
| 500 |
+
Format:
|
| 501 |
+
|
| 502 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 503 |
+
|
| 504 |
+
Speech-to-Text supports three locations: ``global``,
|
| 505 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 506 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 507 |
+
the ``global`` location. To specify a region, use a
|
| 508 |
+
`regional
|
| 509 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 510 |
+
with matching ``us`` or ``eu`` location value.
|
| 511 |
+
|
| 512 |
+
This corresponds to the ``name`` field
|
| 513 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 514 |
+
should not be set.
|
| 515 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 516 |
+
should be retried.
|
| 517 |
+
timeout (float): The timeout for this request.
|
| 518 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 519 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 520 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 521 |
+
be of type `bytes`.
|
| 522 |
+
|
| 523 |
+
Returns:
|
| 524 |
+
google.cloud.speech_v1p1beta1.types.PhraseSet:
|
| 525 |
+
Provides "hints" to the speech
|
| 526 |
+
recognizer to favor specific words and
|
| 527 |
+
phrases in the results.
|
| 528 |
+
|
| 529 |
+
"""
|
| 530 |
+
# Create or coerce a protobuf request object.
|
| 531 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 532 |
+
# gotten any keyword arguments that map to the request.
|
| 533 |
+
flattened_params = [name]
|
| 534 |
+
has_flattened_params = (
|
| 535 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 536 |
+
)
|
| 537 |
+
if request is not None and has_flattened_params:
|
| 538 |
+
raise ValueError(
|
| 539 |
+
"If the `request` argument is set, then none of "
|
| 540 |
+
"the individual field arguments should be set."
|
| 541 |
+
)
|
| 542 |
+
|
| 543 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 544 |
+
# there are no flattened fields), or create one.
|
| 545 |
+
if not isinstance(request, cloud_speech_adaptation.GetPhraseSetRequest):
|
| 546 |
+
request = cloud_speech_adaptation.GetPhraseSetRequest(request)
|
| 547 |
+
|
| 548 |
+
# If we have keyword arguments corresponding to fields on the
|
| 549 |
+
# request, apply these.
|
| 550 |
+
if name is not None:
|
| 551 |
+
request.name = name
|
| 552 |
+
|
| 553 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 554 |
+
# and friendly error handling.
|
| 555 |
+
rpc = self._client._transport._wrapped_methods[
|
| 556 |
+
self._client._transport.get_phrase_set
|
| 557 |
+
]
|
| 558 |
+
|
| 559 |
+
# Certain fields should be provided within the metadata header;
|
| 560 |
+
# add these here.
|
| 561 |
+
metadata = tuple(metadata) + (
|
| 562 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
# Validate the universe domain.
|
| 566 |
+
self._client._validate_universe_domain()
|
| 567 |
+
|
| 568 |
+
# Send the request.
|
| 569 |
+
response = await rpc(
|
| 570 |
+
request,
|
| 571 |
+
retry=retry,
|
| 572 |
+
timeout=timeout,
|
| 573 |
+
metadata=metadata,
|
| 574 |
+
)
|
| 575 |
+
|
| 576 |
+
# Done; return the response.
|
| 577 |
+
return response
|
| 578 |
+
|
| 579 |
+
async def list_phrase_set(
|
| 580 |
+
self,
|
| 581 |
+
request: Optional[
|
| 582 |
+
Union[cloud_speech_adaptation.ListPhraseSetRequest, dict]
|
| 583 |
+
] = None,
|
| 584 |
+
*,
|
| 585 |
+
parent: Optional[str] = None,
|
| 586 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 587 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 588 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 589 |
+
) -> pagers.ListPhraseSetAsyncPager:
|
| 590 |
+
r"""List phrase sets.
|
| 591 |
+
|
| 592 |
+
.. code-block:: python
|
| 593 |
+
|
| 594 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 595 |
+
# code template only.
|
| 596 |
+
# It will require modifications to work:
|
| 597 |
+
# - It may require correct/in-range values for request initialization.
|
| 598 |
+
# - It may require specifying regional endpoints when creating the service
|
| 599 |
+
# client as shown in:
|
| 600 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 601 |
+
from google.cloud import speech_v1p1beta1
|
| 602 |
+
|
| 603 |
+
async def sample_list_phrase_set():
|
| 604 |
+
# Create a client
|
| 605 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 606 |
+
|
| 607 |
+
# Initialize request argument(s)
|
| 608 |
+
request = speech_v1p1beta1.ListPhraseSetRequest(
|
| 609 |
+
parent="parent_value",
|
| 610 |
+
)
|
| 611 |
+
|
| 612 |
+
# Make the request
|
| 613 |
+
page_result = client.list_phrase_set(request=request)
|
| 614 |
+
|
| 615 |
+
# Handle the response
|
| 616 |
+
async for response in page_result:
|
| 617 |
+
print(response)
|
| 618 |
+
|
| 619 |
+
Args:
|
| 620 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.ListPhraseSetRequest, dict]]):
|
| 621 |
+
The request object. Message sent by the client for the ``ListPhraseSet``
|
| 622 |
+
method.
|
| 623 |
+
parent (:class:`str`):
|
| 624 |
+
Required. The parent, which owns this collection of
|
| 625 |
+
phrase set. Format:
|
| 626 |
+
|
| 627 |
+
``projects/{project}/locations/{location}``
|
| 628 |
+
|
| 629 |
+
Speech-to-Text supports three locations: ``global``,
|
| 630 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 631 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 632 |
+
the ``global`` location. To specify a region, use a
|
| 633 |
+
`regional
|
| 634 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 635 |
+
with matching ``us`` or ``eu`` location value.
|
| 636 |
+
|
| 637 |
+
This corresponds to the ``parent`` field
|
| 638 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 639 |
+
should not be set.
|
| 640 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 641 |
+
should be retried.
|
| 642 |
+
timeout (float): The timeout for this request.
|
| 643 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 644 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 645 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 646 |
+
be of type `bytes`.
|
| 647 |
+
|
| 648 |
+
Returns:
|
| 649 |
+
google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListPhraseSetAsyncPager:
|
| 650 |
+
Message returned to the client by the ListPhraseSet
|
| 651 |
+
method.
|
| 652 |
+
|
| 653 |
+
Iterating over this object will yield results and
|
| 654 |
+
resolve additional pages automatically.
|
| 655 |
+
|
| 656 |
+
"""
|
| 657 |
+
# Create or coerce a protobuf request object.
|
| 658 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 659 |
+
# gotten any keyword arguments that map to the request.
|
| 660 |
+
flattened_params = [parent]
|
| 661 |
+
has_flattened_params = (
|
| 662 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 663 |
+
)
|
| 664 |
+
if request is not None and has_flattened_params:
|
| 665 |
+
raise ValueError(
|
| 666 |
+
"If the `request` argument is set, then none of "
|
| 667 |
+
"the individual field arguments should be set."
|
| 668 |
+
)
|
| 669 |
+
|
| 670 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 671 |
+
# there are no flattened fields), or create one.
|
| 672 |
+
if not isinstance(request, cloud_speech_adaptation.ListPhraseSetRequest):
|
| 673 |
+
request = cloud_speech_adaptation.ListPhraseSetRequest(request)
|
| 674 |
+
|
| 675 |
+
# If we have keyword arguments corresponding to fields on the
|
| 676 |
+
# request, apply these.
|
| 677 |
+
if parent is not None:
|
| 678 |
+
request.parent = parent
|
| 679 |
+
|
| 680 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 681 |
+
# and friendly error handling.
|
| 682 |
+
rpc = self._client._transport._wrapped_methods[
|
| 683 |
+
self._client._transport.list_phrase_set
|
| 684 |
+
]
|
| 685 |
+
|
| 686 |
+
# Certain fields should be provided within the metadata header;
|
| 687 |
+
# add these here.
|
| 688 |
+
metadata = tuple(metadata) + (
|
| 689 |
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
| 690 |
+
)
|
| 691 |
+
|
| 692 |
+
# Validate the universe domain.
|
| 693 |
+
self._client._validate_universe_domain()
|
| 694 |
+
|
| 695 |
+
# Send the request.
|
| 696 |
+
response = await rpc(
|
| 697 |
+
request,
|
| 698 |
+
retry=retry,
|
| 699 |
+
timeout=timeout,
|
| 700 |
+
metadata=metadata,
|
| 701 |
+
)
|
| 702 |
+
|
| 703 |
+
# This method is paged; wrap the response in a pager, which provides
|
| 704 |
+
# an `__aiter__` convenience method.
|
| 705 |
+
response = pagers.ListPhraseSetAsyncPager(
|
| 706 |
+
method=rpc,
|
| 707 |
+
request=request,
|
| 708 |
+
response=response,
|
| 709 |
+
retry=retry,
|
| 710 |
+
timeout=timeout,
|
| 711 |
+
metadata=metadata,
|
| 712 |
+
)
|
| 713 |
+
|
| 714 |
+
# Done; return the response.
|
| 715 |
+
return response
|
| 716 |
+
|
| 717 |
+
async def update_phrase_set(
|
| 718 |
+
self,
|
| 719 |
+
request: Optional[
|
| 720 |
+
Union[cloud_speech_adaptation.UpdatePhraseSetRequest, dict]
|
| 721 |
+
] = None,
|
| 722 |
+
*,
|
| 723 |
+
phrase_set: Optional[resource.PhraseSet] = None,
|
| 724 |
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
| 725 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 726 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 727 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 728 |
+
) -> resource.PhraseSet:
|
| 729 |
+
r"""Update a phrase set.
|
| 730 |
+
|
| 731 |
+
.. code-block:: python
|
| 732 |
+
|
| 733 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 734 |
+
# code template only.
|
| 735 |
+
# It will require modifications to work:
|
| 736 |
+
# - It may require correct/in-range values for request initialization.
|
| 737 |
+
# - It may require specifying regional endpoints when creating the service
|
| 738 |
+
# client as shown in:
|
| 739 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 740 |
+
from google.cloud import speech_v1p1beta1
|
| 741 |
+
|
| 742 |
+
async def sample_update_phrase_set():
|
| 743 |
+
# Create a client
|
| 744 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 745 |
+
|
| 746 |
+
# Initialize request argument(s)
|
| 747 |
+
request = speech_v1p1beta1.UpdatePhraseSetRequest(
|
| 748 |
+
)
|
| 749 |
+
|
| 750 |
+
# Make the request
|
| 751 |
+
response = await client.update_phrase_set(request=request)
|
| 752 |
+
|
| 753 |
+
# Handle the response
|
| 754 |
+
print(response)
|
| 755 |
+
|
| 756 |
+
Args:
|
| 757 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.UpdatePhraseSetRequest, dict]]):
|
| 758 |
+
The request object. Message sent by the client for the ``UpdatePhraseSet``
|
| 759 |
+
method.
|
| 760 |
+
phrase_set (:class:`google.cloud.speech_v1p1beta1.types.PhraseSet`):
|
| 761 |
+
Required. The phrase set to update.
|
| 762 |
+
|
| 763 |
+
The phrase set's ``name`` field is used to identify the
|
| 764 |
+
set to be updated. Format:
|
| 765 |
+
|
| 766 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 767 |
+
|
| 768 |
+
Speech-to-Text supports three locations: ``global``,
|
| 769 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 770 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 771 |
+
the ``global`` location. To specify a region, use a
|
| 772 |
+
`regional
|
| 773 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 774 |
+
with matching ``us`` or ``eu`` location value.
|
| 775 |
+
|
| 776 |
+
This corresponds to the ``phrase_set`` field
|
| 777 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 778 |
+
should not be set.
|
| 779 |
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
| 780 |
+
The list of fields to be updated.
|
| 781 |
+
This corresponds to the ``update_mask`` field
|
| 782 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 783 |
+
should not be set.
|
| 784 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 785 |
+
should be retried.
|
| 786 |
+
timeout (float): The timeout for this request.
|
| 787 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 788 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 789 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 790 |
+
be of type `bytes`.
|
| 791 |
+
|
| 792 |
+
Returns:
|
| 793 |
+
google.cloud.speech_v1p1beta1.types.PhraseSet:
|
| 794 |
+
Provides "hints" to the speech
|
| 795 |
+
recognizer to favor specific words and
|
| 796 |
+
phrases in the results.
|
| 797 |
+
|
| 798 |
+
"""
|
| 799 |
+
# Create or coerce a protobuf request object.
|
| 800 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 801 |
+
# gotten any keyword arguments that map to the request.
|
| 802 |
+
flattened_params = [phrase_set, update_mask]
|
| 803 |
+
has_flattened_params = (
|
| 804 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 805 |
+
)
|
| 806 |
+
if request is not None and has_flattened_params:
|
| 807 |
+
raise ValueError(
|
| 808 |
+
"If the `request` argument is set, then none of "
|
| 809 |
+
"the individual field arguments should be set."
|
| 810 |
+
)
|
| 811 |
+
|
| 812 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 813 |
+
# there are no flattened fields), or create one.
|
| 814 |
+
if not isinstance(request, cloud_speech_adaptation.UpdatePhraseSetRequest):
|
| 815 |
+
request = cloud_speech_adaptation.UpdatePhraseSetRequest(request)
|
| 816 |
+
|
| 817 |
+
# If we have keyword arguments corresponding to fields on the
|
| 818 |
+
# request, apply these.
|
| 819 |
+
if phrase_set is not None:
|
| 820 |
+
request.phrase_set = phrase_set
|
| 821 |
+
if update_mask is not None:
|
| 822 |
+
request.update_mask = update_mask
|
| 823 |
+
|
| 824 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 825 |
+
# and friendly error handling.
|
| 826 |
+
rpc = self._client._transport._wrapped_methods[
|
| 827 |
+
self._client._transport.update_phrase_set
|
| 828 |
+
]
|
| 829 |
+
|
| 830 |
+
# Certain fields should be provided within the metadata header;
|
| 831 |
+
# add these here.
|
| 832 |
+
metadata = tuple(metadata) + (
|
| 833 |
+
gapic_v1.routing_header.to_grpc_metadata(
|
| 834 |
+
(("phrase_set.name", request.phrase_set.name),)
|
| 835 |
+
),
|
| 836 |
+
)
|
| 837 |
+
|
| 838 |
+
# Validate the universe domain.
|
| 839 |
+
self._client._validate_universe_domain()
|
| 840 |
+
|
| 841 |
+
# Send the request.
|
| 842 |
+
response = await rpc(
|
| 843 |
+
request,
|
| 844 |
+
retry=retry,
|
| 845 |
+
timeout=timeout,
|
| 846 |
+
metadata=metadata,
|
| 847 |
+
)
|
| 848 |
+
|
| 849 |
+
# Done; return the response.
|
| 850 |
+
return response
|
| 851 |
+
|
| 852 |
+
async def delete_phrase_set(
|
| 853 |
+
self,
|
| 854 |
+
request: Optional[
|
| 855 |
+
Union[cloud_speech_adaptation.DeletePhraseSetRequest, dict]
|
| 856 |
+
] = None,
|
| 857 |
+
*,
|
| 858 |
+
name: Optional[str] = None,
|
| 859 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 860 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 861 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 862 |
+
) -> None:
|
| 863 |
+
r"""Delete a phrase set.
|
| 864 |
+
|
| 865 |
+
.. code-block:: python
|
| 866 |
+
|
| 867 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 868 |
+
# code template only.
|
| 869 |
+
# It will require modifications to work:
|
| 870 |
+
# - It may require correct/in-range values for request initialization.
|
| 871 |
+
# - It may require specifying regional endpoints when creating the service
|
| 872 |
+
# client as shown in:
|
| 873 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 874 |
+
from google.cloud import speech_v1p1beta1
|
| 875 |
+
|
| 876 |
+
async def sample_delete_phrase_set():
|
| 877 |
+
# Create a client
|
| 878 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 879 |
+
|
| 880 |
+
# Initialize request argument(s)
|
| 881 |
+
request = speech_v1p1beta1.DeletePhraseSetRequest(
|
| 882 |
+
name="name_value",
|
| 883 |
+
)
|
| 884 |
+
|
| 885 |
+
# Make the request
|
| 886 |
+
await client.delete_phrase_set(request=request)
|
| 887 |
+
|
| 888 |
+
Args:
|
| 889 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.DeletePhraseSetRequest, dict]]):
|
| 890 |
+
The request object. Message sent by the client for the ``DeletePhraseSet``
|
| 891 |
+
method.
|
| 892 |
+
name (:class:`str`):
|
| 893 |
+
Required. The name of the phrase set to delete. Format:
|
| 894 |
+
|
| 895 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 896 |
+
|
| 897 |
+
This corresponds to the ``name`` field
|
| 898 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 899 |
+
should not be set.
|
| 900 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 901 |
+
should be retried.
|
| 902 |
+
timeout (float): The timeout for this request.
|
| 903 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 904 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 905 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 906 |
+
be of type `bytes`.
|
| 907 |
+
"""
|
| 908 |
+
# Create or coerce a protobuf request object.
|
| 909 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 910 |
+
# gotten any keyword arguments that map to the request.
|
| 911 |
+
flattened_params = [name]
|
| 912 |
+
has_flattened_params = (
|
| 913 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 914 |
+
)
|
| 915 |
+
if request is not None and has_flattened_params:
|
| 916 |
+
raise ValueError(
|
| 917 |
+
"If the `request` argument is set, then none of "
|
| 918 |
+
"the individual field arguments should be set."
|
| 919 |
+
)
|
| 920 |
+
|
| 921 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 922 |
+
# there are no flattened fields), or create one.
|
| 923 |
+
if not isinstance(request, cloud_speech_adaptation.DeletePhraseSetRequest):
|
| 924 |
+
request = cloud_speech_adaptation.DeletePhraseSetRequest(request)
|
| 925 |
+
|
| 926 |
+
# If we have keyword arguments corresponding to fields on the
|
| 927 |
+
# request, apply these.
|
| 928 |
+
if name is not None:
|
| 929 |
+
request.name = name
|
| 930 |
+
|
| 931 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 932 |
+
# and friendly error handling.
|
| 933 |
+
rpc = self._client._transport._wrapped_methods[
|
| 934 |
+
self._client._transport.delete_phrase_set
|
| 935 |
+
]
|
| 936 |
+
|
| 937 |
+
# Certain fields should be provided within the metadata header;
|
| 938 |
+
# add these here.
|
| 939 |
+
metadata = tuple(metadata) + (
|
| 940 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 941 |
+
)
|
| 942 |
+
|
| 943 |
+
# Validate the universe domain.
|
| 944 |
+
self._client._validate_universe_domain()
|
| 945 |
+
|
| 946 |
+
# Send the request.
|
| 947 |
+
await rpc(
|
| 948 |
+
request,
|
| 949 |
+
retry=retry,
|
| 950 |
+
timeout=timeout,
|
| 951 |
+
metadata=metadata,
|
| 952 |
+
)
|
| 953 |
+
|
| 954 |
+
async def create_custom_class(
|
| 955 |
+
self,
|
| 956 |
+
request: Optional[
|
| 957 |
+
Union[cloud_speech_adaptation.CreateCustomClassRequest, dict]
|
| 958 |
+
] = None,
|
| 959 |
+
*,
|
| 960 |
+
parent: Optional[str] = None,
|
| 961 |
+
custom_class: Optional[resource.CustomClass] = None,
|
| 962 |
+
custom_class_id: Optional[str] = None,
|
| 963 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 964 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 965 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 966 |
+
) -> resource.CustomClass:
|
| 967 |
+
r"""Create a custom class.
|
| 968 |
+
|
| 969 |
+
.. code-block:: python
|
| 970 |
+
|
| 971 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 972 |
+
# code template only.
|
| 973 |
+
# It will require modifications to work:
|
| 974 |
+
# - It may require correct/in-range values for request initialization.
|
| 975 |
+
# - It may require specifying regional endpoints when creating the service
|
| 976 |
+
# client as shown in:
|
| 977 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 978 |
+
from google.cloud import speech_v1p1beta1
|
| 979 |
+
|
| 980 |
+
async def sample_create_custom_class():
|
| 981 |
+
# Create a client
|
| 982 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 983 |
+
|
| 984 |
+
# Initialize request argument(s)
|
| 985 |
+
request = speech_v1p1beta1.CreateCustomClassRequest(
|
| 986 |
+
parent="parent_value",
|
| 987 |
+
custom_class_id="custom_class_id_value",
|
| 988 |
+
)
|
| 989 |
+
|
| 990 |
+
# Make the request
|
| 991 |
+
response = await client.create_custom_class(request=request)
|
| 992 |
+
|
| 993 |
+
# Handle the response
|
| 994 |
+
print(response)
|
| 995 |
+
|
| 996 |
+
Args:
|
| 997 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.CreateCustomClassRequest, dict]]):
|
| 998 |
+
The request object. Message sent by the client for the ``CreateCustomClass``
|
| 999 |
+
method.
|
| 1000 |
+
parent (:class:`str`):
|
| 1001 |
+
Required. The parent resource where this custom class
|
| 1002 |
+
will be created. Format:
|
| 1003 |
+
|
| 1004 |
+
``projects/{project}/locations/{location}/customClasses``
|
| 1005 |
+
|
| 1006 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1007 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1008 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1009 |
+
the ``global`` location. To specify a region, use a
|
| 1010 |
+
`regional
|
| 1011 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1012 |
+
with matching ``us`` or ``eu`` location value.
|
| 1013 |
+
|
| 1014 |
+
This corresponds to the ``parent`` field
|
| 1015 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1016 |
+
should not be set.
|
| 1017 |
+
custom_class (:class:`google.cloud.speech_v1p1beta1.types.CustomClass`):
|
| 1018 |
+
Required. The custom class to create.
|
| 1019 |
+
This corresponds to the ``custom_class`` field
|
| 1020 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1021 |
+
should not be set.
|
| 1022 |
+
custom_class_id (:class:`str`):
|
| 1023 |
+
Required. The ID to use for the
|
| 1024 |
+
custom class, which will become the
|
| 1025 |
+
final component of the custom class'
|
| 1026 |
+
resource name.
|
| 1027 |
+
|
| 1028 |
+
This value should restrict to letters,
|
| 1029 |
+
numbers, and hyphens, with the first
|
| 1030 |
+
character a letter, the last a letter or
|
| 1031 |
+
a number, and be 4-63 characters.
|
| 1032 |
+
|
| 1033 |
+
This corresponds to the ``custom_class_id`` field
|
| 1034 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1035 |
+
should not be set.
|
| 1036 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 1037 |
+
should be retried.
|
| 1038 |
+
timeout (float): The timeout for this request.
|
| 1039 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1040 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1041 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1042 |
+
be of type `bytes`.
|
| 1043 |
+
|
| 1044 |
+
Returns:
|
| 1045 |
+
google.cloud.speech_v1p1beta1.types.CustomClass:
|
| 1046 |
+
A set of words or phrases that
|
| 1047 |
+
represents a common concept likely to
|
| 1048 |
+
appear in your audio, for example a list
|
| 1049 |
+
of passenger ship names. CustomClass
|
| 1050 |
+
items can be substituted into
|
| 1051 |
+
placeholders that you set in PhraseSet
|
| 1052 |
+
phrases.
|
| 1053 |
+
|
| 1054 |
+
"""
|
| 1055 |
+
# Create or coerce a protobuf request object.
|
| 1056 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1057 |
+
# gotten any keyword arguments that map to the request.
|
| 1058 |
+
flattened_params = [parent, custom_class, custom_class_id]
|
| 1059 |
+
has_flattened_params = (
|
| 1060 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1061 |
+
)
|
| 1062 |
+
if request is not None and has_flattened_params:
|
| 1063 |
+
raise ValueError(
|
| 1064 |
+
"If the `request` argument is set, then none of "
|
| 1065 |
+
"the individual field arguments should be set."
|
| 1066 |
+
)
|
| 1067 |
+
|
| 1068 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1069 |
+
# there are no flattened fields), or create one.
|
| 1070 |
+
if not isinstance(request, cloud_speech_adaptation.CreateCustomClassRequest):
|
| 1071 |
+
request = cloud_speech_adaptation.CreateCustomClassRequest(request)
|
| 1072 |
+
|
| 1073 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1074 |
+
# request, apply these.
|
| 1075 |
+
if parent is not None:
|
| 1076 |
+
request.parent = parent
|
| 1077 |
+
if custom_class is not None:
|
| 1078 |
+
request.custom_class = custom_class
|
| 1079 |
+
if custom_class_id is not None:
|
| 1080 |
+
request.custom_class_id = custom_class_id
|
| 1081 |
+
|
| 1082 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1083 |
+
# and friendly error handling.
|
| 1084 |
+
rpc = self._client._transport._wrapped_methods[
|
| 1085 |
+
self._client._transport.create_custom_class
|
| 1086 |
+
]
|
| 1087 |
+
|
| 1088 |
+
# Certain fields should be provided within the metadata header;
|
| 1089 |
+
# add these here.
|
| 1090 |
+
metadata = tuple(metadata) + (
|
| 1091 |
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
| 1092 |
+
)
|
| 1093 |
+
|
| 1094 |
+
# Validate the universe domain.
|
| 1095 |
+
self._client._validate_universe_domain()
|
| 1096 |
+
|
| 1097 |
+
# Send the request.
|
| 1098 |
+
response = await rpc(
|
| 1099 |
+
request,
|
| 1100 |
+
retry=retry,
|
| 1101 |
+
timeout=timeout,
|
| 1102 |
+
metadata=metadata,
|
| 1103 |
+
)
|
| 1104 |
+
|
| 1105 |
+
# Done; return the response.
|
| 1106 |
+
return response
|
| 1107 |
+
|
| 1108 |
+
async def get_custom_class(
|
| 1109 |
+
self,
|
| 1110 |
+
request: Optional[
|
| 1111 |
+
Union[cloud_speech_adaptation.GetCustomClassRequest, dict]
|
| 1112 |
+
] = None,
|
| 1113 |
+
*,
|
| 1114 |
+
name: Optional[str] = None,
|
| 1115 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1116 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1117 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1118 |
+
) -> resource.CustomClass:
|
| 1119 |
+
r"""Get a custom class.
|
| 1120 |
+
|
| 1121 |
+
.. code-block:: python
|
| 1122 |
+
|
| 1123 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1124 |
+
# code template only.
|
| 1125 |
+
# It will require modifications to work:
|
| 1126 |
+
# - It may require correct/in-range values for request initialization.
|
| 1127 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1128 |
+
# client as shown in:
|
| 1129 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1130 |
+
from google.cloud import speech_v1p1beta1
|
| 1131 |
+
|
| 1132 |
+
async def sample_get_custom_class():
|
| 1133 |
+
# Create a client
|
| 1134 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 1135 |
+
|
| 1136 |
+
# Initialize request argument(s)
|
| 1137 |
+
request = speech_v1p1beta1.GetCustomClassRequest(
|
| 1138 |
+
name="name_value",
|
| 1139 |
+
)
|
| 1140 |
+
|
| 1141 |
+
# Make the request
|
| 1142 |
+
response = await client.get_custom_class(request=request)
|
| 1143 |
+
|
| 1144 |
+
# Handle the response
|
| 1145 |
+
print(response)
|
| 1146 |
+
|
| 1147 |
+
Args:
|
| 1148 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.GetCustomClassRequest, dict]]):
|
| 1149 |
+
The request object. Message sent by the client for the ``GetCustomClass``
|
| 1150 |
+
method.
|
| 1151 |
+
name (:class:`str`):
|
| 1152 |
+
Required. The name of the custom class to retrieve.
|
| 1153 |
+
Format:
|
| 1154 |
+
|
| 1155 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 1156 |
+
|
| 1157 |
+
This corresponds to the ``name`` field
|
| 1158 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1159 |
+
should not be set.
|
| 1160 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 1161 |
+
should be retried.
|
| 1162 |
+
timeout (float): The timeout for this request.
|
| 1163 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1164 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1165 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1166 |
+
be of type `bytes`.
|
| 1167 |
+
|
| 1168 |
+
Returns:
|
| 1169 |
+
google.cloud.speech_v1p1beta1.types.CustomClass:
|
| 1170 |
+
A set of words or phrases that
|
| 1171 |
+
represents a common concept likely to
|
| 1172 |
+
appear in your audio, for example a list
|
| 1173 |
+
of passenger ship names. CustomClass
|
| 1174 |
+
items can be substituted into
|
| 1175 |
+
placeholders that you set in PhraseSet
|
| 1176 |
+
phrases.
|
| 1177 |
+
|
| 1178 |
+
"""
|
| 1179 |
+
# Create or coerce a protobuf request object.
|
| 1180 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1181 |
+
# gotten any keyword arguments that map to the request.
|
| 1182 |
+
flattened_params = [name]
|
| 1183 |
+
has_flattened_params = (
|
| 1184 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1185 |
+
)
|
| 1186 |
+
if request is not None and has_flattened_params:
|
| 1187 |
+
raise ValueError(
|
| 1188 |
+
"If the `request` argument is set, then none of "
|
| 1189 |
+
"the individual field arguments should be set."
|
| 1190 |
+
)
|
| 1191 |
+
|
| 1192 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1193 |
+
# there are no flattened fields), or create one.
|
| 1194 |
+
if not isinstance(request, cloud_speech_adaptation.GetCustomClassRequest):
|
| 1195 |
+
request = cloud_speech_adaptation.GetCustomClassRequest(request)
|
| 1196 |
+
|
| 1197 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1198 |
+
# request, apply these.
|
| 1199 |
+
if name is not None:
|
| 1200 |
+
request.name = name
|
| 1201 |
+
|
| 1202 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1203 |
+
# and friendly error handling.
|
| 1204 |
+
rpc = self._client._transport._wrapped_methods[
|
| 1205 |
+
self._client._transport.get_custom_class
|
| 1206 |
+
]
|
| 1207 |
+
|
| 1208 |
+
# Certain fields should be provided within the metadata header;
|
| 1209 |
+
# add these here.
|
| 1210 |
+
metadata = tuple(metadata) + (
|
| 1211 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 1212 |
+
)
|
| 1213 |
+
|
| 1214 |
+
# Validate the universe domain.
|
| 1215 |
+
self._client._validate_universe_domain()
|
| 1216 |
+
|
| 1217 |
+
# Send the request.
|
| 1218 |
+
response = await rpc(
|
| 1219 |
+
request,
|
| 1220 |
+
retry=retry,
|
| 1221 |
+
timeout=timeout,
|
| 1222 |
+
metadata=metadata,
|
| 1223 |
+
)
|
| 1224 |
+
|
| 1225 |
+
# Done; return the response.
|
| 1226 |
+
return response
|
| 1227 |
+
|
| 1228 |
+
async def list_custom_classes(
|
| 1229 |
+
self,
|
| 1230 |
+
request: Optional[
|
| 1231 |
+
Union[cloud_speech_adaptation.ListCustomClassesRequest, dict]
|
| 1232 |
+
] = None,
|
| 1233 |
+
*,
|
| 1234 |
+
parent: Optional[str] = None,
|
| 1235 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1236 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1237 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1238 |
+
) -> pagers.ListCustomClassesAsyncPager:
|
| 1239 |
+
r"""List custom classes.
|
| 1240 |
+
|
| 1241 |
+
.. code-block:: python
|
| 1242 |
+
|
| 1243 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1244 |
+
# code template only.
|
| 1245 |
+
# It will require modifications to work:
|
| 1246 |
+
# - It may require correct/in-range values for request initialization.
|
| 1247 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1248 |
+
# client as shown in:
|
| 1249 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1250 |
+
from google.cloud import speech_v1p1beta1
|
| 1251 |
+
|
| 1252 |
+
async def sample_list_custom_classes():
|
| 1253 |
+
# Create a client
|
| 1254 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 1255 |
+
|
| 1256 |
+
# Initialize request argument(s)
|
| 1257 |
+
request = speech_v1p1beta1.ListCustomClassesRequest(
|
| 1258 |
+
parent="parent_value",
|
| 1259 |
+
)
|
| 1260 |
+
|
| 1261 |
+
# Make the request
|
| 1262 |
+
page_result = client.list_custom_classes(request=request)
|
| 1263 |
+
|
| 1264 |
+
# Handle the response
|
| 1265 |
+
async for response in page_result:
|
| 1266 |
+
print(response)
|
| 1267 |
+
|
| 1268 |
+
Args:
|
| 1269 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.ListCustomClassesRequest, dict]]):
|
| 1270 |
+
The request object. Message sent by the client for the ``ListCustomClasses``
|
| 1271 |
+
method.
|
| 1272 |
+
parent (:class:`str`):
|
| 1273 |
+
Required. The parent, which owns this collection of
|
| 1274 |
+
custom classes. Format:
|
| 1275 |
+
|
| 1276 |
+
``projects/{project}/locations/{location}/customClasses``
|
| 1277 |
+
|
| 1278 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1279 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1280 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1281 |
+
the ``global`` location. To specify a region, use a
|
| 1282 |
+
`regional
|
| 1283 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1284 |
+
with matching ``us`` or ``eu`` location value.
|
| 1285 |
+
|
| 1286 |
+
This corresponds to the ``parent`` field
|
| 1287 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1288 |
+
should not be set.
|
| 1289 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 1290 |
+
should be retried.
|
| 1291 |
+
timeout (float): The timeout for this request.
|
| 1292 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1293 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1294 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1295 |
+
be of type `bytes`.
|
| 1296 |
+
|
| 1297 |
+
Returns:
|
| 1298 |
+
google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListCustomClassesAsyncPager:
|
| 1299 |
+
Message returned to the client by the ListCustomClasses
|
| 1300 |
+
method.
|
| 1301 |
+
|
| 1302 |
+
Iterating over this object will yield results and
|
| 1303 |
+
resolve additional pages automatically.
|
| 1304 |
+
|
| 1305 |
+
"""
|
| 1306 |
+
# Create or coerce a protobuf request object.
|
| 1307 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1308 |
+
# gotten any keyword arguments that map to the request.
|
| 1309 |
+
flattened_params = [parent]
|
| 1310 |
+
has_flattened_params = (
|
| 1311 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1312 |
+
)
|
| 1313 |
+
if request is not None and has_flattened_params:
|
| 1314 |
+
raise ValueError(
|
| 1315 |
+
"If the `request` argument is set, then none of "
|
| 1316 |
+
"the individual field arguments should be set."
|
| 1317 |
+
)
|
| 1318 |
+
|
| 1319 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1320 |
+
# there are no flattened fields), or create one.
|
| 1321 |
+
if not isinstance(request, cloud_speech_adaptation.ListCustomClassesRequest):
|
| 1322 |
+
request = cloud_speech_adaptation.ListCustomClassesRequest(request)
|
| 1323 |
+
|
| 1324 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1325 |
+
# request, apply these.
|
| 1326 |
+
if parent is not None:
|
| 1327 |
+
request.parent = parent
|
| 1328 |
+
|
| 1329 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1330 |
+
# and friendly error handling.
|
| 1331 |
+
rpc = self._client._transport._wrapped_methods[
|
| 1332 |
+
self._client._transport.list_custom_classes
|
| 1333 |
+
]
|
| 1334 |
+
|
| 1335 |
+
# Certain fields should be provided within the metadata header;
|
| 1336 |
+
# add these here.
|
| 1337 |
+
metadata = tuple(metadata) + (
|
| 1338 |
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
| 1339 |
+
)
|
| 1340 |
+
|
| 1341 |
+
# Validate the universe domain.
|
| 1342 |
+
self._client._validate_universe_domain()
|
| 1343 |
+
|
| 1344 |
+
# Send the request.
|
| 1345 |
+
response = await rpc(
|
| 1346 |
+
request,
|
| 1347 |
+
retry=retry,
|
| 1348 |
+
timeout=timeout,
|
| 1349 |
+
metadata=metadata,
|
| 1350 |
+
)
|
| 1351 |
+
|
| 1352 |
+
# This method is paged; wrap the response in a pager, which provides
|
| 1353 |
+
# an `__aiter__` convenience method.
|
| 1354 |
+
response = pagers.ListCustomClassesAsyncPager(
|
| 1355 |
+
method=rpc,
|
| 1356 |
+
request=request,
|
| 1357 |
+
response=response,
|
| 1358 |
+
retry=retry,
|
| 1359 |
+
timeout=timeout,
|
| 1360 |
+
metadata=metadata,
|
| 1361 |
+
)
|
| 1362 |
+
|
| 1363 |
+
# Done; return the response.
|
| 1364 |
+
return response
|
| 1365 |
+
|
| 1366 |
+
async def update_custom_class(
|
| 1367 |
+
self,
|
| 1368 |
+
request: Optional[
|
| 1369 |
+
Union[cloud_speech_adaptation.UpdateCustomClassRequest, dict]
|
| 1370 |
+
] = None,
|
| 1371 |
+
*,
|
| 1372 |
+
custom_class: Optional[resource.CustomClass] = None,
|
| 1373 |
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
| 1374 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1375 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1376 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1377 |
+
) -> resource.CustomClass:
|
| 1378 |
+
r"""Update a custom class.
|
| 1379 |
+
|
| 1380 |
+
.. code-block:: python
|
| 1381 |
+
|
| 1382 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1383 |
+
# code template only.
|
| 1384 |
+
# It will require modifications to work:
|
| 1385 |
+
# - It may require correct/in-range values for request initialization.
|
| 1386 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1387 |
+
# client as shown in:
|
| 1388 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1389 |
+
from google.cloud import speech_v1p1beta1
|
| 1390 |
+
|
| 1391 |
+
async def sample_update_custom_class():
|
| 1392 |
+
# Create a client
|
| 1393 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 1394 |
+
|
| 1395 |
+
# Initialize request argument(s)
|
| 1396 |
+
request = speech_v1p1beta1.UpdateCustomClassRequest(
|
| 1397 |
+
)
|
| 1398 |
+
|
| 1399 |
+
# Make the request
|
| 1400 |
+
response = await client.update_custom_class(request=request)
|
| 1401 |
+
|
| 1402 |
+
# Handle the response
|
| 1403 |
+
print(response)
|
| 1404 |
+
|
| 1405 |
+
Args:
|
| 1406 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.UpdateCustomClassRequest, dict]]):
|
| 1407 |
+
The request object. Message sent by the client for the ``UpdateCustomClass``
|
| 1408 |
+
method.
|
| 1409 |
+
custom_class (:class:`google.cloud.speech_v1p1beta1.types.CustomClass`):
|
| 1410 |
+
Required. The custom class to update.
|
| 1411 |
+
|
| 1412 |
+
The custom class's ``name`` field is used to identify
|
| 1413 |
+
the custom class to be updated. Format:
|
| 1414 |
+
|
| 1415 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 1416 |
+
|
| 1417 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1418 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1419 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1420 |
+
the ``global`` location. To specify a region, use a
|
| 1421 |
+
`regional
|
| 1422 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1423 |
+
with matching ``us`` or ``eu`` location value.
|
| 1424 |
+
|
| 1425 |
+
This corresponds to the ``custom_class`` field
|
| 1426 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1427 |
+
should not be set.
|
| 1428 |
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
| 1429 |
+
The list of fields to be updated.
|
| 1430 |
+
This corresponds to the ``update_mask`` field
|
| 1431 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1432 |
+
should not be set.
|
| 1433 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 1434 |
+
should be retried.
|
| 1435 |
+
timeout (float): The timeout for this request.
|
| 1436 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1437 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1438 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1439 |
+
be of type `bytes`.
|
| 1440 |
+
|
| 1441 |
+
Returns:
|
| 1442 |
+
google.cloud.speech_v1p1beta1.types.CustomClass:
|
| 1443 |
+
A set of words or phrases that
|
| 1444 |
+
represents a common concept likely to
|
| 1445 |
+
appear in your audio, for example a list
|
| 1446 |
+
of passenger ship names. CustomClass
|
| 1447 |
+
items can be substituted into
|
| 1448 |
+
placeholders that you set in PhraseSet
|
| 1449 |
+
phrases.
|
| 1450 |
+
|
| 1451 |
+
"""
|
| 1452 |
+
# Create or coerce a protobuf request object.
|
| 1453 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1454 |
+
# gotten any keyword arguments that map to the request.
|
| 1455 |
+
flattened_params = [custom_class, update_mask]
|
| 1456 |
+
has_flattened_params = (
|
| 1457 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1458 |
+
)
|
| 1459 |
+
if request is not None and has_flattened_params:
|
| 1460 |
+
raise ValueError(
|
| 1461 |
+
"If the `request` argument is set, then none of "
|
| 1462 |
+
"the individual field arguments should be set."
|
| 1463 |
+
)
|
| 1464 |
+
|
| 1465 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1466 |
+
# there are no flattened fields), or create one.
|
| 1467 |
+
if not isinstance(request, cloud_speech_adaptation.UpdateCustomClassRequest):
|
| 1468 |
+
request = cloud_speech_adaptation.UpdateCustomClassRequest(request)
|
| 1469 |
+
|
| 1470 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1471 |
+
# request, apply these.
|
| 1472 |
+
if custom_class is not None:
|
| 1473 |
+
request.custom_class = custom_class
|
| 1474 |
+
if update_mask is not None:
|
| 1475 |
+
request.update_mask = update_mask
|
| 1476 |
+
|
| 1477 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1478 |
+
# and friendly error handling.
|
| 1479 |
+
rpc = self._client._transport._wrapped_methods[
|
| 1480 |
+
self._client._transport.update_custom_class
|
| 1481 |
+
]
|
| 1482 |
+
|
| 1483 |
+
# Certain fields should be provided within the metadata header;
|
| 1484 |
+
# add these here.
|
| 1485 |
+
metadata = tuple(metadata) + (
|
| 1486 |
+
gapic_v1.routing_header.to_grpc_metadata(
|
| 1487 |
+
(("custom_class.name", request.custom_class.name),)
|
| 1488 |
+
),
|
| 1489 |
+
)
|
| 1490 |
+
|
| 1491 |
+
# Validate the universe domain.
|
| 1492 |
+
self._client._validate_universe_domain()
|
| 1493 |
+
|
| 1494 |
+
# Send the request.
|
| 1495 |
+
response = await rpc(
|
| 1496 |
+
request,
|
| 1497 |
+
retry=retry,
|
| 1498 |
+
timeout=timeout,
|
| 1499 |
+
metadata=metadata,
|
| 1500 |
+
)
|
| 1501 |
+
|
| 1502 |
+
# Done; return the response.
|
| 1503 |
+
return response
|
| 1504 |
+
|
| 1505 |
+
async def delete_custom_class(
|
| 1506 |
+
self,
|
| 1507 |
+
request: Optional[
|
| 1508 |
+
Union[cloud_speech_adaptation.DeleteCustomClassRequest, dict]
|
| 1509 |
+
] = None,
|
| 1510 |
+
*,
|
| 1511 |
+
name: Optional[str] = None,
|
| 1512 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1513 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1514 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1515 |
+
) -> None:
|
| 1516 |
+
r"""Delete a custom class.
|
| 1517 |
+
|
| 1518 |
+
.. code-block:: python
|
| 1519 |
+
|
| 1520 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1521 |
+
# code template only.
|
| 1522 |
+
# It will require modifications to work:
|
| 1523 |
+
# - It may require correct/in-range values for request initialization.
|
| 1524 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1525 |
+
# client as shown in:
|
| 1526 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1527 |
+
from google.cloud import speech_v1p1beta1
|
| 1528 |
+
|
| 1529 |
+
async def sample_delete_custom_class():
|
| 1530 |
+
# Create a client
|
| 1531 |
+
client = speech_v1p1beta1.AdaptationAsyncClient()
|
| 1532 |
+
|
| 1533 |
+
# Initialize request argument(s)
|
| 1534 |
+
request = speech_v1p1beta1.DeleteCustomClassRequest(
|
| 1535 |
+
name="name_value",
|
| 1536 |
+
)
|
| 1537 |
+
|
| 1538 |
+
# Make the request
|
| 1539 |
+
await client.delete_custom_class(request=request)
|
| 1540 |
+
|
| 1541 |
+
Args:
|
| 1542 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.DeleteCustomClassRequest, dict]]):
|
| 1543 |
+
The request object. Message sent by the client for the ``DeleteCustomClass``
|
| 1544 |
+
method.
|
| 1545 |
+
name (:class:`str`):
|
| 1546 |
+
Required. The name of the custom class to delete.
|
| 1547 |
+
Format:
|
| 1548 |
+
|
| 1549 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 1550 |
+
|
| 1551 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1552 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1553 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1554 |
+
the ``global`` location. To specify a region, use a
|
| 1555 |
+
`regional
|
| 1556 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1557 |
+
with matching ``us`` or ``eu`` location value.
|
| 1558 |
+
|
| 1559 |
+
This corresponds to the ``name`` field
|
| 1560 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1561 |
+
should not be set.
|
| 1562 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 1563 |
+
should be retried.
|
| 1564 |
+
timeout (float): The timeout for this request.
|
| 1565 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1566 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1567 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1568 |
+
be of type `bytes`.
|
| 1569 |
+
"""
|
| 1570 |
+
# Create or coerce a protobuf request object.
|
| 1571 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1572 |
+
# gotten any keyword arguments that map to the request.
|
| 1573 |
+
flattened_params = [name]
|
| 1574 |
+
has_flattened_params = (
|
| 1575 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1576 |
+
)
|
| 1577 |
+
if request is not None and has_flattened_params:
|
| 1578 |
+
raise ValueError(
|
| 1579 |
+
"If the `request` argument is set, then none of "
|
| 1580 |
+
"the individual field arguments should be set."
|
| 1581 |
+
)
|
| 1582 |
+
|
| 1583 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1584 |
+
# there are no flattened fields), or create one.
|
| 1585 |
+
if not isinstance(request, cloud_speech_adaptation.DeleteCustomClassRequest):
|
| 1586 |
+
request = cloud_speech_adaptation.DeleteCustomClassRequest(request)
|
| 1587 |
+
|
| 1588 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1589 |
+
# request, apply these.
|
| 1590 |
+
if name is not None:
|
| 1591 |
+
request.name = name
|
| 1592 |
+
|
| 1593 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1594 |
+
# and friendly error handling.
|
| 1595 |
+
rpc = self._client._transport._wrapped_methods[
|
| 1596 |
+
self._client._transport.delete_custom_class
|
| 1597 |
+
]
|
| 1598 |
+
|
| 1599 |
+
# Certain fields should be provided within the metadata header;
|
| 1600 |
+
# add these here.
|
| 1601 |
+
metadata = tuple(metadata) + (
|
| 1602 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 1603 |
+
)
|
| 1604 |
+
|
| 1605 |
+
# Validate the universe domain.
|
| 1606 |
+
self._client._validate_universe_domain()
|
| 1607 |
+
|
| 1608 |
+
# Send the request.
|
| 1609 |
+
await rpc(
|
| 1610 |
+
request,
|
| 1611 |
+
retry=retry,
|
| 1612 |
+
timeout=timeout,
|
| 1613 |
+
metadata=metadata,
|
| 1614 |
+
)
|
| 1615 |
+
|
| 1616 |
+
async def list_operations(
|
| 1617 |
+
self,
|
| 1618 |
+
request: Optional[Union[operations_pb2.ListOperationsRequest, dict]] = None,
|
| 1619 |
+
*,
|
| 1620 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1621 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1622 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1623 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 1624 |
+
r"""Lists operations that match the specified filter in the request.
|
| 1625 |
+
|
| 1626 |
+
Args:
|
| 1627 |
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
| 1628 |
+
The request object. Request message for
|
| 1629 |
+
`ListOperations` method.
|
| 1630 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
| 1631 |
+
if any, should be retried.
|
| 1632 |
+
timeout (float): The timeout for this request.
|
| 1633 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1634 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1635 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1636 |
+
be of type `bytes`.
|
| 1637 |
+
Returns:
|
| 1638 |
+
~.operations_pb2.ListOperationsResponse:
|
| 1639 |
+
Response message for ``ListOperations`` method.
|
| 1640 |
+
"""
|
| 1641 |
+
# Create or coerce a protobuf request object.
|
| 1642 |
+
# The request isn't a proto-plus wrapped type,
|
| 1643 |
+
# so it must be constructed via keyword expansion.
|
| 1644 |
+
if request is None:
|
| 1645 |
+
request_pb = operations_pb2.ListOperationsRequest()
|
| 1646 |
+
elif isinstance(request, dict):
|
| 1647 |
+
request_pb = operations_pb2.ListOperationsRequest(**request)
|
| 1648 |
+
else:
|
| 1649 |
+
request_pb = request
|
| 1650 |
+
|
| 1651 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1652 |
+
# and friendly error handling.
|
| 1653 |
+
rpc = self.transport._wrapped_methods[self._client._transport.list_operations]
|
| 1654 |
+
|
| 1655 |
+
# Certain fields should be provided within the metadata header;
|
| 1656 |
+
# add these here.
|
| 1657 |
+
metadata = tuple(metadata) + (
|
| 1658 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 1659 |
+
)
|
| 1660 |
+
|
| 1661 |
+
# Validate the universe domain.
|
| 1662 |
+
self._client._validate_universe_domain()
|
| 1663 |
+
|
| 1664 |
+
# Send the request.
|
| 1665 |
+
response = await rpc(
|
| 1666 |
+
request_pb,
|
| 1667 |
+
retry=retry,
|
| 1668 |
+
timeout=timeout,
|
| 1669 |
+
metadata=metadata,
|
| 1670 |
+
)
|
| 1671 |
+
|
| 1672 |
+
# Done; return the response.
|
| 1673 |
+
return response
|
| 1674 |
+
|
| 1675 |
+
async def get_operation(
|
| 1676 |
+
self,
|
| 1677 |
+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
|
| 1678 |
+
*,
|
| 1679 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1680 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1681 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1682 |
+
) -> operations_pb2.Operation:
|
| 1683 |
+
r"""Gets the latest state of a long-running operation.
|
| 1684 |
+
|
| 1685 |
+
Args:
|
| 1686 |
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
| 1687 |
+
The request object. Request message for
|
| 1688 |
+
`GetOperation` method.
|
| 1689 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
| 1690 |
+
if any, should be retried.
|
| 1691 |
+
timeout (float): The timeout for this request.
|
| 1692 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1693 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1694 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1695 |
+
be of type `bytes`.
|
| 1696 |
+
Returns:
|
| 1697 |
+
~.operations_pb2.Operation:
|
| 1698 |
+
An ``Operation`` object.
|
| 1699 |
+
"""
|
| 1700 |
+
# Create or coerce a protobuf request object.
|
| 1701 |
+
# The request isn't a proto-plus wrapped type,
|
| 1702 |
+
# so it must be constructed via keyword expansion.
|
| 1703 |
+
if request is None:
|
| 1704 |
+
request_pb = operations_pb2.GetOperationRequest()
|
| 1705 |
+
elif isinstance(request, dict):
|
| 1706 |
+
request_pb = operations_pb2.GetOperationRequest(**request)
|
| 1707 |
+
else:
|
| 1708 |
+
request_pb = request
|
| 1709 |
+
|
| 1710 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1711 |
+
# and friendly error handling.
|
| 1712 |
+
rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
|
| 1713 |
+
|
| 1714 |
+
# Certain fields should be provided within the metadata header;
|
| 1715 |
+
# add these here.
|
| 1716 |
+
metadata = tuple(metadata) + (
|
| 1717 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 1718 |
+
)
|
| 1719 |
+
|
| 1720 |
+
# Validate the universe domain.
|
| 1721 |
+
self._client._validate_universe_domain()
|
| 1722 |
+
|
| 1723 |
+
# Send the request.
|
| 1724 |
+
response = await rpc(
|
| 1725 |
+
request_pb,
|
| 1726 |
+
retry=retry,
|
| 1727 |
+
timeout=timeout,
|
| 1728 |
+
metadata=metadata,
|
| 1729 |
+
)
|
| 1730 |
+
|
| 1731 |
+
# Done; return the response.
|
| 1732 |
+
return response
|
| 1733 |
+
|
| 1734 |
+
async def __aenter__(self) -> "AdaptationAsyncClient":
|
| 1735 |
+
return self
|
| 1736 |
+
|
| 1737 |
+
async def __aexit__(self, exc_type, exc, tb):
|
| 1738 |
+
await self.transport.close()
|
| 1739 |
+
|
| 1740 |
+
|
| 1741 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 1742 |
+
gapic_version=package_version.__version__
|
| 1743 |
+
)
|
| 1744 |
+
|
| 1745 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 1746 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 1747 |
+
|
| 1748 |
+
|
| 1749 |
+
__all__ = ("AdaptationAsyncClient",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/client.py
ADDED
|
@@ -0,0 +1,2234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json
|
| 17 |
+
import logging as std_logging
|
| 18 |
+
import os
|
| 19 |
+
import re
|
| 20 |
+
import warnings
|
| 21 |
+
from collections import OrderedDict
|
| 22 |
+
from http import HTTPStatus
|
| 23 |
+
from typing import (
|
| 24 |
+
Callable,
|
| 25 |
+
Dict,
|
| 26 |
+
Mapping,
|
| 27 |
+
MutableMapping,
|
| 28 |
+
MutableSequence,
|
| 29 |
+
Optional,
|
| 30 |
+
Sequence,
|
| 31 |
+
Tuple,
|
| 32 |
+
Type,
|
| 33 |
+
Union,
|
| 34 |
+
cast,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
import google.protobuf
|
| 38 |
+
from google.api_core import client_options as client_options_lib
|
| 39 |
+
from google.api_core import exceptions as core_exceptions
|
| 40 |
+
from google.api_core import gapic_v1
|
| 41 |
+
from google.api_core import retry as retries
|
| 42 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 43 |
+
from google.auth.exceptions import MutualTLSChannelError # type: ignore
|
| 44 |
+
from google.auth.transport import mtls # type: ignore
|
| 45 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 46 |
+
from google.oauth2 import service_account # type: ignore
|
| 47 |
+
|
| 48 |
+
from google.cloud.speech_v1p1beta1 import gapic_version as package_version
|
| 49 |
+
|
| 50 |
+
try:
|
| 51 |
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
| 52 |
+
except AttributeError: # pragma: NO COVER
|
| 53 |
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
| 54 |
+
|
| 55 |
+
try:
|
| 56 |
+
from google.api_core import client_logging # type: ignore
|
| 57 |
+
|
| 58 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 59 |
+
except ImportError: # pragma: NO COVER
|
| 60 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 61 |
+
|
| 62 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 63 |
+
|
| 64 |
+
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
|
| 65 |
+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
|
| 66 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 67 |
+
|
| 68 |
+
from google.cloud.speech_v1p1beta1.services.adaptation import pagers
|
| 69 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
|
| 70 |
+
|
| 71 |
+
from .transports.base import DEFAULT_CLIENT_INFO, AdaptationTransport
|
| 72 |
+
from .transports.grpc import AdaptationGrpcTransport
|
| 73 |
+
from .transports.grpc_asyncio import AdaptationGrpcAsyncIOTransport
|
| 74 |
+
from .transports.rest import AdaptationRestTransport
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class AdaptationClientMeta(type):
|
| 78 |
+
"""Metaclass for the Adaptation client.
|
| 79 |
+
|
| 80 |
+
This provides class-level methods for building and retrieving
|
| 81 |
+
support objects (e.g. transport) without polluting the client instance
|
| 82 |
+
objects.
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
_transport_registry = OrderedDict() # type: Dict[str, Type[AdaptationTransport]]
|
| 86 |
+
_transport_registry["grpc"] = AdaptationGrpcTransport
|
| 87 |
+
_transport_registry["grpc_asyncio"] = AdaptationGrpcAsyncIOTransport
|
| 88 |
+
_transport_registry["rest"] = AdaptationRestTransport
|
| 89 |
+
|
| 90 |
+
def get_transport_class(
|
| 91 |
+
cls,
|
| 92 |
+
label: Optional[str] = None,
|
| 93 |
+
) -> Type[AdaptationTransport]:
|
| 94 |
+
"""Returns an appropriate transport class.
|
| 95 |
+
|
| 96 |
+
Args:
|
| 97 |
+
label: The name of the desired transport. If none is
|
| 98 |
+
provided, then the first transport in the registry is used.
|
| 99 |
+
|
| 100 |
+
Returns:
|
| 101 |
+
The transport class to use.
|
| 102 |
+
"""
|
| 103 |
+
# If a specific transport is requested, return that one.
|
| 104 |
+
if label:
|
| 105 |
+
return cls._transport_registry[label]
|
| 106 |
+
|
| 107 |
+
# No transport is requested; return the default (that is, the first one
|
| 108 |
+
# in the dictionary).
|
| 109 |
+
return next(iter(cls._transport_registry.values()))
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class AdaptationClient(metaclass=AdaptationClientMeta):
|
| 113 |
+
"""Service that implements Google Cloud Speech Adaptation API."""
|
| 114 |
+
|
| 115 |
+
@staticmethod
|
| 116 |
+
def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
|
| 117 |
+
"""Converts api endpoint to mTLS endpoint.
|
| 118 |
+
|
| 119 |
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
| 120 |
+
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
| 121 |
+
Args:
|
| 122 |
+
api_endpoint (Optional[str]): the api endpoint to convert.
|
| 123 |
+
Returns:
|
| 124 |
+
Optional[str]: converted mTLS api endpoint.
|
| 125 |
+
"""
|
| 126 |
+
if not api_endpoint:
|
| 127 |
+
return api_endpoint
|
| 128 |
+
|
| 129 |
+
mtls_endpoint_re = re.compile(
|
| 130 |
+
r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
m = mtls_endpoint_re.match(api_endpoint)
|
| 134 |
+
if m is None:
|
| 135 |
+
# Could not parse api_endpoint; return as-is.
|
| 136 |
+
return api_endpoint
|
| 137 |
+
|
| 138 |
+
name, mtls, sandbox, googledomain = m.groups()
|
| 139 |
+
if mtls or not googledomain:
|
| 140 |
+
return api_endpoint
|
| 141 |
+
|
| 142 |
+
if sandbox:
|
| 143 |
+
return api_endpoint.replace(
|
| 144 |
+
"sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
|
| 148 |
+
|
| 149 |
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
| 150 |
+
DEFAULT_ENDPOINT = "speech.googleapis.com"
|
| 151 |
+
DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
|
| 152 |
+
DEFAULT_ENDPOINT
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
_DEFAULT_ENDPOINT_TEMPLATE = "speech.{UNIVERSE_DOMAIN}"
|
| 156 |
+
_DEFAULT_UNIVERSE = "googleapis.com"
|
| 157 |
+
|
| 158 |
+
@staticmethod
|
| 159 |
+
def _use_client_cert_effective():
|
| 160 |
+
"""Returns whether client certificate should be used for mTLS if the
|
| 161 |
+
google-auth version supports should_use_client_cert automatic mTLS enablement.
|
| 162 |
+
|
| 163 |
+
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
|
| 164 |
+
|
| 165 |
+
Returns:
|
| 166 |
+
bool: whether client certificate should be used for mTLS
|
| 167 |
+
Raises:
|
| 168 |
+
ValueError: (If using a version of google-auth without should_use_client_cert and
|
| 169 |
+
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
|
| 170 |
+
"""
|
| 171 |
+
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
|
| 172 |
+
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
|
| 173 |
+
return mtls.should_use_client_cert()
|
| 174 |
+
else: # pragma: NO COVER
|
| 175 |
+
# if unsupported, fallback to reading from env var
|
| 176 |
+
use_client_cert_str = os.getenv(
|
| 177 |
+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
| 178 |
+
).lower()
|
| 179 |
+
if use_client_cert_str not in ("true", "false"):
|
| 180 |
+
raise ValueError(
|
| 181 |
+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
|
| 182 |
+
" either `true` or `false`"
|
| 183 |
+
)
|
| 184 |
+
return use_client_cert_str == "true"
|
| 185 |
+
|
| 186 |
+
@classmethod
|
| 187 |
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
| 188 |
+
"""Creates an instance of this client using the provided credentials
|
| 189 |
+
info.
|
| 190 |
+
|
| 191 |
+
Args:
|
| 192 |
+
info (dict): The service account private key info.
|
| 193 |
+
args: Additional arguments to pass to the constructor.
|
| 194 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 195 |
+
|
| 196 |
+
Returns:
|
| 197 |
+
AdaptationClient: The constructed client.
|
| 198 |
+
"""
|
| 199 |
+
credentials = service_account.Credentials.from_service_account_info(info)
|
| 200 |
+
kwargs["credentials"] = credentials
|
| 201 |
+
return cls(*args, **kwargs)
|
| 202 |
+
|
| 203 |
+
@classmethod
|
| 204 |
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
| 205 |
+
"""Creates an instance of this client using the provided credentials
|
| 206 |
+
file.
|
| 207 |
+
|
| 208 |
+
Args:
|
| 209 |
+
filename (str): The path to the service account private key json
|
| 210 |
+
file.
|
| 211 |
+
args: Additional arguments to pass to the constructor.
|
| 212 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 213 |
+
|
| 214 |
+
Returns:
|
| 215 |
+
AdaptationClient: The constructed client.
|
| 216 |
+
"""
|
| 217 |
+
credentials = service_account.Credentials.from_service_account_file(filename)
|
| 218 |
+
kwargs["credentials"] = credentials
|
| 219 |
+
return cls(*args, **kwargs)
|
| 220 |
+
|
| 221 |
+
from_service_account_json = from_service_account_file
|
| 222 |
+
|
| 223 |
+
@property
|
| 224 |
+
def transport(self) -> AdaptationTransport:
|
| 225 |
+
"""Returns the transport used by the client instance.
|
| 226 |
+
|
| 227 |
+
Returns:
|
| 228 |
+
AdaptationTransport: The transport used by the client
|
| 229 |
+
instance.
|
| 230 |
+
"""
|
| 231 |
+
return self._transport
|
| 232 |
+
|
| 233 |
+
@staticmethod
|
| 234 |
+
def crypto_key_path(
|
| 235 |
+
project: str,
|
| 236 |
+
location: str,
|
| 237 |
+
key_ring: str,
|
| 238 |
+
crypto_key: str,
|
| 239 |
+
) -> str:
|
| 240 |
+
"""Returns a fully-qualified crypto_key string."""
|
| 241 |
+
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format(
|
| 242 |
+
project=project,
|
| 243 |
+
location=location,
|
| 244 |
+
key_ring=key_ring,
|
| 245 |
+
crypto_key=crypto_key,
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
@staticmethod
|
| 249 |
+
def parse_crypto_key_path(path: str) -> Dict[str, str]:
|
| 250 |
+
"""Parses a crypto_key path into its component segments."""
|
| 251 |
+
m = re.match(
|
| 252 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)$",
|
| 253 |
+
path,
|
| 254 |
+
)
|
| 255 |
+
return m.groupdict() if m else {}
|
| 256 |
+
|
| 257 |
+
@staticmethod
|
| 258 |
+
def crypto_key_version_path(
|
| 259 |
+
project: str,
|
| 260 |
+
location: str,
|
| 261 |
+
key_ring: str,
|
| 262 |
+
crypto_key: str,
|
| 263 |
+
crypto_key_version: str,
|
| 264 |
+
) -> str:
|
| 265 |
+
"""Returns a fully-qualified crypto_key_version string."""
|
| 266 |
+
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format(
|
| 267 |
+
project=project,
|
| 268 |
+
location=location,
|
| 269 |
+
key_ring=key_ring,
|
| 270 |
+
crypto_key=crypto_key,
|
| 271 |
+
crypto_key_version=crypto_key_version,
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
@staticmethod
|
| 275 |
+
def parse_crypto_key_version_path(path: str) -> Dict[str, str]:
|
| 276 |
+
"""Parses a crypto_key_version path into its component segments."""
|
| 277 |
+
m = re.match(
|
| 278 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)/cryptoKeyVersions/(?P<crypto_key_version>.+?)$",
|
| 279 |
+
path,
|
| 280 |
+
)
|
| 281 |
+
return m.groupdict() if m else {}
|
| 282 |
+
|
| 283 |
+
@staticmethod
|
| 284 |
+
def custom_class_path(
|
| 285 |
+
project: str,
|
| 286 |
+
location: str,
|
| 287 |
+
custom_class: str,
|
| 288 |
+
) -> str:
|
| 289 |
+
"""Returns a fully-qualified custom_class string."""
|
| 290 |
+
return "projects/{project}/locations/{location}/customClasses/{custom_class}".format(
|
| 291 |
+
project=project,
|
| 292 |
+
location=location,
|
| 293 |
+
custom_class=custom_class,
|
| 294 |
+
)
|
| 295 |
+
|
| 296 |
+
@staticmethod
|
| 297 |
+
def parse_custom_class_path(path: str) -> Dict[str, str]:
|
| 298 |
+
"""Parses a custom_class path into its component segments."""
|
| 299 |
+
m = re.match(
|
| 300 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/customClasses/(?P<custom_class>.+?)$",
|
| 301 |
+
path,
|
| 302 |
+
)
|
| 303 |
+
return m.groupdict() if m else {}
|
| 304 |
+
|
| 305 |
+
@staticmethod
|
| 306 |
+
def phrase_set_path(
|
| 307 |
+
project: str,
|
| 308 |
+
location: str,
|
| 309 |
+
phrase_set: str,
|
| 310 |
+
) -> str:
|
| 311 |
+
"""Returns a fully-qualified phrase_set string."""
|
| 312 |
+
return "projects/{project}/locations/{location}/phraseSets/{phrase_set}".format(
|
| 313 |
+
project=project,
|
| 314 |
+
location=location,
|
| 315 |
+
phrase_set=phrase_set,
|
| 316 |
+
)
|
| 317 |
+
|
| 318 |
+
@staticmethod
|
| 319 |
+
def parse_phrase_set_path(path: str) -> Dict[str, str]:
|
| 320 |
+
"""Parses a phrase_set path into its component segments."""
|
| 321 |
+
m = re.match(
|
| 322 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/phraseSets/(?P<phrase_set>.+?)$",
|
| 323 |
+
path,
|
| 324 |
+
)
|
| 325 |
+
return m.groupdict() if m else {}
|
| 326 |
+
|
| 327 |
+
@staticmethod
|
| 328 |
+
def common_billing_account_path(
|
| 329 |
+
billing_account: str,
|
| 330 |
+
) -> str:
|
| 331 |
+
"""Returns a fully-qualified billing_account string."""
|
| 332 |
+
return "billingAccounts/{billing_account}".format(
|
| 333 |
+
billing_account=billing_account,
|
| 334 |
+
)
|
| 335 |
+
|
| 336 |
+
@staticmethod
|
| 337 |
+
def parse_common_billing_account_path(path: str) -> Dict[str, str]:
|
| 338 |
+
"""Parse a billing_account path into its component segments."""
|
| 339 |
+
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
|
| 340 |
+
return m.groupdict() if m else {}
|
| 341 |
+
|
| 342 |
+
@staticmethod
|
| 343 |
+
def common_folder_path(
|
| 344 |
+
folder: str,
|
| 345 |
+
) -> str:
|
| 346 |
+
"""Returns a fully-qualified folder string."""
|
| 347 |
+
return "folders/{folder}".format(
|
| 348 |
+
folder=folder,
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
+
@staticmethod
|
| 352 |
+
def parse_common_folder_path(path: str) -> Dict[str, str]:
|
| 353 |
+
"""Parse a folder path into its component segments."""
|
| 354 |
+
m = re.match(r"^folders/(?P<folder>.+?)$", path)
|
| 355 |
+
return m.groupdict() if m else {}
|
| 356 |
+
|
| 357 |
+
@staticmethod
|
| 358 |
+
def common_organization_path(
|
| 359 |
+
organization: str,
|
| 360 |
+
) -> str:
|
| 361 |
+
"""Returns a fully-qualified organization string."""
|
| 362 |
+
return "organizations/{organization}".format(
|
| 363 |
+
organization=organization,
|
| 364 |
+
)
|
| 365 |
+
|
| 366 |
+
@staticmethod
|
| 367 |
+
def parse_common_organization_path(path: str) -> Dict[str, str]:
|
| 368 |
+
"""Parse a organization path into its component segments."""
|
| 369 |
+
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
|
| 370 |
+
return m.groupdict() if m else {}
|
| 371 |
+
|
| 372 |
+
@staticmethod
|
| 373 |
+
def common_project_path(
|
| 374 |
+
project: str,
|
| 375 |
+
) -> str:
|
| 376 |
+
"""Returns a fully-qualified project string."""
|
| 377 |
+
return "projects/{project}".format(
|
| 378 |
+
project=project,
|
| 379 |
+
)
|
| 380 |
+
|
| 381 |
+
@staticmethod
|
| 382 |
+
def parse_common_project_path(path: str) -> Dict[str, str]:
|
| 383 |
+
"""Parse a project path into its component segments."""
|
| 384 |
+
m = re.match(r"^projects/(?P<project>.+?)$", path)
|
| 385 |
+
return m.groupdict() if m else {}
|
| 386 |
+
|
| 387 |
+
@staticmethod
|
| 388 |
+
def common_location_path(
|
| 389 |
+
project: str,
|
| 390 |
+
location: str,
|
| 391 |
+
) -> str:
|
| 392 |
+
"""Returns a fully-qualified location string."""
|
| 393 |
+
return "projects/{project}/locations/{location}".format(
|
| 394 |
+
project=project,
|
| 395 |
+
location=location,
|
| 396 |
+
)
|
| 397 |
+
|
| 398 |
+
@staticmethod
|
| 399 |
+
def parse_common_location_path(path: str) -> Dict[str, str]:
|
| 400 |
+
"""Parse a location path into its component segments."""
|
| 401 |
+
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
|
| 402 |
+
return m.groupdict() if m else {}
|
| 403 |
+
|
| 404 |
+
@classmethod
|
| 405 |
+
def get_mtls_endpoint_and_cert_source(
|
| 406 |
+
cls, client_options: Optional[client_options_lib.ClientOptions] = None
|
| 407 |
+
):
|
| 408 |
+
"""Deprecated. Return the API endpoint and client cert source for mutual TLS.
|
| 409 |
+
|
| 410 |
+
The client cert source is determined in the following order:
|
| 411 |
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
| 412 |
+
client cert source is None.
|
| 413 |
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
| 414 |
+
default client cert source exists, use the default one; otherwise the client cert
|
| 415 |
+
source is None.
|
| 416 |
+
|
| 417 |
+
The API endpoint is determined in the following order:
|
| 418 |
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
| 419 |
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
| 420 |
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
| 421 |
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
| 422 |
+
use the default API endpoint.
|
| 423 |
+
|
| 424 |
+
More details can be found at https://google.aip.dev/auth/4114.
|
| 425 |
+
|
| 426 |
+
Args:
|
| 427 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 428 |
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
| 429 |
+
in this method.
|
| 430 |
+
|
| 431 |
+
Returns:
|
| 432 |
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
| 433 |
+
client cert source to use.
|
| 434 |
+
|
| 435 |
+
Raises:
|
| 436 |
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
| 437 |
+
"""
|
| 438 |
+
|
| 439 |
+
warnings.warn(
|
| 440 |
+
"get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
|
| 441 |
+
DeprecationWarning,
|
| 442 |
+
)
|
| 443 |
+
if client_options is None:
|
| 444 |
+
client_options = client_options_lib.ClientOptions()
|
| 445 |
+
use_client_cert = AdaptationClient._use_client_cert_effective()
|
| 446 |
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
|
| 447 |
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
| 448 |
+
raise MutualTLSChannelError(
|
| 449 |
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
| 450 |
+
)
|
| 451 |
+
|
| 452 |
+
# Figure out the client cert source to use.
|
| 453 |
+
client_cert_source = None
|
| 454 |
+
if use_client_cert:
|
| 455 |
+
if client_options.client_cert_source:
|
| 456 |
+
client_cert_source = client_options.client_cert_source
|
| 457 |
+
elif mtls.has_default_client_cert_source():
|
| 458 |
+
client_cert_source = mtls.default_client_cert_source()
|
| 459 |
+
|
| 460 |
+
# Figure out which api endpoint to use.
|
| 461 |
+
if client_options.api_endpoint is not None:
|
| 462 |
+
api_endpoint = client_options.api_endpoint
|
| 463 |
+
elif use_mtls_endpoint == "always" or (
|
| 464 |
+
use_mtls_endpoint == "auto" and client_cert_source
|
| 465 |
+
):
|
| 466 |
+
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
|
| 467 |
+
else:
|
| 468 |
+
api_endpoint = cls.DEFAULT_ENDPOINT
|
| 469 |
+
|
| 470 |
+
return api_endpoint, client_cert_source
|
| 471 |
+
|
| 472 |
+
@staticmethod
|
| 473 |
+
def _read_environment_variables():
|
| 474 |
+
"""Returns the environment variables used by the client.
|
| 475 |
+
|
| 476 |
+
Returns:
|
| 477 |
+
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
|
| 478 |
+
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
|
| 479 |
+
|
| 480 |
+
Raises:
|
| 481 |
+
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
|
| 482 |
+
any of ["true", "false"].
|
| 483 |
+
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
| 484 |
+
is not any of ["auto", "never", "always"].
|
| 485 |
+
"""
|
| 486 |
+
use_client_cert = AdaptationClient._use_client_cert_effective()
|
| 487 |
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
| 488 |
+
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
| 489 |
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
| 490 |
+
raise MutualTLSChannelError(
|
| 491 |
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
| 492 |
+
)
|
| 493 |
+
return use_client_cert, use_mtls_endpoint, universe_domain_env
|
| 494 |
+
|
| 495 |
+
@staticmethod
|
| 496 |
+
def _get_client_cert_source(provided_cert_source, use_cert_flag):
|
| 497 |
+
"""Return the client cert source to be used by the client.
|
| 498 |
+
|
| 499 |
+
Args:
|
| 500 |
+
provided_cert_source (bytes): The client certificate source provided.
|
| 501 |
+
use_cert_flag (bool): A flag indicating whether to use the client certificate.
|
| 502 |
+
|
| 503 |
+
Returns:
|
| 504 |
+
bytes or None: The client cert source to be used by the client.
|
| 505 |
+
"""
|
| 506 |
+
client_cert_source = None
|
| 507 |
+
if use_cert_flag:
|
| 508 |
+
if provided_cert_source:
|
| 509 |
+
client_cert_source = provided_cert_source
|
| 510 |
+
elif mtls.has_default_client_cert_source():
|
| 511 |
+
client_cert_source = mtls.default_client_cert_source()
|
| 512 |
+
return client_cert_source
|
| 513 |
+
|
| 514 |
+
@staticmethod
|
| 515 |
+
def _get_api_endpoint(
|
| 516 |
+
api_override, client_cert_source, universe_domain, use_mtls_endpoint
|
| 517 |
+
) -> str:
|
| 518 |
+
"""Return the API endpoint used by the client.
|
| 519 |
+
|
| 520 |
+
Args:
|
| 521 |
+
api_override (str): The API endpoint override. If specified, this is always
|
| 522 |
+
the return value of this function and the other arguments are not used.
|
| 523 |
+
client_cert_source (bytes): The client certificate source used by the client.
|
| 524 |
+
universe_domain (str): The universe domain used by the client.
|
| 525 |
+
use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
|
| 526 |
+
Possible values are "always", "auto", or "never".
|
| 527 |
+
|
| 528 |
+
Returns:
|
| 529 |
+
str: The API endpoint to be used by the client.
|
| 530 |
+
"""
|
| 531 |
+
if api_override is not None:
|
| 532 |
+
api_endpoint = api_override
|
| 533 |
+
elif use_mtls_endpoint == "always" or (
|
| 534 |
+
use_mtls_endpoint == "auto" and client_cert_source
|
| 535 |
+
):
|
| 536 |
+
_default_universe = AdaptationClient._DEFAULT_UNIVERSE
|
| 537 |
+
if universe_domain != _default_universe:
|
| 538 |
+
raise MutualTLSChannelError(
|
| 539 |
+
f"mTLS is not supported in any universe other than {_default_universe}."
|
| 540 |
+
)
|
| 541 |
+
api_endpoint = AdaptationClient.DEFAULT_MTLS_ENDPOINT
|
| 542 |
+
else:
|
| 543 |
+
api_endpoint = AdaptationClient._DEFAULT_ENDPOINT_TEMPLATE.format(
|
| 544 |
+
UNIVERSE_DOMAIN=universe_domain
|
| 545 |
+
)
|
| 546 |
+
return api_endpoint
|
| 547 |
+
|
| 548 |
+
@staticmethod
|
| 549 |
+
def _get_universe_domain(
|
| 550 |
+
client_universe_domain: Optional[str], universe_domain_env: Optional[str]
|
| 551 |
+
) -> str:
|
| 552 |
+
"""Return the universe domain used by the client.
|
| 553 |
+
|
| 554 |
+
Args:
|
| 555 |
+
client_universe_domain (Optional[str]): The universe domain configured via the client options.
|
| 556 |
+
universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
|
| 557 |
+
|
| 558 |
+
Returns:
|
| 559 |
+
str: The universe domain to be used by the client.
|
| 560 |
+
|
| 561 |
+
Raises:
|
| 562 |
+
ValueError: If the universe domain is an empty string.
|
| 563 |
+
"""
|
| 564 |
+
universe_domain = AdaptationClient._DEFAULT_UNIVERSE
|
| 565 |
+
if client_universe_domain is not None:
|
| 566 |
+
universe_domain = client_universe_domain
|
| 567 |
+
elif universe_domain_env is not None:
|
| 568 |
+
universe_domain = universe_domain_env
|
| 569 |
+
if len(universe_domain.strip()) == 0:
|
| 570 |
+
raise ValueError("Universe Domain cannot be an empty string.")
|
| 571 |
+
return universe_domain
|
| 572 |
+
|
| 573 |
+
def _validate_universe_domain(self):
|
| 574 |
+
"""Validates client's and credentials' universe domains are consistent.
|
| 575 |
+
|
| 576 |
+
Returns:
|
| 577 |
+
bool: True iff the configured universe domain is valid.
|
| 578 |
+
|
| 579 |
+
Raises:
|
| 580 |
+
ValueError: If the configured universe domain is not valid.
|
| 581 |
+
"""
|
| 582 |
+
|
| 583 |
+
# NOTE (b/349488459): universe validation is disabled until further notice.
|
| 584 |
+
return True
|
| 585 |
+
|
| 586 |
+
def _add_cred_info_for_auth_errors(
|
| 587 |
+
self, error: core_exceptions.GoogleAPICallError
|
| 588 |
+
) -> None:
|
| 589 |
+
"""Adds credential info string to error details for 401/403/404 errors.
|
| 590 |
+
|
| 591 |
+
Args:
|
| 592 |
+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
|
| 593 |
+
"""
|
| 594 |
+
if error.code not in [
|
| 595 |
+
HTTPStatus.UNAUTHORIZED,
|
| 596 |
+
HTTPStatus.FORBIDDEN,
|
| 597 |
+
HTTPStatus.NOT_FOUND,
|
| 598 |
+
]:
|
| 599 |
+
return
|
| 600 |
+
|
| 601 |
+
cred = self._transport._credentials
|
| 602 |
+
|
| 603 |
+
# get_cred_info is only available in google-auth>=2.35.0
|
| 604 |
+
if not hasattr(cred, "get_cred_info"):
|
| 605 |
+
return
|
| 606 |
+
|
| 607 |
+
# ignore the type check since pypy test fails when get_cred_info
|
| 608 |
+
# is not available
|
| 609 |
+
cred_info = cred.get_cred_info() # type: ignore
|
| 610 |
+
if cred_info and hasattr(error._details, "append"):
|
| 611 |
+
error._details.append(json.dumps(cred_info))
|
| 612 |
+
|
| 613 |
+
@property
|
| 614 |
+
def api_endpoint(self) -> str:
|
| 615 |
+
"""Return the API endpoint used by the client instance.
|
| 616 |
+
|
| 617 |
+
Returns:
|
| 618 |
+
str: The API endpoint used by the client instance.
|
| 619 |
+
"""
|
| 620 |
+
return self._api_endpoint
|
| 621 |
+
|
| 622 |
+
@property
|
| 623 |
+
def universe_domain(self) -> str:
|
| 624 |
+
"""Return the universe domain used by the client instance.
|
| 625 |
+
|
| 626 |
+
Returns:
|
| 627 |
+
str: The universe domain used by the client instance.
|
| 628 |
+
"""
|
| 629 |
+
return self._universe_domain
|
| 630 |
+
|
| 631 |
+
def __init__(
|
| 632 |
+
self,
|
| 633 |
+
*,
|
| 634 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 635 |
+
transport: Optional[
|
| 636 |
+
Union[str, AdaptationTransport, Callable[..., AdaptationTransport]]
|
| 637 |
+
] = None,
|
| 638 |
+
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
|
| 639 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 640 |
+
) -> None:
|
| 641 |
+
"""Instantiates the adaptation client.
|
| 642 |
+
|
| 643 |
+
Args:
|
| 644 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 645 |
+
authorization credentials to attach to requests. These
|
| 646 |
+
credentials identify the application to the service; if none
|
| 647 |
+
are specified, the client will attempt to ascertain the
|
| 648 |
+
credentials from the environment.
|
| 649 |
+
transport (Optional[Union[str,AdaptationTransport,Callable[..., AdaptationTransport]]]):
|
| 650 |
+
The transport to use, or a Callable that constructs and returns a new transport.
|
| 651 |
+
If a Callable is given, it will be called with the same set of initialization
|
| 652 |
+
arguments as used in the AdaptationTransport constructor.
|
| 653 |
+
If set to None, a transport is chosen automatically.
|
| 654 |
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
| 655 |
+
Custom options for the client.
|
| 656 |
+
|
| 657 |
+
1. The ``api_endpoint`` property can be used to override the
|
| 658 |
+
default endpoint provided by the client when ``transport`` is
|
| 659 |
+
not explicitly provided. Only if this property is not set and
|
| 660 |
+
``transport`` was not explicitly provided, the endpoint is
|
| 661 |
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
| 662 |
+
variable, which have one of the following values:
|
| 663 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 664 |
+
use the default regular endpoint) and "auto" (auto-switch to the
|
| 665 |
+
default mTLS endpoint if client certificate is present; this is
|
| 666 |
+
the default value).
|
| 667 |
+
|
| 668 |
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 669 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 670 |
+
to provide a client certificate for mTLS transport. If
|
| 671 |
+
not provided, the default SSL client certificate will be used if
|
| 672 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 673 |
+
set, no client certificate will be used.
|
| 674 |
+
|
| 675 |
+
3. The ``universe_domain`` property can be used to override the
|
| 676 |
+
default "googleapis.com" universe. Note that the ``api_endpoint``
|
| 677 |
+
property still takes precedence; and ``universe_domain`` is
|
| 678 |
+
currently not supported for mTLS.
|
| 679 |
+
|
| 680 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 681 |
+
The client info used to send a user-agent string along with
|
| 682 |
+
API requests. If ``None``, then default info will be used.
|
| 683 |
+
Generally, you only need to set this if you're developing
|
| 684 |
+
your own client library.
|
| 685 |
+
|
| 686 |
+
Raises:
|
| 687 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 688 |
+
creation failed for any reason.
|
| 689 |
+
"""
|
| 690 |
+
self._client_options = client_options
|
| 691 |
+
if isinstance(self._client_options, dict):
|
| 692 |
+
self._client_options = client_options_lib.from_dict(self._client_options)
|
| 693 |
+
if self._client_options is None:
|
| 694 |
+
self._client_options = client_options_lib.ClientOptions()
|
| 695 |
+
self._client_options = cast(
|
| 696 |
+
client_options_lib.ClientOptions, self._client_options
|
| 697 |
+
)
|
| 698 |
+
|
| 699 |
+
universe_domain_opt = getattr(self._client_options, "universe_domain", None)
|
| 700 |
+
|
| 701 |
+
self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
|
| 702 |
+
AdaptationClient._read_environment_variables()
|
| 703 |
+
)
|
| 704 |
+
self._client_cert_source = AdaptationClient._get_client_cert_source(
|
| 705 |
+
self._client_options.client_cert_source, self._use_client_cert
|
| 706 |
+
)
|
| 707 |
+
self._universe_domain = AdaptationClient._get_universe_domain(
|
| 708 |
+
universe_domain_opt, self._universe_domain_env
|
| 709 |
+
)
|
| 710 |
+
self._api_endpoint: str = "" # updated below, depending on `transport`
|
| 711 |
+
|
| 712 |
+
# Initialize the universe domain validation.
|
| 713 |
+
self._is_universe_domain_valid = False
|
| 714 |
+
|
| 715 |
+
if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
|
| 716 |
+
# Setup logging.
|
| 717 |
+
client_logging.initialize_logging()
|
| 718 |
+
|
| 719 |
+
api_key_value = getattr(self._client_options, "api_key", None)
|
| 720 |
+
if api_key_value and credentials:
|
| 721 |
+
raise ValueError(
|
| 722 |
+
"client_options.api_key and credentials are mutually exclusive"
|
| 723 |
+
)
|
| 724 |
+
|
| 725 |
+
# Save or instantiate the transport.
|
| 726 |
+
# Ordinarily, we provide the transport, but allowing a custom transport
|
| 727 |
+
# instance provides an extensibility point for unusual situations.
|
| 728 |
+
transport_provided = isinstance(transport, AdaptationTransport)
|
| 729 |
+
if transport_provided:
|
| 730 |
+
# transport is a AdaptationTransport instance.
|
| 731 |
+
if credentials or self._client_options.credentials_file or api_key_value:
|
| 732 |
+
raise ValueError(
|
| 733 |
+
"When providing a transport instance, "
|
| 734 |
+
"provide its credentials directly."
|
| 735 |
+
)
|
| 736 |
+
if self._client_options.scopes:
|
| 737 |
+
raise ValueError(
|
| 738 |
+
"When providing a transport instance, provide its scopes directly."
|
| 739 |
+
)
|
| 740 |
+
self._transport = cast(AdaptationTransport, transport)
|
| 741 |
+
self._api_endpoint = self._transport.host
|
| 742 |
+
|
| 743 |
+
self._api_endpoint = self._api_endpoint or AdaptationClient._get_api_endpoint(
|
| 744 |
+
self._client_options.api_endpoint,
|
| 745 |
+
self._client_cert_source,
|
| 746 |
+
self._universe_domain,
|
| 747 |
+
self._use_mtls_endpoint,
|
| 748 |
+
)
|
| 749 |
+
|
| 750 |
+
if not transport_provided:
|
| 751 |
+
import google.auth._default # type: ignore
|
| 752 |
+
|
| 753 |
+
if api_key_value and hasattr(
|
| 754 |
+
google.auth._default, "get_api_key_credentials"
|
| 755 |
+
):
|
| 756 |
+
credentials = google.auth._default.get_api_key_credentials(
|
| 757 |
+
api_key_value
|
| 758 |
+
)
|
| 759 |
+
|
| 760 |
+
transport_init: Union[
|
| 761 |
+
Type[AdaptationTransport], Callable[..., AdaptationTransport]
|
| 762 |
+
] = (
|
| 763 |
+
AdaptationClient.get_transport_class(transport)
|
| 764 |
+
if isinstance(transport, str) or transport is None
|
| 765 |
+
else cast(Callable[..., AdaptationTransport], transport)
|
| 766 |
+
)
|
| 767 |
+
# initialize with the provided callable or the passed in class
|
| 768 |
+
self._transport = transport_init(
|
| 769 |
+
credentials=credentials,
|
| 770 |
+
credentials_file=self._client_options.credentials_file,
|
| 771 |
+
host=self._api_endpoint,
|
| 772 |
+
scopes=self._client_options.scopes,
|
| 773 |
+
client_cert_source_for_mtls=self._client_cert_source,
|
| 774 |
+
quota_project_id=self._client_options.quota_project_id,
|
| 775 |
+
client_info=client_info,
|
| 776 |
+
always_use_jwt_access=True,
|
| 777 |
+
api_audience=self._client_options.api_audience,
|
| 778 |
+
)
|
| 779 |
+
|
| 780 |
+
if "async" not in str(self._transport):
|
| 781 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 782 |
+
std_logging.DEBUG
|
| 783 |
+
): # pragma: NO COVER
|
| 784 |
+
_LOGGER.debug(
|
| 785 |
+
"Created client `google.cloud.speech_v1p1beta1.AdaptationClient`.",
|
| 786 |
+
extra={
|
| 787 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Adaptation",
|
| 788 |
+
"universeDomain": getattr(
|
| 789 |
+
self._transport._credentials, "universe_domain", ""
|
| 790 |
+
),
|
| 791 |
+
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
|
| 792 |
+
"credentialsInfo": getattr(
|
| 793 |
+
self.transport._credentials, "get_cred_info", lambda: None
|
| 794 |
+
)(),
|
| 795 |
+
}
|
| 796 |
+
if hasattr(self._transport, "_credentials")
|
| 797 |
+
else {
|
| 798 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Adaptation",
|
| 799 |
+
"credentialsType": None,
|
| 800 |
+
},
|
| 801 |
+
)
|
| 802 |
+
|
| 803 |
+
def create_phrase_set(
|
| 804 |
+
self,
|
| 805 |
+
request: Optional[
|
| 806 |
+
Union[cloud_speech_adaptation.CreatePhraseSetRequest, dict]
|
| 807 |
+
] = None,
|
| 808 |
+
*,
|
| 809 |
+
parent: Optional[str] = None,
|
| 810 |
+
phrase_set: Optional[resource.PhraseSet] = None,
|
| 811 |
+
phrase_set_id: Optional[str] = None,
|
| 812 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 813 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 814 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 815 |
+
) -> resource.PhraseSet:
|
| 816 |
+
r"""Create a set of phrase hints. Each item in the set
|
| 817 |
+
can be a single word or a multi-word phrase. The items
|
| 818 |
+
in the PhraseSet are favored by the recognition model
|
| 819 |
+
when you send a call that includes the PhraseSet.
|
| 820 |
+
|
| 821 |
+
.. code-block:: python
|
| 822 |
+
|
| 823 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 824 |
+
# code template only.
|
| 825 |
+
# It will require modifications to work:
|
| 826 |
+
# - It may require correct/in-range values for request initialization.
|
| 827 |
+
# - It may require specifying regional endpoints when creating the service
|
| 828 |
+
# client as shown in:
|
| 829 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 830 |
+
from google.cloud import speech_v1p1beta1
|
| 831 |
+
|
| 832 |
+
def sample_create_phrase_set():
|
| 833 |
+
# Create a client
|
| 834 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 835 |
+
|
| 836 |
+
# Initialize request argument(s)
|
| 837 |
+
request = speech_v1p1beta1.CreatePhraseSetRequest(
|
| 838 |
+
parent="parent_value",
|
| 839 |
+
phrase_set_id="phrase_set_id_value",
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
# Make the request
|
| 843 |
+
response = client.create_phrase_set(request=request)
|
| 844 |
+
|
| 845 |
+
# Handle the response
|
| 846 |
+
print(response)
|
| 847 |
+
|
| 848 |
+
Args:
|
| 849 |
+
request (Union[google.cloud.speech_v1p1beta1.types.CreatePhraseSetRequest, dict]):
|
| 850 |
+
The request object. Message sent by the client for the ``CreatePhraseSet``
|
| 851 |
+
method.
|
| 852 |
+
parent (str):
|
| 853 |
+
Required. The parent resource where this phrase set will
|
| 854 |
+
be created. Format:
|
| 855 |
+
|
| 856 |
+
``projects/{project}/locations/{location}``
|
| 857 |
+
|
| 858 |
+
Speech-to-Text supports three locations: ``global``,
|
| 859 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 860 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 861 |
+
the ``global`` location. To specify a region, use a
|
| 862 |
+
`regional
|
| 863 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 864 |
+
with matching ``us`` or ``eu`` location value.
|
| 865 |
+
|
| 866 |
+
This corresponds to the ``parent`` field
|
| 867 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 868 |
+
should not be set.
|
| 869 |
+
phrase_set (google.cloud.speech_v1p1beta1.types.PhraseSet):
|
| 870 |
+
Required. The phrase set to create.
|
| 871 |
+
This corresponds to the ``phrase_set`` field
|
| 872 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 873 |
+
should not be set.
|
| 874 |
+
phrase_set_id (str):
|
| 875 |
+
Required. The ID to use for the
|
| 876 |
+
phrase set, which will become the final
|
| 877 |
+
component of the phrase set's resource
|
| 878 |
+
name.
|
| 879 |
+
|
| 880 |
+
This value should restrict to letters,
|
| 881 |
+
numbers, and hyphens, with the first
|
| 882 |
+
character a letter, the last a letter or
|
| 883 |
+
a number, and be 4-63 characters.
|
| 884 |
+
|
| 885 |
+
This corresponds to the ``phrase_set_id`` field
|
| 886 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 887 |
+
should not be set.
|
| 888 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 889 |
+
should be retried.
|
| 890 |
+
timeout (float): The timeout for this request.
|
| 891 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 892 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 893 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 894 |
+
be of type `bytes`.
|
| 895 |
+
|
| 896 |
+
Returns:
|
| 897 |
+
google.cloud.speech_v1p1beta1.types.PhraseSet:
|
| 898 |
+
Provides "hints" to the speech
|
| 899 |
+
recognizer to favor specific words and
|
| 900 |
+
phrases in the results.
|
| 901 |
+
|
| 902 |
+
"""
|
| 903 |
+
# Create or coerce a protobuf request object.
|
| 904 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 905 |
+
# gotten any keyword arguments that map to the request.
|
| 906 |
+
flattened_params = [parent, phrase_set, phrase_set_id]
|
| 907 |
+
has_flattened_params = (
|
| 908 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 909 |
+
)
|
| 910 |
+
if request is not None and has_flattened_params:
|
| 911 |
+
raise ValueError(
|
| 912 |
+
"If the `request` argument is set, then none of "
|
| 913 |
+
"the individual field arguments should be set."
|
| 914 |
+
)
|
| 915 |
+
|
| 916 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 917 |
+
# there are no flattened fields), or create one.
|
| 918 |
+
if not isinstance(request, cloud_speech_adaptation.CreatePhraseSetRequest):
|
| 919 |
+
request = cloud_speech_adaptation.CreatePhraseSetRequest(request)
|
| 920 |
+
# If we have keyword arguments corresponding to fields on the
|
| 921 |
+
# request, apply these.
|
| 922 |
+
if parent is not None:
|
| 923 |
+
request.parent = parent
|
| 924 |
+
if phrase_set is not None:
|
| 925 |
+
request.phrase_set = phrase_set
|
| 926 |
+
if phrase_set_id is not None:
|
| 927 |
+
request.phrase_set_id = phrase_set_id
|
| 928 |
+
|
| 929 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 930 |
+
# and friendly error handling.
|
| 931 |
+
rpc = self._transport._wrapped_methods[self._transport.create_phrase_set]
|
| 932 |
+
|
| 933 |
+
# Certain fields should be provided within the metadata header;
|
| 934 |
+
# add these here.
|
| 935 |
+
metadata = tuple(metadata) + (
|
| 936 |
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
| 937 |
+
)
|
| 938 |
+
|
| 939 |
+
# Validate the universe domain.
|
| 940 |
+
self._validate_universe_domain()
|
| 941 |
+
|
| 942 |
+
# Send the request.
|
| 943 |
+
response = rpc(
|
| 944 |
+
request,
|
| 945 |
+
retry=retry,
|
| 946 |
+
timeout=timeout,
|
| 947 |
+
metadata=metadata,
|
| 948 |
+
)
|
| 949 |
+
|
| 950 |
+
# Done; return the response.
|
| 951 |
+
return response
|
| 952 |
+
|
| 953 |
+
def get_phrase_set(
|
| 954 |
+
self,
|
| 955 |
+
request: Optional[
|
| 956 |
+
Union[cloud_speech_adaptation.GetPhraseSetRequest, dict]
|
| 957 |
+
] = None,
|
| 958 |
+
*,
|
| 959 |
+
name: Optional[str] = None,
|
| 960 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 961 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 962 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 963 |
+
) -> resource.PhraseSet:
|
| 964 |
+
r"""Get a phrase set.
|
| 965 |
+
|
| 966 |
+
.. code-block:: python
|
| 967 |
+
|
| 968 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 969 |
+
# code template only.
|
| 970 |
+
# It will require modifications to work:
|
| 971 |
+
# - It may require correct/in-range values for request initialization.
|
| 972 |
+
# - It may require specifying regional endpoints when creating the service
|
| 973 |
+
# client as shown in:
|
| 974 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 975 |
+
from google.cloud import speech_v1p1beta1
|
| 976 |
+
|
| 977 |
+
def sample_get_phrase_set():
|
| 978 |
+
# Create a client
|
| 979 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 980 |
+
|
| 981 |
+
# Initialize request argument(s)
|
| 982 |
+
request = speech_v1p1beta1.GetPhraseSetRequest(
|
| 983 |
+
name="name_value",
|
| 984 |
+
)
|
| 985 |
+
|
| 986 |
+
# Make the request
|
| 987 |
+
response = client.get_phrase_set(request=request)
|
| 988 |
+
|
| 989 |
+
# Handle the response
|
| 990 |
+
print(response)
|
| 991 |
+
|
| 992 |
+
Args:
|
| 993 |
+
request (Union[google.cloud.speech_v1p1beta1.types.GetPhraseSetRequest, dict]):
|
| 994 |
+
The request object. Message sent by the client for the ``GetPhraseSet``
|
| 995 |
+
method.
|
| 996 |
+
name (str):
|
| 997 |
+
Required. The name of the phrase set to retrieve.
|
| 998 |
+
Format:
|
| 999 |
+
|
| 1000 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 1001 |
+
|
| 1002 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1003 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1004 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1005 |
+
the ``global`` location. To specify a region, use a
|
| 1006 |
+
`regional
|
| 1007 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1008 |
+
with matching ``us`` or ``eu`` location value.
|
| 1009 |
+
|
| 1010 |
+
This corresponds to the ``name`` field
|
| 1011 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1012 |
+
should not be set.
|
| 1013 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1014 |
+
should be retried.
|
| 1015 |
+
timeout (float): The timeout for this request.
|
| 1016 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1017 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1018 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1019 |
+
be of type `bytes`.
|
| 1020 |
+
|
| 1021 |
+
Returns:
|
| 1022 |
+
google.cloud.speech_v1p1beta1.types.PhraseSet:
|
| 1023 |
+
Provides "hints" to the speech
|
| 1024 |
+
recognizer to favor specific words and
|
| 1025 |
+
phrases in the results.
|
| 1026 |
+
|
| 1027 |
+
"""
|
| 1028 |
+
# Create or coerce a protobuf request object.
|
| 1029 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1030 |
+
# gotten any keyword arguments that map to the request.
|
| 1031 |
+
flattened_params = [name]
|
| 1032 |
+
has_flattened_params = (
|
| 1033 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1034 |
+
)
|
| 1035 |
+
if request is not None and has_flattened_params:
|
| 1036 |
+
raise ValueError(
|
| 1037 |
+
"If the `request` argument is set, then none of "
|
| 1038 |
+
"the individual field arguments should be set."
|
| 1039 |
+
)
|
| 1040 |
+
|
| 1041 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1042 |
+
# there are no flattened fields), or create one.
|
| 1043 |
+
if not isinstance(request, cloud_speech_adaptation.GetPhraseSetRequest):
|
| 1044 |
+
request = cloud_speech_adaptation.GetPhraseSetRequest(request)
|
| 1045 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1046 |
+
# request, apply these.
|
| 1047 |
+
if name is not None:
|
| 1048 |
+
request.name = name
|
| 1049 |
+
|
| 1050 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1051 |
+
# and friendly error handling.
|
| 1052 |
+
rpc = self._transport._wrapped_methods[self._transport.get_phrase_set]
|
| 1053 |
+
|
| 1054 |
+
# Certain fields should be provided within the metadata header;
|
| 1055 |
+
# add these here.
|
| 1056 |
+
metadata = tuple(metadata) + (
|
| 1057 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 1058 |
+
)
|
| 1059 |
+
|
| 1060 |
+
# Validate the universe domain.
|
| 1061 |
+
self._validate_universe_domain()
|
| 1062 |
+
|
| 1063 |
+
# Send the request.
|
| 1064 |
+
response = rpc(
|
| 1065 |
+
request,
|
| 1066 |
+
retry=retry,
|
| 1067 |
+
timeout=timeout,
|
| 1068 |
+
metadata=metadata,
|
| 1069 |
+
)
|
| 1070 |
+
|
| 1071 |
+
# Done; return the response.
|
| 1072 |
+
return response
|
| 1073 |
+
|
| 1074 |
+
def list_phrase_set(
|
| 1075 |
+
self,
|
| 1076 |
+
request: Optional[
|
| 1077 |
+
Union[cloud_speech_adaptation.ListPhraseSetRequest, dict]
|
| 1078 |
+
] = None,
|
| 1079 |
+
*,
|
| 1080 |
+
parent: Optional[str] = None,
|
| 1081 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1082 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1083 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1084 |
+
) -> pagers.ListPhraseSetPager:
|
| 1085 |
+
r"""List phrase sets.
|
| 1086 |
+
|
| 1087 |
+
.. code-block:: python
|
| 1088 |
+
|
| 1089 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1090 |
+
# code template only.
|
| 1091 |
+
# It will require modifications to work:
|
| 1092 |
+
# - It may require correct/in-range values for request initialization.
|
| 1093 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1094 |
+
# client as shown in:
|
| 1095 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1096 |
+
from google.cloud import speech_v1p1beta1
|
| 1097 |
+
|
| 1098 |
+
def sample_list_phrase_set():
|
| 1099 |
+
# Create a client
|
| 1100 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 1101 |
+
|
| 1102 |
+
# Initialize request argument(s)
|
| 1103 |
+
request = speech_v1p1beta1.ListPhraseSetRequest(
|
| 1104 |
+
parent="parent_value",
|
| 1105 |
+
)
|
| 1106 |
+
|
| 1107 |
+
# Make the request
|
| 1108 |
+
page_result = client.list_phrase_set(request=request)
|
| 1109 |
+
|
| 1110 |
+
# Handle the response
|
| 1111 |
+
for response in page_result:
|
| 1112 |
+
print(response)
|
| 1113 |
+
|
| 1114 |
+
Args:
|
| 1115 |
+
request (Union[google.cloud.speech_v1p1beta1.types.ListPhraseSetRequest, dict]):
|
| 1116 |
+
The request object. Message sent by the client for the ``ListPhraseSet``
|
| 1117 |
+
method.
|
| 1118 |
+
parent (str):
|
| 1119 |
+
Required. The parent, which owns this collection of
|
| 1120 |
+
phrase set. Format:
|
| 1121 |
+
|
| 1122 |
+
``projects/{project}/locations/{location}``
|
| 1123 |
+
|
| 1124 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1125 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1126 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1127 |
+
the ``global`` location. To specify a region, use a
|
| 1128 |
+
`regional
|
| 1129 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1130 |
+
with matching ``us`` or ``eu`` location value.
|
| 1131 |
+
|
| 1132 |
+
This corresponds to the ``parent`` field
|
| 1133 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1134 |
+
should not be set.
|
| 1135 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1136 |
+
should be retried.
|
| 1137 |
+
timeout (float): The timeout for this request.
|
| 1138 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1139 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1140 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1141 |
+
be of type `bytes`.
|
| 1142 |
+
|
| 1143 |
+
Returns:
|
| 1144 |
+
google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListPhraseSetPager:
|
| 1145 |
+
Message returned to the client by the ListPhraseSet
|
| 1146 |
+
method.
|
| 1147 |
+
|
| 1148 |
+
Iterating over this object will yield results and
|
| 1149 |
+
resolve additional pages automatically.
|
| 1150 |
+
|
| 1151 |
+
"""
|
| 1152 |
+
# Create or coerce a protobuf request object.
|
| 1153 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1154 |
+
# gotten any keyword arguments that map to the request.
|
| 1155 |
+
flattened_params = [parent]
|
| 1156 |
+
has_flattened_params = (
|
| 1157 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1158 |
+
)
|
| 1159 |
+
if request is not None and has_flattened_params:
|
| 1160 |
+
raise ValueError(
|
| 1161 |
+
"If the `request` argument is set, then none of "
|
| 1162 |
+
"the individual field arguments should be set."
|
| 1163 |
+
)
|
| 1164 |
+
|
| 1165 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1166 |
+
# there are no flattened fields), or create one.
|
| 1167 |
+
if not isinstance(request, cloud_speech_adaptation.ListPhraseSetRequest):
|
| 1168 |
+
request = cloud_speech_adaptation.ListPhraseSetRequest(request)
|
| 1169 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1170 |
+
# request, apply these.
|
| 1171 |
+
if parent is not None:
|
| 1172 |
+
request.parent = parent
|
| 1173 |
+
|
| 1174 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1175 |
+
# and friendly error handling.
|
| 1176 |
+
rpc = self._transport._wrapped_methods[self._transport.list_phrase_set]
|
| 1177 |
+
|
| 1178 |
+
# Certain fields should be provided within the metadata header;
|
| 1179 |
+
# add these here.
|
| 1180 |
+
metadata = tuple(metadata) + (
|
| 1181 |
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
| 1182 |
+
)
|
| 1183 |
+
|
| 1184 |
+
# Validate the universe domain.
|
| 1185 |
+
self._validate_universe_domain()
|
| 1186 |
+
|
| 1187 |
+
# Send the request.
|
| 1188 |
+
response = rpc(
|
| 1189 |
+
request,
|
| 1190 |
+
retry=retry,
|
| 1191 |
+
timeout=timeout,
|
| 1192 |
+
metadata=metadata,
|
| 1193 |
+
)
|
| 1194 |
+
|
| 1195 |
+
# This method is paged; wrap the response in a pager, which provides
|
| 1196 |
+
# an `__iter__` convenience method.
|
| 1197 |
+
response = pagers.ListPhraseSetPager(
|
| 1198 |
+
method=rpc,
|
| 1199 |
+
request=request,
|
| 1200 |
+
response=response,
|
| 1201 |
+
retry=retry,
|
| 1202 |
+
timeout=timeout,
|
| 1203 |
+
metadata=metadata,
|
| 1204 |
+
)
|
| 1205 |
+
|
| 1206 |
+
# Done; return the response.
|
| 1207 |
+
return response
|
| 1208 |
+
|
| 1209 |
+
def update_phrase_set(
|
| 1210 |
+
self,
|
| 1211 |
+
request: Optional[
|
| 1212 |
+
Union[cloud_speech_adaptation.UpdatePhraseSetRequest, dict]
|
| 1213 |
+
] = None,
|
| 1214 |
+
*,
|
| 1215 |
+
phrase_set: Optional[resource.PhraseSet] = None,
|
| 1216 |
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
| 1217 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1218 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1219 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1220 |
+
) -> resource.PhraseSet:
|
| 1221 |
+
r"""Update a phrase set.
|
| 1222 |
+
|
| 1223 |
+
.. code-block:: python
|
| 1224 |
+
|
| 1225 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1226 |
+
# code template only.
|
| 1227 |
+
# It will require modifications to work:
|
| 1228 |
+
# - It may require correct/in-range values for request initialization.
|
| 1229 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1230 |
+
# client as shown in:
|
| 1231 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1232 |
+
from google.cloud import speech_v1p1beta1
|
| 1233 |
+
|
| 1234 |
+
def sample_update_phrase_set():
|
| 1235 |
+
# Create a client
|
| 1236 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 1237 |
+
|
| 1238 |
+
# Initialize request argument(s)
|
| 1239 |
+
request = speech_v1p1beta1.UpdatePhraseSetRequest(
|
| 1240 |
+
)
|
| 1241 |
+
|
| 1242 |
+
# Make the request
|
| 1243 |
+
response = client.update_phrase_set(request=request)
|
| 1244 |
+
|
| 1245 |
+
# Handle the response
|
| 1246 |
+
print(response)
|
| 1247 |
+
|
| 1248 |
+
Args:
|
| 1249 |
+
request (Union[google.cloud.speech_v1p1beta1.types.UpdatePhraseSetRequest, dict]):
|
| 1250 |
+
The request object. Message sent by the client for the ``UpdatePhraseSet``
|
| 1251 |
+
method.
|
| 1252 |
+
phrase_set (google.cloud.speech_v1p1beta1.types.PhraseSet):
|
| 1253 |
+
Required. The phrase set to update.
|
| 1254 |
+
|
| 1255 |
+
The phrase set's ``name`` field is used to identify the
|
| 1256 |
+
set to be updated. Format:
|
| 1257 |
+
|
| 1258 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 1259 |
+
|
| 1260 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1261 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1262 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1263 |
+
the ``global`` location. To specify a region, use a
|
| 1264 |
+
`regional
|
| 1265 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1266 |
+
with matching ``us`` or ``eu`` location value.
|
| 1267 |
+
|
| 1268 |
+
This corresponds to the ``phrase_set`` field
|
| 1269 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1270 |
+
should not be set.
|
| 1271 |
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
| 1272 |
+
The list of fields to be updated.
|
| 1273 |
+
This corresponds to the ``update_mask`` field
|
| 1274 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1275 |
+
should not be set.
|
| 1276 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1277 |
+
should be retried.
|
| 1278 |
+
timeout (float): The timeout for this request.
|
| 1279 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1280 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1281 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1282 |
+
be of type `bytes`.
|
| 1283 |
+
|
| 1284 |
+
Returns:
|
| 1285 |
+
google.cloud.speech_v1p1beta1.types.PhraseSet:
|
| 1286 |
+
Provides "hints" to the speech
|
| 1287 |
+
recognizer to favor specific words and
|
| 1288 |
+
phrases in the results.
|
| 1289 |
+
|
| 1290 |
+
"""
|
| 1291 |
+
# Create or coerce a protobuf request object.
|
| 1292 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1293 |
+
# gotten any keyword arguments that map to the request.
|
| 1294 |
+
flattened_params = [phrase_set, update_mask]
|
| 1295 |
+
has_flattened_params = (
|
| 1296 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1297 |
+
)
|
| 1298 |
+
if request is not None and has_flattened_params:
|
| 1299 |
+
raise ValueError(
|
| 1300 |
+
"If the `request` argument is set, then none of "
|
| 1301 |
+
"the individual field arguments should be set."
|
| 1302 |
+
)
|
| 1303 |
+
|
| 1304 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1305 |
+
# there are no flattened fields), or create one.
|
| 1306 |
+
if not isinstance(request, cloud_speech_adaptation.UpdatePhraseSetRequest):
|
| 1307 |
+
request = cloud_speech_adaptation.UpdatePhraseSetRequest(request)
|
| 1308 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1309 |
+
# request, apply these.
|
| 1310 |
+
if phrase_set is not None:
|
| 1311 |
+
request.phrase_set = phrase_set
|
| 1312 |
+
if update_mask is not None:
|
| 1313 |
+
request.update_mask = update_mask
|
| 1314 |
+
|
| 1315 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1316 |
+
# and friendly error handling.
|
| 1317 |
+
rpc = self._transport._wrapped_methods[self._transport.update_phrase_set]
|
| 1318 |
+
|
| 1319 |
+
# Certain fields should be provided within the metadata header;
|
| 1320 |
+
# add these here.
|
| 1321 |
+
metadata = tuple(metadata) + (
|
| 1322 |
+
gapic_v1.routing_header.to_grpc_metadata(
|
| 1323 |
+
(("phrase_set.name", request.phrase_set.name),)
|
| 1324 |
+
),
|
| 1325 |
+
)
|
| 1326 |
+
|
| 1327 |
+
# Validate the universe domain.
|
| 1328 |
+
self._validate_universe_domain()
|
| 1329 |
+
|
| 1330 |
+
# Send the request.
|
| 1331 |
+
response = rpc(
|
| 1332 |
+
request,
|
| 1333 |
+
retry=retry,
|
| 1334 |
+
timeout=timeout,
|
| 1335 |
+
metadata=metadata,
|
| 1336 |
+
)
|
| 1337 |
+
|
| 1338 |
+
# Done; return the response.
|
| 1339 |
+
return response
|
| 1340 |
+
|
| 1341 |
+
def delete_phrase_set(
|
| 1342 |
+
self,
|
| 1343 |
+
request: Optional[
|
| 1344 |
+
Union[cloud_speech_adaptation.DeletePhraseSetRequest, dict]
|
| 1345 |
+
] = None,
|
| 1346 |
+
*,
|
| 1347 |
+
name: Optional[str] = None,
|
| 1348 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1349 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1350 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1351 |
+
) -> None:
|
| 1352 |
+
r"""Delete a phrase set.
|
| 1353 |
+
|
| 1354 |
+
.. code-block:: python
|
| 1355 |
+
|
| 1356 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1357 |
+
# code template only.
|
| 1358 |
+
# It will require modifications to work:
|
| 1359 |
+
# - It may require correct/in-range values for request initialization.
|
| 1360 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1361 |
+
# client as shown in:
|
| 1362 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1363 |
+
from google.cloud import speech_v1p1beta1
|
| 1364 |
+
|
| 1365 |
+
def sample_delete_phrase_set():
|
| 1366 |
+
# Create a client
|
| 1367 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 1368 |
+
|
| 1369 |
+
# Initialize request argument(s)
|
| 1370 |
+
request = speech_v1p1beta1.DeletePhraseSetRequest(
|
| 1371 |
+
name="name_value",
|
| 1372 |
+
)
|
| 1373 |
+
|
| 1374 |
+
# Make the request
|
| 1375 |
+
client.delete_phrase_set(request=request)
|
| 1376 |
+
|
| 1377 |
+
Args:
|
| 1378 |
+
request (Union[google.cloud.speech_v1p1beta1.types.DeletePhraseSetRequest, dict]):
|
| 1379 |
+
The request object. Message sent by the client for the ``DeletePhraseSet``
|
| 1380 |
+
method.
|
| 1381 |
+
name (str):
|
| 1382 |
+
Required. The name of the phrase set to delete. Format:
|
| 1383 |
+
|
| 1384 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 1385 |
+
|
| 1386 |
+
This corresponds to the ``name`` field
|
| 1387 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1388 |
+
should not be set.
|
| 1389 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1390 |
+
should be retried.
|
| 1391 |
+
timeout (float): The timeout for this request.
|
| 1392 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1393 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1394 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1395 |
+
be of type `bytes`.
|
| 1396 |
+
"""
|
| 1397 |
+
# Create or coerce a protobuf request object.
|
| 1398 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1399 |
+
# gotten any keyword arguments that map to the request.
|
| 1400 |
+
flattened_params = [name]
|
| 1401 |
+
has_flattened_params = (
|
| 1402 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1403 |
+
)
|
| 1404 |
+
if request is not None and has_flattened_params:
|
| 1405 |
+
raise ValueError(
|
| 1406 |
+
"If the `request` argument is set, then none of "
|
| 1407 |
+
"the individual field arguments should be set."
|
| 1408 |
+
)
|
| 1409 |
+
|
| 1410 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1411 |
+
# there are no flattened fields), or create one.
|
| 1412 |
+
if not isinstance(request, cloud_speech_adaptation.DeletePhraseSetRequest):
|
| 1413 |
+
request = cloud_speech_adaptation.DeletePhraseSetRequest(request)
|
| 1414 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1415 |
+
# request, apply these.
|
| 1416 |
+
if name is not None:
|
| 1417 |
+
request.name = name
|
| 1418 |
+
|
| 1419 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1420 |
+
# and friendly error handling.
|
| 1421 |
+
rpc = self._transport._wrapped_methods[self._transport.delete_phrase_set]
|
| 1422 |
+
|
| 1423 |
+
# Certain fields should be provided within the metadata header;
|
| 1424 |
+
# add these here.
|
| 1425 |
+
metadata = tuple(metadata) + (
|
| 1426 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 1427 |
+
)
|
| 1428 |
+
|
| 1429 |
+
# Validate the universe domain.
|
| 1430 |
+
self._validate_universe_domain()
|
| 1431 |
+
|
| 1432 |
+
# Send the request.
|
| 1433 |
+
rpc(
|
| 1434 |
+
request,
|
| 1435 |
+
retry=retry,
|
| 1436 |
+
timeout=timeout,
|
| 1437 |
+
metadata=metadata,
|
| 1438 |
+
)
|
| 1439 |
+
|
| 1440 |
+
def create_custom_class(
|
| 1441 |
+
self,
|
| 1442 |
+
request: Optional[
|
| 1443 |
+
Union[cloud_speech_adaptation.CreateCustomClassRequest, dict]
|
| 1444 |
+
] = None,
|
| 1445 |
+
*,
|
| 1446 |
+
parent: Optional[str] = None,
|
| 1447 |
+
custom_class: Optional[resource.CustomClass] = None,
|
| 1448 |
+
custom_class_id: Optional[str] = None,
|
| 1449 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1450 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1451 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1452 |
+
) -> resource.CustomClass:
|
| 1453 |
+
r"""Create a custom class.
|
| 1454 |
+
|
| 1455 |
+
.. code-block:: python
|
| 1456 |
+
|
| 1457 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1458 |
+
# code template only.
|
| 1459 |
+
# It will require modifications to work:
|
| 1460 |
+
# - It may require correct/in-range values for request initialization.
|
| 1461 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1462 |
+
# client as shown in:
|
| 1463 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1464 |
+
from google.cloud import speech_v1p1beta1
|
| 1465 |
+
|
| 1466 |
+
def sample_create_custom_class():
|
| 1467 |
+
# Create a client
|
| 1468 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 1469 |
+
|
| 1470 |
+
# Initialize request argument(s)
|
| 1471 |
+
request = speech_v1p1beta1.CreateCustomClassRequest(
|
| 1472 |
+
parent="parent_value",
|
| 1473 |
+
custom_class_id="custom_class_id_value",
|
| 1474 |
+
)
|
| 1475 |
+
|
| 1476 |
+
# Make the request
|
| 1477 |
+
response = client.create_custom_class(request=request)
|
| 1478 |
+
|
| 1479 |
+
# Handle the response
|
| 1480 |
+
print(response)
|
| 1481 |
+
|
| 1482 |
+
Args:
|
| 1483 |
+
request (Union[google.cloud.speech_v1p1beta1.types.CreateCustomClassRequest, dict]):
|
| 1484 |
+
The request object. Message sent by the client for the ``CreateCustomClass``
|
| 1485 |
+
method.
|
| 1486 |
+
parent (str):
|
| 1487 |
+
Required. The parent resource where this custom class
|
| 1488 |
+
will be created. Format:
|
| 1489 |
+
|
| 1490 |
+
``projects/{project}/locations/{location}/customClasses``
|
| 1491 |
+
|
| 1492 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1493 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1494 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1495 |
+
the ``global`` location. To specify a region, use a
|
| 1496 |
+
`regional
|
| 1497 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1498 |
+
with matching ``us`` or ``eu`` location value.
|
| 1499 |
+
|
| 1500 |
+
This corresponds to the ``parent`` field
|
| 1501 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1502 |
+
should not be set.
|
| 1503 |
+
custom_class (google.cloud.speech_v1p1beta1.types.CustomClass):
|
| 1504 |
+
Required. The custom class to create.
|
| 1505 |
+
This corresponds to the ``custom_class`` field
|
| 1506 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1507 |
+
should not be set.
|
| 1508 |
+
custom_class_id (str):
|
| 1509 |
+
Required. The ID to use for the
|
| 1510 |
+
custom class, which will become the
|
| 1511 |
+
final component of the custom class'
|
| 1512 |
+
resource name.
|
| 1513 |
+
|
| 1514 |
+
This value should restrict to letters,
|
| 1515 |
+
numbers, and hyphens, with the first
|
| 1516 |
+
character a letter, the last a letter or
|
| 1517 |
+
a number, and be 4-63 characters.
|
| 1518 |
+
|
| 1519 |
+
This corresponds to the ``custom_class_id`` field
|
| 1520 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1521 |
+
should not be set.
|
| 1522 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1523 |
+
should be retried.
|
| 1524 |
+
timeout (float): The timeout for this request.
|
| 1525 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1526 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1527 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1528 |
+
be of type `bytes`.
|
| 1529 |
+
|
| 1530 |
+
Returns:
|
| 1531 |
+
google.cloud.speech_v1p1beta1.types.CustomClass:
|
| 1532 |
+
A set of words or phrases that
|
| 1533 |
+
represents a common concept likely to
|
| 1534 |
+
appear in your audio, for example a list
|
| 1535 |
+
of passenger ship names. CustomClass
|
| 1536 |
+
items can be substituted into
|
| 1537 |
+
placeholders that you set in PhraseSet
|
| 1538 |
+
phrases.
|
| 1539 |
+
|
| 1540 |
+
"""
|
| 1541 |
+
# Create or coerce a protobuf request object.
|
| 1542 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1543 |
+
# gotten any keyword arguments that map to the request.
|
| 1544 |
+
flattened_params = [parent, custom_class, custom_class_id]
|
| 1545 |
+
has_flattened_params = (
|
| 1546 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1547 |
+
)
|
| 1548 |
+
if request is not None and has_flattened_params:
|
| 1549 |
+
raise ValueError(
|
| 1550 |
+
"If the `request` argument is set, then none of "
|
| 1551 |
+
"the individual field arguments should be set."
|
| 1552 |
+
)
|
| 1553 |
+
|
| 1554 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1555 |
+
# there are no flattened fields), or create one.
|
| 1556 |
+
if not isinstance(request, cloud_speech_adaptation.CreateCustomClassRequest):
|
| 1557 |
+
request = cloud_speech_adaptation.CreateCustomClassRequest(request)
|
| 1558 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1559 |
+
# request, apply these.
|
| 1560 |
+
if parent is not None:
|
| 1561 |
+
request.parent = parent
|
| 1562 |
+
if custom_class is not None:
|
| 1563 |
+
request.custom_class = custom_class
|
| 1564 |
+
if custom_class_id is not None:
|
| 1565 |
+
request.custom_class_id = custom_class_id
|
| 1566 |
+
|
| 1567 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1568 |
+
# and friendly error handling.
|
| 1569 |
+
rpc = self._transport._wrapped_methods[self._transport.create_custom_class]
|
| 1570 |
+
|
| 1571 |
+
# Certain fields should be provided within the metadata header;
|
| 1572 |
+
# add these here.
|
| 1573 |
+
metadata = tuple(metadata) + (
|
| 1574 |
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
| 1575 |
+
)
|
| 1576 |
+
|
| 1577 |
+
# Validate the universe domain.
|
| 1578 |
+
self._validate_universe_domain()
|
| 1579 |
+
|
| 1580 |
+
# Send the request.
|
| 1581 |
+
response = rpc(
|
| 1582 |
+
request,
|
| 1583 |
+
retry=retry,
|
| 1584 |
+
timeout=timeout,
|
| 1585 |
+
metadata=metadata,
|
| 1586 |
+
)
|
| 1587 |
+
|
| 1588 |
+
# Done; return the response.
|
| 1589 |
+
return response
|
| 1590 |
+
|
| 1591 |
+
def get_custom_class(
|
| 1592 |
+
self,
|
| 1593 |
+
request: Optional[
|
| 1594 |
+
Union[cloud_speech_adaptation.GetCustomClassRequest, dict]
|
| 1595 |
+
] = None,
|
| 1596 |
+
*,
|
| 1597 |
+
name: Optional[str] = None,
|
| 1598 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1599 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1600 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1601 |
+
) -> resource.CustomClass:
|
| 1602 |
+
r"""Get a custom class.
|
| 1603 |
+
|
| 1604 |
+
.. code-block:: python
|
| 1605 |
+
|
| 1606 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1607 |
+
# code template only.
|
| 1608 |
+
# It will require modifications to work:
|
| 1609 |
+
# - It may require correct/in-range values for request initialization.
|
| 1610 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1611 |
+
# client as shown in:
|
| 1612 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1613 |
+
from google.cloud import speech_v1p1beta1
|
| 1614 |
+
|
| 1615 |
+
def sample_get_custom_class():
|
| 1616 |
+
# Create a client
|
| 1617 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 1618 |
+
|
| 1619 |
+
# Initialize request argument(s)
|
| 1620 |
+
request = speech_v1p1beta1.GetCustomClassRequest(
|
| 1621 |
+
name="name_value",
|
| 1622 |
+
)
|
| 1623 |
+
|
| 1624 |
+
# Make the request
|
| 1625 |
+
response = client.get_custom_class(request=request)
|
| 1626 |
+
|
| 1627 |
+
# Handle the response
|
| 1628 |
+
print(response)
|
| 1629 |
+
|
| 1630 |
+
Args:
|
| 1631 |
+
request (Union[google.cloud.speech_v1p1beta1.types.GetCustomClassRequest, dict]):
|
| 1632 |
+
The request object. Message sent by the client for the ``GetCustomClass``
|
| 1633 |
+
method.
|
| 1634 |
+
name (str):
|
| 1635 |
+
Required. The name of the custom class to retrieve.
|
| 1636 |
+
Format:
|
| 1637 |
+
|
| 1638 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 1639 |
+
|
| 1640 |
+
This corresponds to the ``name`` field
|
| 1641 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1642 |
+
should not be set.
|
| 1643 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1644 |
+
should be retried.
|
| 1645 |
+
timeout (float): The timeout for this request.
|
| 1646 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1647 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1648 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1649 |
+
be of type `bytes`.
|
| 1650 |
+
|
| 1651 |
+
Returns:
|
| 1652 |
+
google.cloud.speech_v1p1beta1.types.CustomClass:
|
| 1653 |
+
A set of words or phrases that
|
| 1654 |
+
represents a common concept likely to
|
| 1655 |
+
appear in your audio, for example a list
|
| 1656 |
+
of passenger ship names. CustomClass
|
| 1657 |
+
items can be substituted into
|
| 1658 |
+
placeholders that you set in PhraseSet
|
| 1659 |
+
phrases.
|
| 1660 |
+
|
| 1661 |
+
"""
|
| 1662 |
+
# Create or coerce a protobuf request object.
|
| 1663 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1664 |
+
# gotten any keyword arguments that map to the request.
|
| 1665 |
+
flattened_params = [name]
|
| 1666 |
+
has_flattened_params = (
|
| 1667 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1668 |
+
)
|
| 1669 |
+
if request is not None and has_flattened_params:
|
| 1670 |
+
raise ValueError(
|
| 1671 |
+
"If the `request` argument is set, then none of "
|
| 1672 |
+
"the individual field arguments should be set."
|
| 1673 |
+
)
|
| 1674 |
+
|
| 1675 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1676 |
+
# there are no flattened fields), or create one.
|
| 1677 |
+
if not isinstance(request, cloud_speech_adaptation.GetCustomClassRequest):
|
| 1678 |
+
request = cloud_speech_adaptation.GetCustomClassRequest(request)
|
| 1679 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1680 |
+
# request, apply these.
|
| 1681 |
+
if name is not None:
|
| 1682 |
+
request.name = name
|
| 1683 |
+
|
| 1684 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1685 |
+
# and friendly error handling.
|
| 1686 |
+
rpc = self._transport._wrapped_methods[self._transport.get_custom_class]
|
| 1687 |
+
|
| 1688 |
+
# Certain fields should be provided within the metadata header;
|
| 1689 |
+
# add these here.
|
| 1690 |
+
metadata = tuple(metadata) + (
|
| 1691 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 1692 |
+
)
|
| 1693 |
+
|
| 1694 |
+
# Validate the universe domain.
|
| 1695 |
+
self._validate_universe_domain()
|
| 1696 |
+
|
| 1697 |
+
# Send the request.
|
| 1698 |
+
response = rpc(
|
| 1699 |
+
request,
|
| 1700 |
+
retry=retry,
|
| 1701 |
+
timeout=timeout,
|
| 1702 |
+
metadata=metadata,
|
| 1703 |
+
)
|
| 1704 |
+
|
| 1705 |
+
# Done; return the response.
|
| 1706 |
+
return response
|
| 1707 |
+
|
| 1708 |
+
def list_custom_classes(
|
| 1709 |
+
self,
|
| 1710 |
+
request: Optional[
|
| 1711 |
+
Union[cloud_speech_adaptation.ListCustomClassesRequest, dict]
|
| 1712 |
+
] = None,
|
| 1713 |
+
*,
|
| 1714 |
+
parent: Optional[str] = None,
|
| 1715 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1716 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1717 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1718 |
+
) -> pagers.ListCustomClassesPager:
|
| 1719 |
+
r"""List custom classes.
|
| 1720 |
+
|
| 1721 |
+
.. code-block:: python
|
| 1722 |
+
|
| 1723 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1724 |
+
# code template only.
|
| 1725 |
+
# It will require modifications to work:
|
| 1726 |
+
# - It may require correct/in-range values for request initialization.
|
| 1727 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1728 |
+
# client as shown in:
|
| 1729 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1730 |
+
from google.cloud import speech_v1p1beta1
|
| 1731 |
+
|
| 1732 |
+
def sample_list_custom_classes():
|
| 1733 |
+
# Create a client
|
| 1734 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 1735 |
+
|
| 1736 |
+
# Initialize request argument(s)
|
| 1737 |
+
request = speech_v1p1beta1.ListCustomClassesRequest(
|
| 1738 |
+
parent="parent_value",
|
| 1739 |
+
)
|
| 1740 |
+
|
| 1741 |
+
# Make the request
|
| 1742 |
+
page_result = client.list_custom_classes(request=request)
|
| 1743 |
+
|
| 1744 |
+
# Handle the response
|
| 1745 |
+
for response in page_result:
|
| 1746 |
+
print(response)
|
| 1747 |
+
|
| 1748 |
+
Args:
|
| 1749 |
+
request (Union[google.cloud.speech_v1p1beta1.types.ListCustomClassesRequest, dict]):
|
| 1750 |
+
The request object. Message sent by the client for the ``ListCustomClasses``
|
| 1751 |
+
method.
|
| 1752 |
+
parent (str):
|
| 1753 |
+
Required. The parent, which owns this collection of
|
| 1754 |
+
custom classes. Format:
|
| 1755 |
+
|
| 1756 |
+
``projects/{project}/locations/{location}/customClasses``
|
| 1757 |
+
|
| 1758 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1759 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1760 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1761 |
+
the ``global`` location. To specify a region, use a
|
| 1762 |
+
`regional
|
| 1763 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1764 |
+
with matching ``us`` or ``eu`` location value.
|
| 1765 |
+
|
| 1766 |
+
This corresponds to the ``parent`` field
|
| 1767 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1768 |
+
should not be set.
|
| 1769 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1770 |
+
should be retried.
|
| 1771 |
+
timeout (float): The timeout for this request.
|
| 1772 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1773 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1774 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1775 |
+
be of type `bytes`.
|
| 1776 |
+
|
| 1777 |
+
Returns:
|
| 1778 |
+
google.cloud.speech_v1p1beta1.services.adaptation.pagers.ListCustomClassesPager:
|
| 1779 |
+
Message returned to the client by the ListCustomClasses
|
| 1780 |
+
method.
|
| 1781 |
+
|
| 1782 |
+
Iterating over this object will yield results and
|
| 1783 |
+
resolve additional pages automatically.
|
| 1784 |
+
|
| 1785 |
+
"""
|
| 1786 |
+
# Create or coerce a protobuf request object.
|
| 1787 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1788 |
+
# gotten any keyword arguments that map to the request.
|
| 1789 |
+
flattened_params = [parent]
|
| 1790 |
+
has_flattened_params = (
|
| 1791 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1792 |
+
)
|
| 1793 |
+
if request is not None and has_flattened_params:
|
| 1794 |
+
raise ValueError(
|
| 1795 |
+
"If the `request` argument is set, then none of "
|
| 1796 |
+
"the individual field arguments should be set."
|
| 1797 |
+
)
|
| 1798 |
+
|
| 1799 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1800 |
+
# there are no flattened fields), or create one.
|
| 1801 |
+
if not isinstance(request, cloud_speech_adaptation.ListCustomClassesRequest):
|
| 1802 |
+
request = cloud_speech_adaptation.ListCustomClassesRequest(request)
|
| 1803 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1804 |
+
# request, apply these.
|
| 1805 |
+
if parent is not None:
|
| 1806 |
+
request.parent = parent
|
| 1807 |
+
|
| 1808 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1809 |
+
# and friendly error handling.
|
| 1810 |
+
rpc = self._transport._wrapped_methods[self._transport.list_custom_classes]
|
| 1811 |
+
|
| 1812 |
+
# Certain fields should be provided within the metadata header;
|
| 1813 |
+
# add these here.
|
| 1814 |
+
metadata = tuple(metadata) + (
|
| 1815 |
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
| 1816 |
+
)
|
| 1817 |
+
|
| 1818 |
+
# Validate the universe domain.
|
| 1819 |
+
self._validate_universe_domain()
|
| 1820 |
+
|
| 1821 |
+
# Send the request.
|
| 1822 |
+
response = rpc(
|
| 1823 |
+
request,
|
| 1824 |
+
retry=retry,
|
| 1825 |
+
timeout=timeout,
|
| 1826 |
+
metadata=metadata,
|
| 1827 |
+
)
|
| 1828 |
+
|
| 1829 |
+
# This method is paged; wrap the response in a pager, which provides
|
| 1830 |
+
# an `__iter__` convenience method.
|
| 1831 |
+
response = pagers.ListCustomClassesPager(
|
| 1832 |
+
method=rpc,
|
| 1833 |
+
request=request,
|
| 1834 |
+
response=response,
|
| 1835 |
+
retry=retry,
|
| 1836 |
+
timeout=timeout,
|
| 1837 |
+
metadata=metadata,
|
| 1838 |
+
)
|
| 1839 |
+
|
| 1840 |
+
# Done; return the response.
|
| 1841 |
+
return response
|
| 1842 |
+
|
| 1843 |
+
def update_custom_class(
|
| 1844 |
+
self,
|
| 1845 |
+
request: Optional[
|
| 1846 |
+
Union[cloud_speech_adaptation.UpdateCustomClassRequest, dict]
|
| 1847 |
+
] = None,
|
| 1848 |
+
*,
|
| 1849 |
+
custom_class: Optional[resource.CustomClass] = None,
|
| 1850 |
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
| 1851 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1852 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1853 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1854 |
+
) -> resource.CustomClass:
|
| 1855 |
+
r"""Update a custom class.
|
| 1856 |
+
|
| 1857 |
+
.. code-block:: python
|
| 1858 |
+
|
| 1859 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1860 |
+
# code template only.
|
| 1861 |
+
# It will require modifications to work:
|
| 1862 |
+
# - It may require correct/in-range values for request initialization.
|
| 1863 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1864 |
+
# client as shown in:
|
| 1865 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1866 |
+
from google.cloud import speech_v1p1beta1
|
| 1867 |
+
|
| 1868 |
+
def sample_update_custom_class():
|
| 1869 |
+
# Create a client
|
| 1870 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 1871 |
+
|
| 1872 |
+
# Initialize request argument(s)
|
| 1873 |
+
request = speech_v1p1beta1.UpdateCustomClassRequest(
|
| 1874 |
+
)
|
| 1875 |
+
|
| 1876 |
+
# Make the request
|
| 1877 |
+
response = client.update_custom_class(request=request)
|
| 1878 |
+
|
| 1879 |
+
# Handle the response
|
| 1880 |
+
print(response)
|
| 1881 |
+
|
| 1882 |
+
Args:
|
| 1883 |
+
request (Union[google.cloud.speech_v1p1beta1.types.UpdateCustomClassRequest, dict]):
|
| 1884 |
+
The request object. Message sent by the client for the ``UpdateCustomClass``
|
| 1885 |
+
method.
|
| 1886 |
+
custom_class (google.cloud.speech_v1p1beta1.types.CustomClass):
|
| 1887 |
+
Required. The custom class to update.
|
| 1888 |
+
|
| 1889 |
+
The custom class's ``name`` field is used to identify
|
| 1890 |
+
the custom class to be updated. Format:
|
| 1891 |
+
|
| 1892 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 1893 |
+
|
| 1894 |
+
Speech-to-Text supports three locations: ``global``,
|
| 1895 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 1896 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 1897 |
+
the ``global`` location. To specify a region, use a
|
| 1898 |
+
`regional
|
| 1899 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 1900 |
+
with matching ``us`` or ``eu`` location value.
|
| 1901 |
+
|
| 1902 |
+
This corresponds to the ``custom_class`` field
|
| 1903 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1904 |
+
should not be set.
|
| 1905 |
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
| 1906 |
+
The list of fields to be updated.
|
| 1907 |
+
This corresponds to the ``update_mask`` field
|
| 1908 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1909 |
+
should not be set.
|
| 1910 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1911 |
+
should be retried.
|
| 1912 |
+
timeout (float): The timeout for this request.
|
| 1913 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1914 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1915 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1916 |
+
be of type `bytes`.
|
| 1917 |
+
|
| 1918 |
+
Returns:
|
| 1919 |
+
google.cloud.speech_v1p1beta1.types.CustomClass:
|
| 1920 |
+
A set of words or phrases that
|
| 1921 |
+
represents a common concept likely to
|
| 1922 |
+
appear in your audio, for example a list
|
| 1923 |
+
of passenger ship names. CustomClass
|
| 1924 |
+
items can be substituted into
|
| 1925 |
+
placeholders that you set in PhraseSet
|
| 1926 |
+
phrases.
|
| 1927 |
+
|
| 1928 |
+
"""
|
| 1929 |
+
# Create or coerce a protobuf request object.
|
| 1930 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1931 |
+
# gotten any keyword arguments that map to the request.
|
| 1932 |
+
flattened_params = [custom_class, update_mask]
|
| 1933 |
+
has_flattened_params = (
|
| 1934 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1935 |
+
)
|
| 1936 |
+
if request is not None and has_flattened_params:
|
| 1937 |
+
raise ValueError(
|
| 1938 |
+
"If the `request` argument is set, then none of "
|
| 1939 |
+
"the individual field arguments should be set."
|
| 1940 |
+
)
|
| 1941 |
+
|
| 1942 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1943 |
+
# there are no flattened fields), or create one.
|
| 1944 |
+
if not isinstance(request, cloud_speech_adaptation.UpdateCustomClassRequest):
|
| 1945 |
+
request = cloud_speech_adaptation.UpdateCustomClassRequest(request)
|
| 1946 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1947 |
+
# request, apply these.
|
| 1948 |
+
if custom_class is not None:
|
| 1949 |
+
request.custom_class = custom_class
|
| 1950 |
+
if update_mask is not None:
|
| 1951 |
+
request.update_mask = update_mask
|
| 1952 |
+
|
| 1953 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1954 |
+
# and friendly error handling.
|
| 1955 |
+
rpc = self._transport._wrapped_methods[self._transport.update_custom_class]
|
| 1956 |
+
|
| 1957 |
+
# Certain fields should be provided within the metadata header;
|
| 1958 |
+
# add these here.
|
| 1959 |
+
metadata = tuple(metadata) + (
|
| 1960 |
+
gapic_v1.routing_header.to_grpc_metadata(
|
| 1961 |
+
(("custom_class.name", request.custom_class.name),)
|
| 1962 |
+
),
|
| 1963 |
+
)
|
| 1964 |
+
|
| 1965 |
+
# Validate the universe domain.
|
| 1966 |
+
self._validate_universe_domain()
|
| 1967 |
+
|
| 1968 |
+
# Send the request.
|
| 1969 |
+
response = rpc(
|
| 1970 |
+
request,
|
| 1971 |
+
retry=retry,
|
| 1972 |
+
timeout=timeout,
|
| 1973 |
+
metadata=metadata,
|
| 1974 |
+
)
|
| 1975 |
+
|
| 1976 |
+
# Done; return the response.
|
| 1977 |
+
return response
|
| 1978 |
+
|
| 1979 |
+
def delete_custom_class(
|
| 1980 |
+
self,
|
| 1981 |
+
request: Optional[
|
| 1982 |
+
Union[cloud_speech_adaptation.DeleteCustomClassRequest, dict]
|
| 1983 |
+
] = None,
|
| 1984 |
+
*,
|
| 1985 |
+
name: Optional[str] = None,
|
| 1986 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1987 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1988 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1989 |
+
) -> None:
|
| 1990 |
+
r"""Delete a custom class.
|
| 1991 |
+
|
| 1992 |
+
.. code-block:: python
|
| 1993 |
+
|
| 1994 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1995 |
+
# code template only.
|
| 1996 |
+
# It will require modifications to work:
|
| 1997 |
+
# - It may require correct/in-range values for request initialization.
|
| 1998 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1999 |
+
# client as shown in:
|
| 2000 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 2001 |
+
from google.cloud import speech_v1p1beta1
|
| 2002 |
+
|
| 2003 |
+
def sample_delete_custom_class():
|
| 2004 |
+
# Create a client
|
| 2005 |
+
client = speech_v1p1beta1.AdaptationClient()
|
| 2006 |
+
|
| 2007 |
+
# Initialize request argument(s)
|
| 2008 |
+
request = speech_v1p1beta1.DeleteCustomClassRequest(
|
| 2009 |
+
name="name_value",
|
| 2010 |
+
)
|
| 2011 |
+
|
| 2012 |
+
# Make the request
|
| 2013 |
+
client.delete_custom_class(request=request)
|
| 2014 |
+
|
| 2015 |
+
Args:
|
| 2016 |
+
request (Union[google.cloud.speech_v1p1beta1.types.DeleteCustomClassRequest, dict]):
|
| 2017 |
+
The request object. Message sent by the client for the ``DeleteCustomClass``
|
| 2018 |
+
method.
|
| 2019 |
+
name (str):
|
| 2020 |
+
Required. The name of the custom class to delete.
|
| 2021 |
+
Format:
|
| 2022 |
+
|
| 2023 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 2024 |
+
|
| 2025 |
+
Speech-to-Text supports three locations: ``global``,
|
| 2026 |
+
``us`` (US North America), and ``eu`` (Europe). If you
|
| 2027 |
+
are calling the ``speech.googleapis.com`` endpoint, use
|
| 2028 |
+
the ``global`` location. To specify a region, use a
|
| 2029 |
+
`regional
|
| 2030 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 2031 |
+
with matching ``us`` or ``eu`` location value.
|
| 2032 |
+
|
| 2033 |
+
This corresponds to the ``name`` field
|
| 2034 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 2035 |
+
should not be set.
|
| 2036 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 2037 |
+
should be retried.
|
| 2038 |
+
timeout (float): The timeout for this request.
|
| 2039 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 2040 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 2041 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 2042 |
+
be of type `bytes`.
|
| 2043 |
+
"""
|
| 2044 |
+
# Create or coerce a protobuf request object.
|
| 2045 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 2046 |
+
# gotten any keyword arguments that map to the request.
|
| 2047 |
+
flattened_params = [name]
|
| 2048 |
+
has_flattened_params = (
|
| 2049 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 2050 |
+
)
|
| 2051 |
+
if request is not None and has_flattened_params:
|
| 2052 |
+
raise ValueError(
|
| 2053 |
+
"If the `request` argument is set, then none of "
|
| 2054 |
+
"the individual field arguments should be set."
|
| 2055 |
+
)
|
| 2056 |
+
|
| 2057 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 2058 |
+
# there are no flattened fields), or create one.
|
| 2059 |
+
if not isinstance(request, cloud_speech_adaptation.DeleteCustomClassRequest):
|
| 2060 |
+
request = cloud_speech_adaptation.DeleteCustomClassRequest(request)
|
| 2061 |
+
# If we have keyword arguments corresponding to fields on the
|
| 2062 |
+
# request, apply these.
|
| 2063 |
+
if name is not None:
|
| 2064 |
+
request.name = name
|
| 2065 |
+
|
| 2066 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 2067 |
+
# and friendly error handling.
|
| 2068 |
+
rpc = self._transport._wrapped_methods[self._transport.delete_custom_class]
|
| 2069 |
+
|
| 2070 |
+
# Certain fields should be provided within the metadata header;
|
| 2071 |
+
# add these here.
|
| 2072 |
+
metadata = tuple(metadata) + (
|
| 2073 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
| 2074 |
+
)
|
| 2075 |
+
|
| 2076 |
+
# Validate the universe domain.
|
| 2077 |
+
self._validate_universe_domain()
|
| 2078 |
+
|
| 2079 |
+
# Send the request.
|
| 2080 |
+
rpc(
|
| 2081 |
+
request,
|
| 2082 |
+
retry=retry,
|
| 2083 |
+
timeout=timeout,
|
| 2084 |
+
metadata=metadata,
|
| 2085 |
+
)
|
| 2086 |
+
|
| 2087 |
+
def __enter__(self) -> "AdaptationClient":
|
| 2088 |
+
return self
|
| 2089 |
+
|
| 2090 |
+
def __exit__(self, type, value, traceback):
|
| 2091 |
+
"""Releases underlying transport's resources.
|
| 2092 |
+
|
| 2093 |
+
.. warning::
|
| 2094 |
+
ONLY use as a context manager if the transport is NOT shared
|
| 2095 |
+
with other clients! Exiting the with block will CLOSE the transport
|
| 2096 |
+
and may cause errors in other clients!
|
| 2097 |
+
"""
|
| 2098 |
+
self.transport.close()
|
| 2099 |
+
|
| 2100 |
+
def list_operations(
|
| 2101 |
+
self,
|
| 2102 |
+
request: Optional[Union[operations_pb2.ListOperationsRequest, dict]] = None,
|
| 2103 |
+
*,
|
| 2104 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 2105 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 2106 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 2107 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 2108 |
+
r"""Lists operations that match the specified filter in the request.
|
| 2109 |
+
|
| 2110 |
+
Args:
|
| 2111 |
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
| 2112 |
+
The request object. Request message for
|
| 2113 |
+
`ListOperations` method.
|
| 2114 |
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
| 2115 |
+
if any, should be retried.
|
| 2116 |
+
timeout (float): The timeout for this request.
|
| 2117 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 2118 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 2119 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 2120 |
+
be of type `bytes`.
|
| 2121 |
+
Returns:
|
| 2122 |
+
~.operations_pb2.ListOperationsResponse:
|
| 2123 |
+
Response message for ``ListOperations`` method.
|
| 2124 |
+
"""
|
| 2125 |
+
# Create or coerce a protobuf request object.
|
| 2126 |
+
# The request isn't a proto-plus wrapped type,
|
| 2127 |
+
# so it must be constructed via keyword expansion.
|
| 2128 |
+
if request is None:
|
| 2129 |
+
request_pb = operations_pb2.ListOperationsRequest()
|
| 2130 |
+
elif isinstance(request, dict):
|
| 2131 |
+
request_pb = operations_pb2.ListOperationsRequest(**request)
|
| 2132 |
+
else:
|
| 2133 |
+
request_pb = request
|
| 2134 |
+
|
| 2135 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 2136 |
+
# and friendly error handling.
|
| 2137 |
+
rpc = self._transport._wrapped_methods[self._transport.list_operations]
|
| 2138 |
+
|
| 2139 |
+
# Certain fields should be provided within the metadata header;
|
| 2140 |
+
# add these here.
|
| 2141 |
+
metadata = tuple(metadata) + (
|
| 2142 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 2143 |
+
)
|
| 2144 |
+
|
| 2145 |
+
# Validate the universe domain.
|
| 2146 |
+
self._validate_universe_domain()
|
| 2147 |
+
|
| 2148 |
+
try:
|
| 2149 |
+
# Send the request.
|
| 2150 |
+
response = rpc(
|
| 2151 |
+
request_pb,
|
| 2152 |
+
retry=retry,
|
| 2153 |
+
timeout=timeout,
|
| 2154 |
+
metadata=metadata,
|
| 2155 |
+
)
|
| 2156 |
+
|
| 2157 |
+
# Done; return the response.
|
| 2158 |
+
return response
|
| 2159 |
+
except core_exceptions.GoogleAPICallError as e:
|
| 2160 |
+
self._add_cred_info_for_auth_errors(e)
|
| 2161 |
+
raise e
|
| 2162 |
+
|
| 2163 |
+
def get_operation(
|
| 2164 |
+
self,
|
| 2165 |
+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
|
| 2166 |
+
*,
|
| 2167 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 2168 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 2169 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 2170 |
+
) -> operations_pb2.Operation:
|
| 2171 |
+
r"""Gets the latest state of a long-running operation.
|
| 2172 |
+
|
| 2173 |
+
Args:
|
| 2174 |
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
| 2175 |
+
The request object. Request message for
|
| 2176 |
+
`GetOperation` method.
|
| 2177 |
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
| 2178 |
+
if any, should be retried.
|
| 2179 |
+
timeout (float): The timeout for this request.
|
| 2180 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 2181 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 2182 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 2183 |
+
be of type `bytes`.
|
| 2184 |
+
Returns:
|
| 2185 |
+
~.operations_pb2.Operation:
|
| 2186 |
+
An ``Operation`` object.
|
| 2187 |
+
"""
|
| 2188 |
+
# Create or coerce a protobuf request object.
|
| 2189 |
+
# The request isn't a proto-plus wrapped type,
|
| 2190 |
+
# so it must be constructed via keyword expansion.
|
| 2191 |
+
if request is None:
|
| 2192 |
+
request_pb = operations_pb2.GetOperationRequest()
|
| 2193 |
+
elif isinstance(request, dict):
|
| 2194 |
+
request_pb = operations_pb2.GetOperationRequest(**request)
|
| 2195 |
+
else:
|
| 2196 |
+
request_pb = request
|
| 2197 |
+
|
| 2198 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 2199 |
+
# and friendly error handling.
|
| 2200 |
+
rpc = self._transport._wrapped_methods[self._transport.get_operation]
|
| 2201 |
+
|
| 2202 |
+
# Certain fields should be provided within the metadata header;
|
| 2203 |
+
# add these here.
|
| 2204 |
+
metadata = tuple(metadata) + (
|
| 2205 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 2206 |
+
)
|
| 2207 |
+
|
| 2208 |
+
# Validate the universe domain.
|
| 2209 |
+
self._validate_universe_domain()
|
| 2210 |
+
|
| 2211 |
+
try:
|
| 2212 |
+
# Send the request.
|
| 2213 |
+
response = rpc(
|
| 2214 |
+
request_pb,
|
| 2215 |
+
retry=retry,
|
| 2216 |
+
timeout=timeout,
|
| 2217 |
+
metadata=metadata,
|
| 2218 |
+
)
|
| 2219 |
+
|
| 2220 |
+
# Done; return the response.
|
| 2221 |
+
return response
|
| 2222 |
+
except core_exceptions.GoogleAPICallError as e:
|
| 2223 |
+
self._add_cred_info_for_auth_errors(e)
|
| 2224 |
+
raise e
|
| 2225 |
+
|
| 2226 |
+
|
| 2227 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 2228 |
+
gapic_version=package_version.__version__
|
| 2229 |
+
)
|
| 2230 |
+
|
| 2231 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 2232 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 2233 |
+
|
| 2234 |
+
__all__ = ("AdaptationClient",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/pagers.py
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from typing import (
|
| 17 |
+
Any,
|
| 18 |
+
AsyncIterator,
|
| 19 |
+
Awaitable,
|
| 20 |
+
Callable,
|
| 21 |
+
Iterator,
|
| 22 |
+
Optional,
|
| 23 |
+
Sequence,
|
| 24 |
+
Tuple,
|
| 25 |
+
Union,
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
from google.api_core import gapic_v1
|
| 29 |
+
from google.api_core import retry as retries
|
| 30 |
+
from google.api_core import retry_async as retries_async
|
| 31 |
+
|
| 32 |
+
try:
|
| 33 |
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
| 34 |
+
OptionalAsyncRetry = Union[
|
| 35 |
+
retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None
|
| 36 |
+
]
|
| 37 |
+
except AttributeError: # pragma: NO COVER
|
| 38 |
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
| 39 |
+
OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore
|
| 40 |
+
|
| 41 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class ListPhraseSetPager:
|
| 45 |
+
"""A pager for iterating through ``list_phrase_set`` requests.
|
| 46 |
+
|
| 47 |
+
This class thinly wraps an initial
|
| 48 |
+
:class:`google.cloud.speech_v1p1beta1.types.ListPhraseSetResponse` object, and
|
| 49 |
+
provides an ``__iter__`` method to iterate through its
|
| 50 |
+
``phrase_sets`` field.
|
| 51 |
+
|
| 52 |
+
If there are more pages, the ``__iter__`` method will make additional
|
| 53 |
+
``ListPhraseSet`` requests and continue to iterate
|
| 54 |
+
through the ``phrase_sets`` field on the
|
| 55 |
+
corresponding responses.
|
| 56 |
+
|
| 57 |
+
All the usual :class:`google.cloud.speech_v1p1beta1.types.ListPhraseSetResponse`
|
| 58 |
+
attributes are available on the pager. If multiple requests are made, only
|
| 59 |
+
the most recent response is retained, and thus used for attribute lookup.
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
+
def __init__(
|
| 63 |
+
self,
|
| 64 |
+
method: Callable[..., cloud_speech_adaptation.ListPhraseSetResponse],
|
| 65 |
+
request: cloud_speech_adaptation.ListPhraseSetRequest,
|
| 66 |
+
response: cloud_speech_adaptation.ListPhraseSetResponse,
|
| 67 |
+
*,
|
| 68 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 69 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 70 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 71 |
+
):
|
| 72 |
+
"""Instantiate the pager.
|
| 73 |
+
|
| 74 |
+
Args:
|
| 75 |
+
method (Callable): The method that was originally called, and
|
| 76 |
+
which instantiated this pager.
|
| 77 |
+
request (google.cloud.speech_v1p1beta1.types.ListPhraseSetRequest):
|
| 78 |
+
The initial request object.
|
| 79 |
+
response (google.cloud.speech_v1p1beta1.types.ListPhraseSetResponse):
|
| 80 |
+
The initial response object.
|
| 81 |
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
| 82 |
+
if any, should be retried.
|
| 83 |
+
timeout (float): The timeout for this request.
|
| 84 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 85 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 86 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 87 |
+
be of type `bytes`.
|
| 88 |
+
"""
|
| 89 |
+
self._method = method
|
| 90 |
+
self._request = cloud_speech_adaptation.ListPhraseSetRequest(request)
|
| 91 |
+
self._response = response
|
| 92 |
+
self._retry = retry
|
| 93 |
+
self._timeout = timeout
|
| 94 |
+
self._metadata = metadata
|
| 95 |
+
|
| 96 |
+
def __getattr__(self, name: str) -> Any:
|
| 97 |
+
return getattr(self._response, name)
|
| 98 |
+
|
| 99 |
+
@property
|
| 100 |
+
def pages(self) -> Iterator[cloud_speech_adaptation.ListPhraseSetResponse]:
|
| 101 |
+
yield self._response
|
| 102 |
+
while self._response.next_page_token:
|
| 103 |
+
self._request.page_token = self._response.next_page_token
|
| 104 |
+
self._response = self._method(
|
| 105 |
+
self._request,
|
| 106 |
+
retry=self._retry,
|
| 107 |
+
timeout=self._timeout,
|
| 108 |
+
metadata=self._metadata,
|
| 109 |
+
)
|
| 110 |
+
yield self._response
|
| 111 |
+
|
| 112 |
+
def __iter__(self) -> Iterator[resource.PhraseSet]:
|
| 113 |
+
for page in self.pages:
|
| 114 |
+
yield from page.phrase_sets
|
| 115 |
+
|
| 116 |
+
def __repr__(self) -> str:
|
| 117 |
+
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
class ListPhraseSetAsyncPager:
|
| 121 |
+
"""A pager for iterating through ``list_phrase_set`` requests.
|
| 122 |
+
|
| 123 |
+
This class thinly wraps an initial
|
| 124 |
+
:class:`google.cloud.speech_v1p1beta1.types.ListPhraseSetResponse` object, and
|
| 125 |
+
provides an ``__aiter__`` method to iterate through its
|
| 126 |
+
``phrase_sets`` field.
|
| 127 |
+
|
| 128 |
+
If there are more pages, the ``__aiter__`` method will make additional
|
| 129 |
+
``ListPhraseSet`` requests and continue to iterate
|
| 130 |
+
through the ``phrase_sets`` field on the
|
| 131 |
+
corresponding responses.
|
| 132 |
+
|
| 133 |
+
All the usual :class:`google.cloud.speech_v1p1beta1.types.ListPhraseSetResponse`
|
| 134 |
+
attributes are available on the pager. If multiple requests are made, only
|
| 135 |
+
the most recent response is retained, and thus used for attribute lookup.
|
| 136 |
+
"""
|
| 137 |
+
|
| 138 |
+
def __init__(
|
| 139 |
+
self,
|
| 140 |
+
method: Callable[..., Awaitable[cloud_speech_adaptation.ListPhraseSetResponse]],
|
| 141 |
+
request: cloud_speech_adaptation.ListPhraseSetRequest,
|
| 142 |
+
response: cloud_speech_adaptation.ListPhraseSetResponse,
|
| 143 |
+
*,
|
| 144 |
+
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
|
| 145 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 146 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 147 |
+
):
|
| 148 |
+
"""Instantiates the pager.
|
| 149 |
+
|
| 150 |
+
Args:
|
| 151 |
+
method (Callable): The method that was originally called, and
|
| 152 |
+
which instantiated this pager.
|
| 153 |
+
request (google.cloud.speech_v1p1beta1.types.ListPhraseSetRequest):
|
| 154 |
+
The initial request object.
|
| 155 |
+
response (google.cloud.speech_v1p1beta1.types.ListPhraseSetResponse):
|
| 156 |
+
The initial response object.
|
| 157 |
+
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
|
| 158 |
+
if any, should be retried.
|
| 159 |
+
timeout (float): The timeout for this request.
|
| 160 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 161 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 162 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 163 |
+
be of type `bytes`.
|
| 164 |
+
"""
|
| 165 |
+
self._method = method
|
| 166 |
+
self._request = cloud_speech_adaptation.ListPhraseSetRequest(request)
|
| 167 |
+
self._response = response
|
| 168 |
+
self._retry = retry
|
| 169 |
+
self._timeout = timeout
|
| 170 |
+
self._metadata = metadata
|
| 171 |
+
|
| 172 |
+
def __getattr__(self, name: str) -> Any:
|
| 173 |
+
return getattr(self._response, name)
|
| 174 |
+
|
| 175 |
+
@property
|
| 176 |
+
async def pages(
|
| 177 |
+
self,
|
| 178 |
+
) -> AsyncIterator[cloud_speech_adaptation.ListPhraseSetResponse]:
|
| 179 |
+
yield self._response
|
| 180 |
+
while self._response.next_page_token:
|
| 181 |
+
self._request.page_token = self._response.next_page_token
|
| 182 |
+
self._response = await self._method(
|
| 183 |
+
self._request,
|
| 184 |
+
retry=self._retry,
|
| 185 |
+
timeout=self._timeout,
|
| 186 |
+
metadata=self._metadata,
|
| 187 |
+
)
|
| 188 |
+
yield self._response
|
| 189 |
+
|
| 190 |
+
def __aiter__(self) -> AsyncIterator[resource.PhraseSet]:
|
| 191 |
+
async def async_generator():
|
| 192 |
+
async for page in self.pages:
|
| 193 |
+
for response in page.phrase_sets:
|
| 194 |
+
yield response
|
| 195 |
+
|
| 196 |
+
return async_generator()
|
| 197 |
+
|
| 198 |
+
def __repr__(self) -> str:
|
| 199 |
+
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class ListCustomClassesPager:
|
| 203 |
+
"""A pager for iterating through ``list_custom_classes`` requests.
|
| 204 |
+
|
| 205 |
+
This class thinly wraps an initial
|
| 206 |
+
:class:`google.cloud.speech_v1p1beta1.types.ListCustomClassesResponse` object, and
|
| 207 |
+
provides an ``__iter__`` method to iterate through its
|
| 208 |
+
``custom_classes`` field.
|
| 209 |
+
|
| 210 |
+
If there are more pages, the ``__iter__`` method will make additional
|
| 211 |
+
``ListCustomClasses`` requests and continue to iterate
|
| 212 |
+
through the ``custom_classes`` field on the
|
| 213 |
+
corresponding responses.
|
| 214 |
+
|
| 215 |
+
All the usual :class:`google.cloud.speech_v1p1beta1.types.ListCustomClassesResponse`
|
| 216 |
+
attributes are available on the pager. If multiple requests are made, only
|
| 217 |
+
the most recent response is retained, and thus used for attribute lookup.
|
| 218 |
+
"""
|
| 219 |
+
|
| 220 |
+
def __init__(
|
| 221 |
+
self,
|
| 222 |
+
method: Callable[..., cloud_speech_adaptation.ListCustomClassesResponse],
|
| 223 |
+
request: cloud_speech_adaptation.ListCustomClassesRequest,
|
| 224 |
+
response: cloud_speech_adaptation.ListCustomClassesResponse,
|
| 225 |
+
*,
|
| 226 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 227 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 228 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 229 |
+
):
|
| 230 |
+
"""Instantiate the pager.
|
| 231 |
+
|
| 232 |
+
Args:
|
| 233 |
+
method (Callable): The method that was originally called, and
|
| 234 |
+
which instantiated this pager.
|
| 235 |
+
request (google.cloud.speech_v1p1beta1.types.ListCustomClassesRequest):
|
| 236 |
+
The initial request object.
|
| 237 |
+
response (google.cloud.speech_v1p1beta1.types.ListCustomClassesResponse):
|
| 238 |
+
The initial response object.
|
| 239 |
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
| 240 |
+
if any, should be retried.
|
| 241 |
+
timeout (float): The timeout for this request.
|
| 242 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 243 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 244 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 245 |
+
be of type `bytes`.
|
| 246 |
+
"""
|
| 247 |
+
self._method = method
|
| 248 |
+
self._request = cloud_speech_adaptation.ListCustomClassesRequest(request)
|
| 249 |
+
self._response = response
|
| 250 |
+
self._retry = retry
|
| 251 |
+
self._timeout = timeout
|
| 252 |
+
self._metadata = metadata
|
| 253 |
+
|
| 254 |
+
def __getattr__(self, name: str) -> Any:
|
| 255 |
+
return getattr(self._response, name)
|
| 256 |
+
|
| 257 |
+
@property
|
| 258 |
+
def pages(self) -> Iterator[cloud_speech_adaptation.ListCustomClassesResponse]:
|
| 259 |
+
yield self._response
|
| 260 |
+
while self._response.next_page_token:
|
| 261 |
+
self._request.page_token = self._response.next_page_token
|
| 262 |
+
self._response = self._method(
|
| 263 |
+
self._request,
|
| 264 |
+
retry=self._retry,
|
| 265 |
+
timeout=self._timeout,
|
| 266 |
+
metadata=self._metadata,
|
| 267 |
+
)
|
| 268 |
+
yield self._response
|
| 269 |
+
|
| 270 |
+
def __iter__(self) -> Iterator[resource.CustomClass]:
|
| 271 |
+
for page in self.pages:
|
| 272 |
+
yield from page.custom_classes
|
| 273 |
+
|
| 274 |
+
def __repr__(self) -> str:
|
| 275 |
+
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
class ListCustomClassesAsyncPager:
|
| 279 |
+
"""A pager for iterating through ``list_custom_classes`` requests.
|
| 280 |
+
|
| 281 |
+
This class thinly wraps an initial
|
| 282 |
+
:class:`google.cloud.speech_v1p1beta1.types.ListCustomClassesResponse` object, and
|
| 283 |
+
provides an ``__aiter__`` method to iterate through its
|
| 284 |
+
``custom_classes`` field.
|
| 285 |
+
|
| 286 |
+
If there are more pages, the ``__aiter__`` method will make additional
|
| 287 |
+
``ListCustomClasses`` requests and continue to iterate
|
| 288 |
+
through the ``custom_classes`` field on the
|
| 289 |
+
corresponding responses.
|
| 290 |
+
|
| 291 |
+
All the usual :class:`google.cloud.speech_v1p1beta1.types.ListCustomClassesResponse`
|
| 292 |
+
attributes are available on the pager. If multiple requests are made, only
|
| 293 |
+
the most recent response is retained, and thus used for attribute lookup.
|
| 294 |
+
"""
|
| 295 |
+
|
| 296 |
+
def __init__(
|
| 297 |
+
self,
|
| 298 |
+
method: Callable[
|
| 299 |
+
..., Awaitable[cloud_speech_adaptation.ListCustomClassesResponse]
|
| 300 |
+
],
|
| 301 |
+
request: cloud_speech_adaptation.ListCustomClassesRequest,
|
| 302 |
+
response: cloud_speech_adaptation.ListCustomClassesResponse,
|
| 303 |
+
*,
|
| 304 |
+
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
|
| 305 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 306 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 307 |
+
):
|
| 308 |
+
"""Instantiates the pager.
|
| 309 |
+
|
| 310 |
+
Args:
|
| 311 |
+
method (Callable): The method that was originally called, and
|
| 312 |
+
which instantiated this pager.
|
| 313 |
+
request (google.cloud.speech_v1p1beta1.types.ListCustomClassesRequest):
|
| 314 |
+
The initial request object.
|
| 315 |
+
response (google.cloud.speech_v1p1beta1.types.ListCustomClassesResponse):
|
| 316 |
+
The initial response object.
|
| 317 |
+
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
|
| 318 |
+
if any, should be retried.
|
| 319 |
+
timeout (float): The timeout for this request.
|
| 320 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 321 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 322 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 323 |
+
be of type `bytes`.
|
| 324 |
+
"""
|
| 325 |
+
self._method = method
|
| 326 |
+
self._request = cloud_speech_adaptation.ListCustomClassesRequest(request)
|
| 327 |
+
self._response = response
|
| 328 |
+
self._retry = retry
|
| 329 |
+
self._timeout = timeout
|
| 330 |
+
self._metadata = metadata
|
| 331 |
+
|
| 332 |
+
def __getattr__(self, name: str) -> Any:
|
| 333 |
+
return getattr(self._response, name)
|
| 334 |
+
|
| 335 |
+
@property
|
| 336 |
+
async def pages(
|
| 337 |
+
self,
|
| 338 |
+
) -> AsyncIterator[cloud_speech_adaptation.ListCustomClassesResponse]:
|
| 339 |
+
yield self._response
|
| 340 |
+
while self._response.next_page_token:
|
| 341 |
+
self._request.page_token = self._response.next_page_token
|
| 342 |
+
self._response = await self._method(
|
| 343 |
+
self._request,
|
| 344 |
+
retry=self._retry,
|
| 345 |
+
timeout=self._timeout,
|
| 346 |
+
metadata=self._metadata,
|
| 347 |
+
)
|
| 348 |
+
yield self._response
|
| 349 |
+
|
| 350 |
+
def __aiter__(self) -> AsyncIterator[resource.CustomClass]:
|
| 351 |
+
async def async_generator():
|
| 352 |
+
async for page in self.pages:
|
| 353 |
+
for response in page.custom_classes:
|
| 354 |
+
yield response
|
| 355 |
+
|
| 356 |
+
return async_generator()
|
| 357 |
+
|
| 358 |
+
def __repr__(self) -> str:
|
| 359 |
+
return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from collections import OrderedDict
|
| 17 |
+
from typing import Dict, Type
|
| 18 |
+
|
| 19 |
+
from .base import AdaptationTransport
|
| 20 |
+
from .grpc import AdaptationGrpcTransport
|
| 21 |
+
from .grpc_asyncio import AdaptationGrpcAsyncIOTransport
|
| 22 |
+
from .rest import AdaptationRestInterceptor, AdaptationRestTransport
|
| 23 |
+
|
| 24 |
+
# Compile a registry of transports.
|
| 25 |
+
_transport_registry = OrderedDict() # type: Dict[str, Type[AdaptationTransport]]
|
| 26 |
+
_transport_registry["grpc"] = AdaptationGrpcTransport
|
| 27 |
+
_transport_registry["grpc_asyncio"] = AdaptationGrpcAsyncIOTransport
|
| 28 |
+
_transport_registry["rest"] = AdaptationRestTransport
|
| 29 |
+
|
| 30 |
+
__all__ = (
|
| 31 |
+
"AdaptationTransport",
|
| 32 |
+
"AdaptationGrpcTransport",
|
| 33 |
+
"AdaptationGrpcAsyncIOTransport",
|
| 34 |
+
"AdaptationRestTransport",
|
| 35 |
+
"AdaptationRestInterceptor",
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import abc
|
| 17 |
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
|
| 18 |
+
|
| 19 |
+
import google.api_core
|
| 20 |
+
import google.auth # type: ignore
|
| 21 |
+
import google.protobuf
|
| 22 |
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
| 23 |
+
from google.api_core import exceptions as core_exceptions
|
| 24 |
+
from google.api_core import gapic_v1
|
| 25 |
+
from google.api_core import retry as retries
|
| 26 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 27 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 28 |
+
from google.oauth2 import service_account # type: ignore
|
| 29 |
+
|
| 30 |
+
from google.cloud.speech_v1p1beta1 import gapic_version as package_version
|
| 31 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
|
| 32 |
+
|
| 33 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 34 |
+
gapic_version=package_version.__version__
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 38 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class AdaptationTransport(abc.ABC):
|
| 42 |
+
"""Abstract transport class for Adaptation."""
|
| 43 |
+
|
| 44 |
+
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
|
| 45 |
+
|
| 46 |
+
DEFAULT_HOST: str = "speech.googleapis.com"
|
| 47 |
+
|
| 48 |
+
def __init__(
|
| 49 |
+
self,
|
| 50 |
+
*,
|
| 51 |
+
host: str = DEFAULT_HOST,
|
| 52 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 53 |
+
credentials_file: Optional[str] = None,
|
| 54 |
+
scopes: Optional[Sequence[str]] = None,
|
| 55 |
+
quota_project_id: Optional[str] = None,
|
| 56 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 57 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 58 |
+
api_audience: Optional[str] = None,
|
| 59 |
+
**kwargs,
|
| 60 |
+
) -> None:
|
| 61 |
+
"""Instantiate the transport.
|
| 62 |
+
|
| 63 |
+
Args:
|
| 64 |
+
host (Optional[str]):
|
| 65 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 66 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 67 |
+
authorization credentials to attach to requests. These
|
| 68 |
+
credentials identify the application to the service; if none
|
| 69 |
+
are specified, the client will attempt to ascertain the
|
| 70 |
+
credentials from the environment.
|
| 71 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 72 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 73 |
+
This argument is mutually exclusive with credentials. This argument will be
|
| 74 |
+
removed in the next major version of this library.
|
| 75 |
+
scopes (Optional[Sequence[str]]): A list of scopes.
|
| 76 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 77 |
+
and quota.
|
| 78 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 79 |
+
The client info used to send a user-agent string along with
|
| 80 |
+
API requests. If ``None``, then default info will be used.
|
| 81 |
+
Generally, you only need to set this if you're developing
|
| 82 |
+
your own client library.
|
| 83 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 84 |
+
be used for service account credentials.
|
| 85 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 86 |
+
to the service that will be set when using certain 3rd party
|
| 87 |
+
authentication flows. Audience is typically a resource identifier.
|
| 88 |
+
If not set, the host value will be used as a default.
|
| 89 |
+
"""
|
| 90 |
+
|
| 91 |
+
# Save the scopes.
|
| 92 |
+
self._scopes = scopes
|
| 93 |
+
if not hasattr(self, "_ignore_credentials"):
|
| 94 |
+
self._ignore_credentials: bool = False
|
| 95 |
+
|
| 96 |
+
# If no credentials are provided, then determine the appropriate
|
| 97 |
+
# defaults.
|
| 98 |
+
if credentials and credentials_file:
|
| 99 |
+
raise core_exceptions.DuplicateCredentialArgs(
|
| 100 |
+
"'credentials_file' and 'credentials' are mutually exclusive"
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
if credentials_file is not None:
|
| 104 |
+
credentials, _ = google.auth.load_credentials_from_file(
|
| 105 |
+
credentials_file,
|
| 106 |
+
scopes=scopes,
|
| 107 |
+
quota_project_id=quota_project_id,
|
| 108 |
+
default_scopes=self.AUTH_SCOPES,
|
| 109 |
+
)
|
| 110 |
+
elif credentials is None and not self._ignore_credentials:
|
| 111 |
+
credentials, _ = google.auth.default(
|
| 112 |
+
scopes=scopes,
|
| 113 |
+
quota_project_id=quota_project_id,
|
| 114 |
+
default_scopes=self.AUTH_SCOPES,
|
| 115 |
+
)
|
| 116 |
+
# Don't apply audience if the credentials file passed from user.
|
| 117 |
+
if hasattr(credentials, "with_gdch_audience"):
|
| 118 |
+
credentials = credentials.with_gdch_audience(
|
| 119 |
+
api_audience if api_audience else host
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
# If the credentials are service account credentials, then always try to use self signed JWT.
|
| 123 |
+
if (
|
| 124 |
+
always_use_jwt_access
|
| 125 |
+
and isinstance(credentials, service_account.Credentials)
|
| 126 |
+
and hasattr(service_account.Credentials, "with_always_use_jwt_access")
|
| 127 |
+
):
|
| 128 |
+
credentials = credentials.with_always_use_jwt_access(True)
|
| 129 |
+
|
| 130 |
+
# Save the credentials.
|
| 131 |
+
self._credentials = credentials
|
| 132 |
+
|
| 133 |
+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
|
| 134 |
+
if ":" not in host:
|
| 135 |
+
host += ":443"
|
| 136 |
+
self._host = host
|
| 137 |
+
|
| 138 |
+
self._wrapped_methods: Dict[Callable, Callable] = {}
|
| 139 |
+
|
| 140 |
+
@property
|
| 141 |
+
def host(self):
|
| 142 |
+
return self._host
|
| 143 |
+
|
| 144 |
+
def _prep_wrapped_messages(self, client_info):
|
| 145 |
+
# Precompute the wrapped methods.
|
| 146 |
+
self._wrapped_methods = {
|
| 147 |
+
self.create_phrase_set: gapic_v1.method.wrap_method(
|
| 148 |
+
self.create_phrase_set,
|
| 149 |
+
default_timeout=None,
|
| 150 |
+
client_info=client_info,
|
| 151 |
+
),
|
| 152 |
+
self.get_phrase_set: gapic_v1.method.wrap_method(
|
| 153 |
+
self.get_phrase_set,
|
| 154 |
+
default_timeout=None,
|
| 155 |
+
client_info=client_info,
|
| 156 |
+
),
|
| 157 |
+
self.list_phrase_set: gapic_v1.method.wrap_method(
|
| 158 |
+
self.list_phrase_set,
|
| 159 |
+
default_timeout=None,
|
| 160 |
+
client_info=client_info,
|
| 161 |
+
),
|
| 162 |
+
self.update_phrase_set: gapic_v1.method.wrap_method(
|
| 163 |
+
self.update_phrase_set,
|
| 164 |
+
default_timeout=None,
|
| 165 |
+
client_info=client_info,
|
| 166 |
+
),
|
| 167 |
+
self.delete_phrase_set: gapic_v1.method.wrap_method(
|
| 168 |
+
self.delete_phrase_set,
|
| 169 |
+
default_timeout=None,
|
| 170 |
+
client_info=client_info,
|
| 171 |
+
),
|
| 172 |
+
self.create_custom_class: gapic_v1.method.wrap_method(
|
| 173 |
+
self.create_custom_class,
|
| 174 |
+
default_timeout=None,
|
| 175 |
+
client_info=client_info,
|
| 176 |
+
),
|
| 177 |
+
self.get_custom_class: gapic_v1.method.wrap_method(
|
| 178 |
+
self.get_custom_class,
|
| 179 |
+
default_timeout=None,
|
| 180 |
+
client_info=client_info,
|
| 181 |
+
),
|
| 182 |
+
self.list_custom_classes: gapic_v1.method.wrap_method(
|
| 183 |
+
self.list_custom_classes,
|
| 184 |
+
default_timeout=None,
|
| 185 |
+
client_info=client_info,
|
| 186 |
+
),
|
| 187 |
+
self.update_custom_class: gapic_v1.method.wrap_method(
|
| 188 |
+
self.update_custom_class,
|
| 189 |
+
default_timeout=None,
|
| 190 |
+
client_info=client_info,
|
| 191 |
+
),
|
| 192 |
+
self.delete_custom_class: gapic_v1.method.wrap_method(
|
| 193 |
+
self.delete_custom_class,
|
| 194 |
+
default_timeout=None,
|
| 195 |
+
client_info=client_info,
|
| 196 |
+
),
|
| 197 |
+
self.get_operation: gapic_v1.method.wrap_method(
|
| 198 |
+
self.get_operation,
|
| 199 |
+
default_timeout=None,
|
| 200 |
+
client_info=client_info,
|
| 201 |
+
),
|
| 202 |
+
self.list_operations: gapic_v1.method.wrap_method(
|
| 203 |
+
self.list_operations,
|
| 204 |
+
default_timeout=None,
|
| 205 |
+
client_info=client_info,
|
| 206 |
+
),
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
def close(self):
|
| 210 |
+
"""Closes resources associated with the transport.
|
| 211 |
+
|
| 212 |
+
.. warning::
|
| 213 |
+
Only call this method if the transport is NOT shared
|
| 214 |
+
with other clients - this may cause errors in other clients!
|
| 215 |
+
"""
|
| 216 |
+
raise NotImplementedError()
|
| 217 |
+
|
| 218 |
+
@property
|
| 219 |
+
def create_phrase_set(
|
| 220 |
+
self,
|
| 221 |
+
) -> Callable[
|
| 222 |
+
[cloud_speech_adaptation.CreatePhraseSetRequest],
|
| 223 |
+
Union[resource.PhraseSet, Awaitable[resource.PhraseSet]],
|
| 224 |
+
]:
|
| 225 |
+
raise NotImplementedError()
|
| 226 |
+
|
| 227 |
+
@property
|
| 228 |
+
def get_phrase_set(
|
| 229 |
+
self,
|
| 230 |
+
) -> Callable[
|
| 231 |
+
[cloud_speech_adaptation.GetPhraseSetRequest],
|
| 232 |
+
Union[resource.PhraseSet, Awaitable[resource.PhraseSet]],
|
| 233 |
+
]:
|
| 234 |
+
raise NotImplementedError()
|
| 235 |
+
|
| 236 |
+
@property
|
| 237 |
+
def list_phrase_set(
|
| 238 |
+
self,
|
| 239 |
+
) -> Callable[
|
| 240 |
+
[cloud_speech_adaptation.ListPhraseSetRequest],
|
| 241 |
+
Union[
|
| 242 |
+
cloud_speech_adaptation.ListPhraseSetResponse,
|
| 243 |
+
Awaitable[cloud_speech_adaptation.ListPhraseSetResponse],
|
| 244 |
+
],
|
| 245 |
+
]:
|
| 246 |
+
raise NotImplementedError()
|
| 247 |
+
|
| 248 |
+
@property
|
| 249 |
+
def update_phrase_set(
|
| 250 |
+
self,
|
| 251 |
+
) -> Callable[
|
| 252 |
+
[cloud_speech_adaptation.UpdatePhraseSetRequest],
|
| 253 |
+
Union[resource.PhraseSet, Awaitable[resource.PhraseSet]],
|
| 254 |
+
]:
|
| 255 |
+
raise NotImplementedError()
|
| 256 |
+
|
| 257 |
+
@property
|
| 258 |
+
def delete_phrase_set(
|
| 259 |
+
self,
|
| 260 |
+
) -> Callable[
|
| 261 |
+
[cloud_speech_adaptation.DeletePhraseSetRequest],
|
| 262 |
+
Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]],
|
| 263 |
+
]:
|
| 264 |
+
raise NotImplementedError()
|
| 265 |
+
|
| 266 |
+
@property
|
| 267 |
+
def create_custom_class(
|
| 268 |
+
self,
|
| 269 |
+
) -> Callable[
|
| 270 |
+
[cloud_speech_adaptation.CreateCustomClassRequest],
|
| 271 |
+
Union[resource.CustomClass, Awaitable[resource.CustomClass]],
|
| 272 |
+
]:
|
| 273 |
+
raise NotImplementedError()
|
| 274 |
+
|
| 275 |
+
@property
|
| 276 |
+
def get_custom_class(
|
| 277 |
+
self,
|
| 278 |
+
) -> Callable[
|
| 279 |
+
[cloud_speech_adaptation.GetCustomClassRequest],
|
| 280 |
+
Union[resource.CustomClass, Awaitable[resource.CustomClass]],
|
| 281 |
+
]:
|
| 282 |
+
raise NotImplementedError()
|
| 283 |
+
|
| 284 |
+
@property
|
| 285 |
+
def list_custom_classes(
|
| 286 |
+
self,
|
| 287 |
+
) -> Callable[
|
| 288 |
+
[cloud_speech_adaptation.ListCustomClassesRequest],
|
| 289 |
+
Union[
|
| 290 |
+
cloud_speech_adaptation.ListCustomClassesResponse,
|
| 291 |
+
Awaitable[cloud_speech_adaptation.ListCustomClassesResponse],
|
| 292 |
+
],
|
| 293 |
+
]:
|
| 294 |
+
raise NotImplementedError()
|
| 295 |
+
|
| 296 |
+
@property
|
| 297 |
+
def update_custom_class(
|
| 298 |
+
self,
|
| 299 |
+
) -> Callable[
|
| 300 |
+
[cloud_speech_adaptation.UpdateCustomClassRequest],
|
| 301 |
+
Union[resource.CustomClass, Awaitable[resource.CustomClass]],
|
| 302 |
+
]:
|
| 303 |
+
raise NotImplementedError()
|
| 304 |
+
|
| 305 |
+
@property
|
| 306 |
+
def delete_custom_class(
|
| 307 |
+
self,
|
| 308 |
+
) -> Callable[
|
| 309 |
+
[cloud_speech_adaptation.DeleteCustomClassRequest],
|
| 310 |
+
Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]],
|
| 311 |
+
]:
|
| 312 |
+
raise NotImplementedError()
|
| 313 |
+
|
| 314 |
+
@property
|
| 315 |
+
def list_operations(
|
| 316 |
+
self,
|
| 317 |
+
) -> Callable[
|
| 318 |
+
[operations_pb2.ListOperationsRequest],
|
| 319 |
+
Union[
|
| 320 |
+
operations_pb2.ListOperationsResponse,
|
| 321 |
+
Awaitable[operations_pb2.ListOperationsResponse],
|
| 322 |
+
],
|
| 323 |
+
]:
|
| 324 |
+
raise NotImplementedError()
|
| 325 |
+
|
| 326 |
+
@property
|
| 327 |
+
def get_operation(
|
| 328 |
+
self,
|
| 329 |
+
) -> Callable[
|
| 330 |
+
[operations_pb2.GetOperationRequest],
|
| 331 |
+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
|
| 332 |
+
]:
|
| 333 |
+
raise NotImplementedError()
|
| 334 |
+
|
| 335 |
+
@property
|
| 336 |
+
def kind(self) -> str:
|
| 337 |
+
raise NotImplementedError()
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
__all__ = ("AdaptationTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc.py
ADDED
|
@@ -0,0 +1,649 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json
|
| 17 |
+
import logging as std_logging
|
| 18 |
+
import pickle
|
| 19 |
+
import warnings
|
| 20 |
+
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
|
| 21 |
+
|
| 22 |
+
import google.auth # type: ignore
|
| 23 |
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
| 24 |
+
import google.protobuf.message
|
| 25 |
+
import grpc # type: ignore
|
| 26 |
+
import proto # type: ignore
|
| 27 |
+
from google.api_core import gapic_v1, grpc_helpers
|
| 28 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 29 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 30 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 31 |
+
from google.protobuf.json_format import MessageToJson
|
| 32 |
+
|
| 33 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
|
| 34 |
+
|
| 35 |
+
from .base import DEFAULT_CLIENT_INFO, AdaptationTransport
|
| 36 |
+
|
| 37 |
+
try:
|
| 38 |
+
from google.api_core import client_logging # type: ignore
|
| 39 |
+
|
| 40 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 41 |
+
except ImportError: # pragma: NO COVER
|
| 42 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 43 |
+
|
| 44 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
|
| 48 |
+
def intercept_unary_unary(self, continuation, client_call_details, request):
|
| 49 |
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 50 |
+
std_logging.DEBUG
|
| 51 |
+
)
|
| 52 |
+
if logging_enabled: # pragma: NO COVER
|
| 53 |
+
request_metadata = client_call_details.metadata
|
| 54 |
+
if isinstance(request, proto.Message):
|
| 55 |
+
request_payload = type(request).to_json(request)
|
| 56 |
+
elif isinstance(request, google.protobuf.message.Message):
|
| 57 |
+
request_payload = MessageToJson(request)
|
| 58 |
+
else:
|
| 59 |
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
|
| 60 |
+
|
| 61 |
+
request_metadata = {
|
| 62 |
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
| 63 |
+
for key, value in request_metadata
|
| 64 |
+
}
|
| 65 |
+
grpc_request = {
|
| 66 |
+
"payload": request_payload,
|
| 67 |
+
"requestMethod": "grpc",
|
| 68 |
+
"metadata": dict(request_metadata),
|
| 69 |
+
}
|
| 70 |
+
_LOGGER.debug(
|
| 71 |
+
f"Sending request for {client_call_details.method}",
|
| 72 |
+
extra={
|
| 73 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Adaptation",
|
| 74 |
+
"rpcName": str(client_call_details.method),
|
| 75 |
+
"request": grpc_request,
|
| 76 |
+
"metadata": grpc_request["metadata"],
|
| 77 |
+
},
|
| 78 |
+
)
|
| 79 |
+
response = continuation(client_call_details, request)
|
| 80 |
+
if logging_enabled: # pragma: NO COVER
|
| 81 |
+
response_metadata = response.trailing_metadata()
|
| 82 |
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
| 83 |
+
metadata = (
|
| 84 |
+
dict([(k, str(v)) for k, v in response_metadata])
|
| 85 |
+
if response_metadata
|
| 86 |
+
else None
|
| 87 |
+
)
|
| 88 |
+
result = response.result()
|
| 89 |
+
if isinstance(result, proto.Message):
|
| 90 |
+
response_payload = type(result).to_json(result)
|
| 91 |
+
elif isinstance(result, google.protobuf.message.Message):
|
| 92 |
+
response_payload = MessageToJson(result)
|
| 93 |
+
else:
|
| 94 |
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
|
| 95 |
+
grpc_response = {
|
| 96 |
+
"payload": response_payload,
|
| 97 |
+
"metadata": metadata,
|
| 98 |
+
"status": "OK",
|
| 99 |
+
}
|
| 100 |
+
_LOGGER.debug(
|
| 101 |
+
f"Received response for {client_call_details.method}.",
|
| 102 |
+
extra={
|
| 103 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Adaptation",
|
| 104 |
+
"rpcName": client_call_details.method,
|
| 105 |
+
"response": grpc_response,
|
| 106 |
+
"metadata": grpc_response["metadata"],
|
| 107 |
+
},
|
| 108 |
+
)
|
| 109 |
+
return response
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class AdaptationGrpcTransport(AdaptationTransport):
|
| 113 |
+
"""gRPC backend transport for Adaptation.
|
| 114 |
+
|
| 115 |
+
Service that implements Google Cloud Speech Adaptation API.
|
| 116 |
+
|
| 117 |
+
This class defines the same methods as the primary client, so the
|
| 118 |
+
primary client can load the underlying transport implementation
|
| 119 |
+
and call it.
|
| 120 |
+
|
| 121 |
+
It sends protocol buffers over the wire using gRPC (which is built on
|
| 122 |
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
| 123 |
+
"""
|
| 124 |
+
|
| 125 |
+
_stubs: Dict[str, Callable]
|
| 126 |
+
|
| 127 |
+
def __init__(
|
| 128 |
+
self,
|
| 129 |
+
*,
|
| 130 |
+
host: str = "speech.googleapis.com",
|
| 131 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 132 |
+
credentials_file: Optional[str] = None,
|
| 133 |
+
scopes: Optional[Sequence[str]] = None,
|
| 134 |
+
channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
|
| 135 |
+
api_mtls_endpoint: Optional[str] = None,
|
| 136 |
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 137 |
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
| 138 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 139 |
+
quota_project_id: Optional[str] = None,
|
| 140 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 141 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 142 |
+
api_audience: Optional[str] = None,
|
| 143 |
+
) -> None:
|
| 144 |
+
"""Instantiate the transport.
|
| 145 |
+
|
| 146 |
+
Args:
|
| 147 |
+
host (Optional[str]):
|
| 148 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 149 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 150 |
+
authorization credentials to attach to requests. These
|
| 151 |
+
credentials identify the application to the service; if none
|
| 152 |
+
are specified, the client will attempt to ascertain the
|
| 153 |
+
credentials from the environment.
|
| 154 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 155 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 156 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 157 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 158 |
+
This argument will be removed in the next major version of this library.
|
| 159 |
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
| 160 |
+
ignored if a ``channel`` instance is provided.
|
| 161 |
+
channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
|
| 162 |
+
A ``Channel`` instance through which to make calls, or a Callable
|
| 163 |
+
that constructs and returns one. If set to None, ``self.create_channel``
|
| 164 |
+
is used to create the channel. If a Callable is given, it will be called
|
| 165 |
+
with the same arguments as used in ``self.create_channel``.
|
| 166 |
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
| 167 |
+
If provided, it overrides the ``host`` argument and tries to create
|
| 168 |
+
a mutual TLS channel with client SSL credentials from
|
| 169 |
+
``client_cert_source`` or application default SSL credentials.
|
| 170 |
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 171 |
+
Deprecated. A callback to provide client SSL certificate bytes and
|
| 172 |
+
private key bytes, both in PEM format. It is ignored if
|
| 173 |
+
``api_mtls_endpoint`` is None.
|
| 174 |
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
| 175 |
+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
|
| 176 |
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 177 |
+
A callback to provide client certificate bytes and private key bytes,
|
| 178 |
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
| 179 |
+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
|
| 180 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 181 |
+
and quota.
|
| 182 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 183 |
+
The client info used to send a user-agent string along with
|
| 184 |
+
API requests. If ``None``, then default info will be used.
|
| 185 |
+
Generally, you only need to set this if you're developing
|
| 186 |
+
your own client library.
|
| 187 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 188 |
+
be used for service account credentials.
|
| 189 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 190 |
+
to the service that will be set when using certain 3rd party
|
| 191 |
+
authentication flows. Audience is typically a resource identifier.
|
| 192 |
+
If not set, the host value will be used as a default.
|
| 193 |
+
|
| 194 |
+
Raises:
|
| 195 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 196 |
+
creation failed for any reason.
|
| 197 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 198 |
+
and ``credentials_file`` are passed.
|
| 199 |
+
"""
|
| 200 |
+
self._grpc_channel = None
|
| 201 |
+
self._ssl_channel_credentials = ssl_channel_credentials
|
| 202 |
+
self._stubs: Dict[str, Callable] = {}
|
| 203 |
+
|
| 204 |
+
if api_mtls_endpoint:
|
| 205 |
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
| 206 |
+
if client_cert_source:
|
| 207 |
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
| 208 |
+
|
| 209 |
+
if isinstance(channel, grpc.Channel):
|
| 210 |
+
# Ignore credentials if a channel was passed.
|
| 211 |
+
credentials = None
|
| 212 |
+
self._ignore_credentials = True
|
| 213 |
+
# If a channel was explicitly provided, set it.
|
| 214 |
+
self._grpc_channel = channel
|
| 215 |
+
self._ssl_channel_credentials = None
|
| 216 |
+
|
| 217 |
+
else:
|
| 218 |
+
if api_mtls_endpoint:
|
| 219 |
+
host = api_mtls_endpoint
|
| 220 |
+
|
| 221 |
+
# Create SSL credentials with client_cert_source or application
|
| 222 |
+
# default SSL credentials.
|
| 223 |
+
if client_cert_source:
|
| 224 |
+
cert, key = client_cert_source()
|
| 225 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 226 |
+
certificate_chain=cert, private_key=key
|
| 227 |
+
)
|
| 228 |
+
else:
|
| 229 |
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
| 230 |
+
|
| 231 |
+
else:
|
| 232 |
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
| 233 |
+
cert, key = client_cert_source_for_mtls()
|
| 234 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 235 |
+
certificate_chain=cert, private_key=key
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
# The base transport sets the host, credentials and scopes
|
| 239 |
+
super().__init__(
|
| 240 |
+
host=host,
|
| 241 |
+
credentials=credentials,
|
| 242 |
+
credentials_file=credentials_file,
|
| 243 |
+
scopes=scopes,
|
| 244 |
+
quota_project_id=quota_project_id,
|
| 245 |
+
client_info=client_info,
|
| 246 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 247 |
+
api_audience=api_audience,
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
if not self._grpc_channel:
|
| 251 |
+
# initialize with the provided callable or the default channel
|
| 252 |
+
channel_init = channel or type(self).create_channel
|
| 253 |
+
self._grpc_channel = channel_init(
|
| 254 |
+
self._host,
|
| 255 |
+
# use the credentials which are saved
|
| 256 |
+
credentials=self._credentials,
|
| 257 |
+
# Set ``credentials_file`` to ``None`` here as
|
| 258 |
+
# the credentials that we saved earlier should be used.
|
| 259 |
+
credentials_file=None,
|
| 260 |
+
scopes=self._scopes,
|
| 261 |
+
ssl_credentials=self._ssl_channel_credentials,
|
| 262 |
+
quota_project_id=quota_project_id,
|
| 263 |
+
options=[
|
| 264 |
+
("grpc.max_send_message_length", -1),
|
| 265 |
+
("grpc.max_receive_message_length", -1),
|
| 266 |
+
],
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
self._interceptor = _LoggingClientInterceptor()
|
| 270 |
+
self._logged_channel = grpc.intercept_channel(
|
| 271 |
+
self._grpc_channel, self._interceptor
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
# Wrap messages. This must be done after self._logged_channel exists
|
| 275 |
+
self._prep_wrapped_messages(client_info)
|
| 276 |
+
|
| 277 |
+
@classmethod
|
| 278 |
+
def create_channel(
|
| 279 |
+
cls,
|
| 280 |
+
host: str = "speech.googleapis.com",
|
| 281 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 282 |
+
credentials_file: Optional[str] = None,
|
| 283 |
+
scopes: Optional[Sequence[str]] = None,
|
| 284 |
+
quota_project_id: Optional[str] = None,
|
| 285 |
+
**kwargs,
|
| 286 |
+
) -> grpc.Channel:
|
| 287 |
+
"""Create and return a gRPC channel object.
|
| 288 |
+
Args:
|
| 289 |
+
host (Optional[str]): The host for the channel to use.
|
| 290 |
+
credentials (Optional[~.Credentials]): The
|
| 291 |
+
authorization credentials to attach to requests. These
|
| 292 |
+
credentials identify this application to the service. If
|
| 293 |
+
none are specified, the client will attempt to ascertain
|
| 294 |
+
the credentials from the environment.
|
| 295 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 296 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 297 |
+
This argument is mutually exclusive with credentials. This argument will be
|
| 298 |
+
removed in the next major version of this library.
|
| 299 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 300 |
+
service. These are only used when credentials are not specified and
|
| 301 |
+
are passed to :func:`google.auth.default`.
|
| 302 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 303 |
+
and quota.
|
| 304 |
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
| 305 |
+
channel creation.
|
| 306 |
+
Returns:
|
| 307 |
+
grpc.Channel: A gRPC channel object.
|
| 308 |
+
|
| 309 |
+
Raises:
|
| 310 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 311 |
+
and ``credentials_file`` are passed.
|
| 312 |
+
"""
|
| 313 |
+
|
| 314 |
+
return grpc_helpers.create_channel(
|
| 315 |
+
host,
|
| 316 |
+
credentials=credentials,
|
| 317 |
+
credentials_file=credentials_file,
|
| 318 |
+
quota_project_id=quota_project_id,
|
| 319 |
+
default_scopes=cls.AUTH_SCOPES,
|
| 320 |
+
scopes=scopes,
|
| 321 |
+
default_host=cls.DEFAULT_HOST,
|
| 322 |
+
**kwargs,
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
@property
|
| 326 |
+
def grpc_channel(self) -> grpc.Channel:
|
| 327 |
+
"""Return the channel designed to connect to this service."""
|
| 328 |
+
return self._grpc_channel
|
| 329 |
+
|
| 330 |
+
@property
|
| 331 |
+
def create_phrase_set(
|
| 332 |
+
self,
|
| 333 |
+
) -> Callable[[cloud_speech_adaptation.CreatePhraseSetRequest], resource.PhraseSet]:
|
| 334 |
+
r"""Return a callable for the create phrase set method over gRPC.
|
| 335 |
+
|
| 336 |
+
Create a set of phrase hints. Each item in the set
|
| 337 |
+
can be a single word or a multi-word phrase. The items
|
| 338 |
+
in the PhraseSet are favored by the recognition model
|
| 339 |
+
when you send a call that includes the PhraseSet.
|
| 340 |
+
|
| 341 |
+
Returns:
|
| 342 |
+
Callable[[~.CreatePhraseSetRequest],
|
| 343 |
+
~.PhraseSet]:
|
| 344 |
+
A function that, when called, will call the underlying RPC
|
| 345 |
+
on the server.
|
| 346 |
+
"""
|
| 347 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 348 |
+
# the request.
|
| 349 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 350 |
+
# to pass in the functions for each.
|
| 351 |
+
if "create_phrase_set" not in self._stubs:
|
| 352 |
+
self._stubs["create_phrase_set"] = self._logged_channel.unary_unary(
|
| 353 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/CreatePhraseSet",
|
| 354 |
+
request_serializer=cloud_speech_adaptation.CreatePhraseSetRequest.serialize,
|
| 355 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 356 |
+
)
|
| 357 |
+
return self._stubs["create_phrase_set"]
|
| 358 |
+
|
| 359 |
+
@property
|
| 360 |
+
def get_phrase_set(
|
| 361 |
+
self,
|
| 362 |
+
) -> Callable[[cloud_speech_adaptation.GetPhraseSetRequest], resource.PhraseSet]:
|
| 363 |
+
r"""Return a callable for the get phrase set method over gRPC.
|
| 364 |
+
|
| 365 |
+
Get a phrase set.
|
| 366 |
+
|
| 367 |
+
Returns:
|
| 368 |
+
Callable[[~.GetPhraseSetRequest],
|
| 369 |
+
~.PhraseSet]:
|
| 370 |
+
A function that, when called, will call the underlying RPC
|
| 371 |
+
on the server.
|
| 372 |
+
"""
|
| 373 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 374 |
+
# the request.
|
| 375 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 376 |
+
# to pass in the functions for each.
|
| 377 |
+
if "get_phrase_set" not in self._stubs:
|
| 378 |
+
self._stubs["get_phrase_set"] = self._logged_channel.unary_unary(
|
| 379 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/GetPhraseSet",
|
| 380 |
+
request_serializer=cloud_speech_adaptation.GetPhraseSetRequest.serialize,
|
| 381 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 382 |
+
)
|
| 383 |
+
return self._stubs["get_phrase_set"]
|
| 384 |
+
|
| 385 |
+
@property
|
| 386 |
+
def list_phrase_set(
|
| 387 |
+
self,
|
| 388 |
+
) -> Callable[
|
| 389 |
+
[cloud_speech_adaptation.ListPhraseSetRequest],
|
| 390 |
+
cloud_speech_adaptation.ListPhraseSetResponse,
|
| 391 |
+
]:
|
| 392 |
+
r"""Return a callable for the list phrase set method over gRPC.
|
| 393 |
+
|
| 394 |
+
List phrase sets.
|
| 395 |
+
|
| 396 |
+
Returns:
|
| 397 |
+
Callable[[~.ListPhraseSetRequest],
|
| 398 |
+
~.ListPhraseSetResponse]:
|
| 399 |
+
A function that, when called, will call the underlying RPC
|
| 400 |
+
on the server.
|
| 401 |
+
"""
|
| 402 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 403 |
+
# the request.
|
| 404 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 405 |
+
# to pass in the functions for each.
|
| 406 |
+
if "list_phrase_set" not in self._stubs:
|
| 407 |
+
self._stubs["list_phrase_set"] = self._logged_channel.unary_unary(
|
| 408 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/ListPhraseSet",
|
| 409 |
+
request_serializer=cloud_speech_adaptation.ListPhraseSetRequest.serialize,
|
| 410 |
+
response_deserializer=cloud_speech_adaptation.ListPhraseSetResponse.deserialize,
|
| 411 |
+
)
|
| 412 |
+
return self._stubs["list_phrase_set"]
|
| 413 |
+
|
| 414 |
+
@property
|
| 415 |
+
def update_phrase_set(
|
| 416 |
+
self,
|
| 417 |
+
) -> Callable[[cloud_speech_adaptation.UpdatePhraseSetRequest], resource.PhraseSet]:
|
| 418 |
+
r"""Return a callable for the update phrase set method over gRPC.
|
| 419 |
+
|
| 420 |
+
Update a phrase set.
|
| 421 |
+
|
| 422 |
+
Returns:
|
| 423 |
+
Callable[[~.UpdatePhraseSetRequest],
|
| 424 |
+
~.PhraseSet]:
|
| 425 |
+
A function that, when called, will call the underlying RPC
|
| 426 |
+
on the server.
|
| 427 |
+
"""
|
| 428 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 429 |
+
# the request.
|
| 430 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 431 |
+
# to pass in the functions for each.
|
| 432 |
+
if "update_phrase_set" not in self._stubs:
|
| 433 |
+
self._stubs["update_phrase_set"] = self._logged_channel.unary_unary(
|
| 434 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/UpdatePhraseSet",
|
| 435 |
+
request_serializer=cloud_speech_adaptation.UpdatePhraseSetRequest.serialize,
|
| 436 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 437 |
+
)
|
| 438 |
+
return self._stubs["update_phrase_set"]
|
| 439 |
+
|
| 440 |
+
@property
|
| 441 |
+
def delete_phrase_set(
|
| 442 |
+
self,
|
| 443 |
+
) -> Callable[[cloud_speech_adaptation.DeletePhraseSetRequest], empty_pb2.Empty]:
|
| 444 |
+
r"""Return a callable for the delete phrase set method over gRPC.
|
| 445 |
+
|
| 446 |
+
Delete a phrase set.
|
| 447 |
+
|
| 448 |
+
Returns:
|
| 449 |
+
Callable[[~.DeletePhraseSetRequest],
|
| 450 |
+
~.Empty]:
|
| 451 |
+
A function that, when called, will call the underlying RPC
|
| 452 |
+
on the server.
|
| 453 |
+
"""
|
| 454 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 455 |
+
# the request.
|
| 456 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 457 |
+
# to pass in the functions for each.
|
| 458 |
+
if "delete_phrase_set" not in self._stubs:
|
| 459 |
+
self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary(
|
| 460 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/DeletePhraseSet",
|
| 461 |
+
request_serializer=cloud_speech_adaptation.DeletePhraseSetRequest.serialize,
|
| 462 |
+
response_deserializer=empty_pb2.Empty.FromString,
|
| 463 |
+
)
|
| 464 |
+
return self._stubs["delete_phrase_set"]
|
| 465 |
+
|
| 466 |
+
@property
|
| 467 |
+
def create_custom_class(
|
| 468 |
+
self,
|
| 469 |
+
) -> Callable[
|
| 470 |
+
[cloud_speech_adaptation.CreateCustomClassRequest], resource.CustomClass
|
| 471 |
+
]:
|
| 472 |
+
r"""Return a callable for the create custom class method over gRPC.
|
| 473 |
+
|
| 474 |
+
Create a custom class.
|
| 475 |
+
|
| 476 |
+
Returns:
|
| 477 |
+
Callable[[~.CreateCustomClassRequest],
|
| 478 |
+
~.CustomClass]:
|
| 479 |
+
A function that, when called, will call the underlying RPC
|
| 480 |
+
on the server.
|
| 481 |
+
"""
|
| 482 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 483 |
+
# the request.
|
| 484 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 485 |
+
# to pass in the functions for each.
|
| 486 |
+
if "create_custom_class" not in self._stubs:
|
| 487 |
+
self._stubs["create_custom_class"] = self._logged_channel.unary_unary(
|
| 488 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/CreateCustomClass",
|
| 489 |
+
request_serializer=cloud_speech_adaptation.CreateCustomClassRequest.serialize,
|
| 490 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 491 |
+
)
|
| 492 |
+
return self._stubs["create_custom_class"]
|
| 493 |
+
|
| 494 |
+
@property
|
| 495 |
+
def get_custom_class(
|
| 496 |
+
self,
|
| 497 |
+
) -> Callable[
|
| 498 |
+
[cloud_speech_adaptation.GetCustomClassRequest], resource.CustomClass
|
| 499 |
+
]:
|
| 500 |
+
r"""Return a callable for the get custom class method over gRPC.
|
| 501 |
+
|
| 502 |
+
Get a custom class.
|
| 503 |
+
|
| 504 |
+
Returns:
|
| 505 |
+
Callable[[~.GetCustomClassRequest],
|
| 506 |
+
~.CustomClass]:
|
| 507 |
+
A function that, when called, will call the underlying RPC
|
| 508 |
+
on the server.
|
| 509 |
+
"""
|
| 510 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 511 |
+
# the request.
|
| 512 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 513 |
+
# to pass in the functions for each.
|
| 514 |
+
if "get_custom_class" not in self._stubs:
|
| 515 |
+
self._stubs["get_custom_class"] = self._logged_channel.unary_unary(
|
| 516 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/GetCustomClass",
|
| 517 |
+
request_serializer=cloud_speech_adaptation.GetCustomClassRequest.serialize,
|
| 518 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 519 |
+
)
|
| 520 |
+
return self._stubs["get_custom_class"]
|
| 521 |
+
|
| 522 |
+
@property
|
| 523 |
+
def list_custom_classes(
|
| 524 |
+
self,
|
| 525 |
+
) -> Callable[
|
| 526 |
+
[cloud_speech_adaptation.ListCustomClassesRequest],
|
| 527 |
+
cloud_speech_adaptation.ListCustomClassesResponse,
|
| 528 |
+
]:
|
| 529 |
+
r"""Return a callable for the list custom classes method over gRPC.
|
| 530 |
+
|
| 531 |
+
List custom classes.
|
| 532 |
+
|
| 533 |
+
Returns:
|
| 534 |
+
Callable[[~.ListCustomClassesRequest],
|
| 535 |
+
~.ListCustomClassesResponse]:
|
| 536 |
+
A function that, when called, will call the underlying RPC
|
| 537 |
+
on the server.
|
| 538 |
+
"""
|
| 539 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 540 |
+
# the request.
|
| 541 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 542 |
+
# to pass in the functions for each.
|
| 543 |
+
if "list_custom_classes" not in self._stubs:
|
| 544 |
+
self._stubs["list_custom_classes"] = self._logged_channel.unary_unary(
|
| 545 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/ListCustomClasses",
|
| 546 |
+
request_serializer=cloud_speech_adaptation.ListCustomClassesRequest.serialize,
|
| 547 |
+
response_deserializer=cloud_speech_adaptation.ListCustomClassesResponse.deserialize,
|
| 548 |
+
)
|
| 549 |
+
return self._stubs["list_custom_classes"]
|
| 550 |
+
|
| 551 |
+
@property
|
| 552 |
+
def update_custom_class(
|
| 553 |
+
self,
|
| 554 |
+
) -> Callable[
|
| 555 |
+
[cloud_speech_adaptation.UpdateCustomClassRequest], resource.CustomClass
|
| 556 |
+
]:
|
| 557 |
+
r"""Return a callable for the update custom class method over gRPC.
|
| 558 |
+
|
| 559 |
+
Update a custom class.
|
| 560 |
+
|
| 561 |
+
Returns:
|
| 562 |
+
Callable[[~.UpdateCustomClassRequest],
|
| 563 |
+
~.CustomClass]:
|
| 564 |
+
A function that, when called, will call the underlying RPC
|
| 565 |
+
on the server.
|
| 566 |
+
"""
|
| 567 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 568 |
+
# the request.
|
| 569 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 570 |
+
# to pass in the functions for each.
|
| 571 |
+
if "update_custom_class" not in self._stubs:
|
| 572 |
+
self._stubs["update_custom_class"] = self._logged_channel.unary_unary(
|
| 573 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/UpdateCustomClass",
|
| 574 |
+
request_serializer=cloud_speech_adaptation.UpdateCustomClassRequest.serialize,
|
| 575 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 576 |
+
)
|
| 577 |
+
return self._stubs["update_custom_class"]
|
| 578 |
+
|
| 579 |
+
@property
|
| 580 |
+
def delete_custom_class(
|
| 581 |
+
self,
|
| 582 |
+
) -> Callable[[cloud_speech_adaptation.DeleteCustomClassRequest], empty_pb2.Empty]:
|
| 583 |
+
r"""Return a callable for the delete custom class method over gRPC.
|
| 584 |
+
|
| 585 |
+
Delete a custom class.
|
| 586 |
+
|
| 587 |
+
Returns:
|
| 588 |
+
Callable[[~.DeleteCustomClassRequest],
|
| 589 |
+
~.Empty]:
|
| 590 |
+
A function that, when called, will call the underlying RPC
|
| 591 |
+
on the server.
|
| 592 |
+
"""
|
| 593 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 594 |
+
# the request.
|
| 595 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 596 |
+
# to pass in the functions for each.
|
| 597 |
+
if "delete_custom_class" not in self._stubs:
|
| 598 |
+
self._stubs["delete_custom_class"] = self._logged_channel.unary_unary(
|
| 599 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/DeleteCustomClass",
|
| 600 |
+
request_serializer=cloud_speech_adaptation.DeleteCustomClassRequest.serialize,
|
| 601 |
+
response_deserializer=empty_pb2.Empty.FromString,
|
| 602 |
+
)
|
| 603 |
+
return self._stubs["delete_custom_class"]
|
| 604 |
+
|
| 605 |
+
def close(self):
|
| 606 |
+
self._logged_channel.close()
|
| 607 |
+
|
| 608 |
+
@property
|
| 609 |
+
def get_operation(
|
| 610 |
+
self,
|
| 611 |
+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
|
| 612 |
+
r"""Return a callable for the get_operation method over gRPC."""
|
| 613 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 614 |
+
# the request.
|
| 615 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 616 |
+
# to pass in the functions for each.
|
| 617 |
+
if "get_operation" not in self._stubs:
|
| 618 |
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
| 619 |
+
"/google.longrunning.Operations/GetOperation",
|
| 620 |
+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
| 621 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 622 |
+
)
|
| 623 |
+
return self._stubs["get_operation"]
|
| 624 |
+
|
| 625 |
+
@property
|
| 626 |
+
def list_operations(
|
| 627 |
+
self,
|
| 628 |
+
) -> Callable[
|
| 629 |
+
[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
|
| 630 |
+
]:
|
| 631 |
+
r"""Return a callable for the list_operations method over gRPC."""
|
| 632 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 633 |
+
# the request.
|
| 634 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 635 |
+
# to pass in the functions for each.
|
| 636 |
+
if "list_operations" not in self._stubs:
|
| 637 |
+
self._stubs["list_operations"] = self._logged_channel.unary_unary(
|
| 638 |
+
"/google.longrunning.Operations/ListOperations",
|
| 639 |
+
request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
|
| 640 |
+
response_deserializer=operations_pb2.ListOperationsResponse.FromString,
|
| 641 |
+
)
|
| 642 |
+
return self._stubs["list_operations"]
|
| 643 |
+
|
| 644 |
+
@property
|
| 645 |
+
def kind(self) -> str:
|
| 646 |
+
return "grpc"
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
__all__ = ("AdaptationGrpcTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/grpc_asyncio.py
ADDED
|
@@ -0,0 +1,739 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import inspect
|
| 17 |
+
import json
|
| 18 |
+
import logging as std_logging
|
| 19 |
+
import pickle
|
| 20 |
+
import warnings
|
| 21 |
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
|
| 22 |
+
|
| 23 |
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
| 24 |
+
import google.protobuf.message
|
| 25 |
+
import grpc # type: ignore
|
| 26 |
+
import proto # type: ignore
|
| 27 |
+
from google.api_core import exceptions as core_exceptions
|
| 28 |
+
from google.api_core import gapic_v1, grpc_helpers_async
|
| 29 |
+
from google.api_core import retry_async as retries
|
| 30 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 31 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 32 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 33 |
+
from google.protobuf.json_format import MessageToJson
|
| 34 |
+
from grpc.experimental import aio # type: ignore
|
| 35 |
+
|
| 36 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
|
| 37 |
+
|
| 38 |
+
from .base import DEFAULT_CLIENT_INFO, AdaptationTransport
|
| 39 |
+
from .grpc import AdaptationGrpcTransport
|
| 40 |
+
|
| 41 |
+
try:
|
| 42 |
+
from google.api_core import client_logging # type: ignore
|
| 43 |
+
|
| 44 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 45 |
+
except ImportError: # pragma: NO COVER
|
| 46 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 47 |
+
|
| 48 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class _LoggingClientAIOInterceptor(
|
| 52 |
+
grpc.aio.UnaryUnaryClientInterceptor
|
| 53 |
+
): # pragma: NO COVER
|
| 54 |
+
async def intercept_unary_unary(self, continuation, client_call_details, request):
|
| 55 |
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 56 |
+
std_logging.DEBUG
|
| 57 |
+
)
|
| 58 |
+
if logging_enabled: # pragma: NO COVER
|
| 59 |
+
request_metadata = client_call_details.metadata
|
| 60 |
+
if isinstance(request, proto.Message):
|
| 61 |
+
request_payload = type(request).to_json(request)
|
| 62 |
+
elif isinstance(request, google.protobuf.message.Message):
|
| 63 |
+
request_payload = MessageToJson(request)
|
| 64 |
+
else:
|
| 65 |
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
|
| 66 |
+
|
| 67 |
+
request_metadata = {
|
| 68 |
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
| 69 |
+
for key, value in request_metadata
|
| 70 |
+
}
|
| 71 |
+
grpc_request = {
|
| 72 |
+
"payload": request_payload,
|
| 73 |
+
"requestMethod": "grpc",
|
| 74 |
+
"metadata": dict(request_metadata),
|
| 75 |
+
}
|
| 76 |
+
_LOGGER.debug(
|
| 77 |
+
f"Sending request for {client_call_details.method}",
|
| 78 |
+
extra={
|
| 79 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Adaptation",
|
| 80 |
+
"rpcName": str(client_call_details.method),
|
| 81 |
+
"request": grpc_request,
|
| 82 |
+
"metadata": grpc_request["metadata"],
|
| 83 |
+
},
|
| 84 |
+
)
|
| 85 |
+
response = await continuation(client_call_details, request)
|
| 86 |
+
if logging_enabled: # pragma: NO COVER
|
| 87 |
+
response_metadata = await response.trailing_metadata()
|
| 88 |
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
| 89 |
+
metadata = (
|
| 90 |
+
dict([(k, str(v)) for k, v in response_metadata])
|
| 91 |
+
if response_metadata
|
| 92 |
+
else None
|
| 93 |
+
)
|
| 94 |
+
result = await response
|
| 95 |
+
if isinstance(result, proto.Message):
|
| 96 |
+
response_payload = type(result).to_json(result)
|
| 97 |
+
elif isinstance(result, google.protobuf.message.Message):
|
| 98 |
+
response_payload = MessageToJson(result)
|
| 99 |
+
else:
|
| 100 |
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
|
| 101 |
+
grpc_response = {
|
| 102 |
+
"payload": response_payload,
|
| 103 |
+
"metadata": metadata,
|
| 104 |
+
"status": "OK",
|
| 105 |
+
}
|
| 106 |
+
_LOGGER.debug(
|
| 107 |
+
f"Received response to rpc {client_call_details.method}.",
|
| 108 |
+
extra={
|
| 109 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Adaptation",
|
| 110 |
+
"rpcName": str(client_call_details.method),
|
| 111 |
+
"response": grpc_response,
|
| 112 |
+
"metadata": grpc_response["metadata"],
|
| 113 |
+
},
|
| 114 |
+
)
|
| 115 |
+
return response
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
class AdaptationGrpcAsyncIOTransport(AdaptationTransport):
|
| 119 |
+
"""gRPC AsyncIO backend transport for Adaptation.
|
| 120 |
+
|
| 121 |
+
Service that implements Google Cloud Speech Adaptation API.
|
| 122 |
+
|
| 123 |
+
This class defines the same methods as the primary client, so the
|
| 124 |
+
primary client can load the underlying transport implementation
|
| 125 |
+
and call it.
|
| 126 |
+
|
| 127 |
+
It sends protocol buffers over the wire using gRPC (which is built on
|
| 128 |
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
| 129 |
+
"""
|
| 130 |
+
|
| 131 |
+
_grpc_channel: aio.Channel
|
| 132 |
+
_stubs: Dict[str, Callable] = {}
|
| 133 |
+
|
| 134 |
+
@classmethod
|
| 135 |
+
def create_channel(
|
| 136 |
+
cls,
|
| 137 |
+
host: str = "speech.googleapis.com",
|
| 138 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 139 |
+
credentials_file: Optional[str] = None,
|
| 140 |
+
scopes: Optional[Sequence[str]] = None,
|
| 141 |
+
quota_project_id: Optional[str] = None,
|
| 142 |
+
**kwargs,
|
| 143 |
+
) -> aio.Channel:
|
| 144 |
+
"""Create and return a gRPC AsyncIO channel object.
|
| 145 |
+
Args:
|
| 146 |
+
host (Optional[str]): The host for the channel to use.
|
| 147 |
+
credentials (Optional[~.Credentials]): The
|
| 148 |
+
authorization credentials to attach to requests. These
|
| 149 |
+
credentials identify this application to the service. If
|
| 150 |
+
none are specified, the client will attempt to ascertain
|
| 151 |
+
the credentials from the environment.
|
| 152 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 153 |
+
be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be
|
| 154 |
+
removed in the next major version of this library.
|
| 155 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 156 |
+
service. These are only used when credentials are not specified and
|
| 157 |
+
are passed to :func:`google.auth.default`.
|
| 158 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 159 |
+
and quota.
|
| 160 |
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
| 161 |
+
channel creation.
|
| 162 |
+
Returns:
|
| 163 |
+
aio.Channel: A gRPC AsyncIO channel object.
|
| 164 |
+
"""
|
| 165 |
+
|
| 166 |
+
return grpc_helpers_async.create_channel(
|
| 167 |
+
host,
|
| 168 |
+
credentials=credentials,
|
| 169 |
+
credentials_file=credentials_file,
|
| 170 |
+
quota_project_id=quota_project_id,
|
| 171 |
+
default_scopes=cls.AUTH_SCOPES,
|
| 172 |
+
scopes=scopes,
|
| 173 |
+
default_host=cls.DEFAULT_HOST,
|
| 174 |
+
**kwargs,
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
def __init__(
|
| 178 |
+
self,
|
| 179 |
+
*,
|
| 180 |
+
host: str = "speech.googleapis.com",
|
| 181 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 182 |
+
credentials_file: Optional[str] = None,
|
| 183 |
+
scopes: Optional[Sequence[str]] = None,
|
| 184 |
+
channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
|
| 185 |
+
api_mtls_endpoint: Optional[str] = None,
|
| 186 |
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 187 |
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
| 188 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 189 |
+
quota_project_id: Optional[str] = None,
|
| 190 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 191 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 192 |
+
api_audience: Optional[str] = None,
|
| 193 |
+
) -> None:
|
| 194 |
+
"""Instantiate the transport.
|
| 195 |
+
|
| 196 |
+
Args:
|
| 197 |
+
host (Optional[str]):
|
| 198 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 199 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 200 |
+
authorization credentials to attach to requests. These
|
| 201 |
+
credentials identify the application to the service; if none
|
| 202 |
+
are specified, the client will attempt to ascertain the
|
| 203 |
+
credentials from the environment.
|
| 204 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 205 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 206 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 207 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 208 |
+
This argument will be removed in the next major version of this library.
|
| 209 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 210 |
+
service. These are only used when credentials are not specified and
|
| 211 |
+
are passed to :func:`google.auth.default`.
|
| 212 |
+
channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
|
| 213 |
+
A ``Channel`` instance through which to make calls, or a Callable
|
| 214 |
+
that constructs and returns one. If set to None, ``self.create_channel``
|
| 215 |
+
is used to create the channel. If a Callable is given, it will be called
|
| 216 |
+
with the same arguments as used in ``self.create_channel``.
|
| 217 |
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
| 218 |
+
If provided, it overrides the ``host`` argument and tries to create
|
| 219 |
+
a mutual TLS channel with client SSL credentials from
|
| 220 |
+
``client_cert_source`` or application default SSL credentials.
|
| 221 |
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 222 |
+
Deprecated. A callback to provide client SSL certificate bytes and
|
| 223 |
+
private key bytes, both in PEM format. It is ignored if
|
| 224 |
+
``api_mtls_endpoint`` is None.
|
| 225 |
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
| 226 |
+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
|
| 227 |
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 228 |
+
A callback to provide client certificate bytes and private key bytes,
|
| 229 |
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
| 230 |
+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
|
| 231 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 232 |
+
and quota.
|
| 233 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 234 |
+
The client info used to send a user-agent string along with
|
| 235 |
+
API requests. If ``None``, then default info will be used.
|
| 236 |
+
Generally, you only need to set this if you're developing
|
| 237 |
+
your own client library.
|
| 238 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 239 |
+
be used for service account credentials.
|
| 240 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 241 |
+
to the service that will be set when using certain 3rd party
|
| 242 |
+
authentication flows. Audience is typically a resource identifier.
|
| 243 |
+
If not set, the host value will be used as a default.
|
| 244 |
+
|
| 245 |
+
Raises:
|
| 246 |
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
| 247 |
+
creation failed for any reason.
|
| 248 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 249 |
+
and ``credentials_file`` are passed.
|
| 250 |
+
"""
|
| 251 |
+
self._grpc_channel = None
|
| 252 |
+
self._ssl_channel_credentials = ssl_channel_credentials
|
| 253 |
+
self._stubs: Dict[str, Callable] = {}
|
| 254 |
+
|
| 255 |
+
if api_mtls_endpoint:
|
| 256 |
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
| 257 |
+
if client_cert_source:
|
| 258 |
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
| 259 |
+
|
| 260 |
+
if isinstance(channel, aio.Channel):
|
| 261 |
+
# Ignore credentials if a channel was passed.
|
| 262 |
+
credentials = None
|
| 263 |
+
self._ignore_credentials = True
|
| 264 |
+
# If a channel was explicitly provided, set it.
|
| 265 |
+
self._grpc_channel = channel
|
| 266 |
+
self._ssl_channel_credentials = None
|
| 267 |
+
else:
|
| 268 |
+
if api_mtls_endpoint:
|
| 269 |
+
host = api_mtls_endpoint
|
| 270 |
+
|
| 271 |
+
# Create SSL credentials with client_cert_source or application
|
| 272 |
+
# default SSL credentials.
|
| 273 |
+
if client_cert_source:
|
| 274 |
+
cert, key = client_cert_source()
|
| 275 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 276 |
+
certificate_chain=cert, private_key=key
|
| 277 |
+
)
|
| 278 |
+
else:
|
| 279 |
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
| 280 |
+
|
| 281 |
+
else:
|
| 282 |
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
| 283 |
+
cert, key = client_cert_source_for_mtls()
|
| 284 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 285 |
+
certificate_chain=cert, private_key=key
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
# The base transport sets the host, credentials and scopes
|
| 289 |
+
super().__init__(
|
| 290 |
+
host=host,
|
| 291 |
+
credentials=credentials,
|
| 292 |
+
credentials_file=credentials_file,
|
| 293 |
+
scopes=scopes,
|
| 294 |
+
quota_project_id=quota_project_id,
|
| 295 |
+
client_info=client_info,
|
| 296 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 297 |
+
api_audience=api_audience,
|
| 298 |
+
)
|
| 299 |
+
|
| 300 |
+
if not self._grpc_channel:
|
| 301 |
+
# initialize with the provided callable or the default channel
|
| 302 |
+
channel_init = channel or type(self).create_channel
|
| 303 |
+
self._grpc_channel = channel_init(
|
| 304 |
+
self._host,
|
| 305 |
+
# use the credentials which are saved
|
| 306 |
+
credentials=self._credentials,
|
| 307 |
+
# Set ``credentials_file`` to ``None`` here as
|
| 308 |
+
# the credentials that we saved earlier should be used.
|
| 309 |
+
credentials_file=None,
|
| 310 |
+
scopes=self._scopes,
|
| 311 |
+
ssl_credentials=self._ssl_channel_credentials,
|
| 312 |
+
quota_project_id=quota_project_id,
|
| 313 |
+
options=[
|
| 314 |
+
("grpc.max_send_message_length", -1),
|
| 315 |
+
("grpc.max_receive_message_length", -1),
|
| 316 |
+
],
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
+
self._interceptor = _LoggingClientAIOInterceptor()
|
| 320 |
+
self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
|
| 321 |
+
self._logged_channel = self._grpc_channel
|
| 322 |
+
self._wrap_with_kind = (
|
| 323 |
+
"kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
|
| 324 |
+
)
|
| 325 |
+
# Wrap messages. This must be done after self._logged_channel exists
|
| 326 |
+
self._prep_wrapped_messages(client_info)
|
| 327 |
+
|
| 328 |
+
@property
|
| 329 |
+
def grpc_channel(self) -> aio.Channel:
|
| 330 |
+
"""Create the channel designed to connect to this service.
|
| 331 |
+
|
| 332 |
+
This property caches on the instance; repeated calls return
|
| 333 |
+
the same channel.
|
| 334 |
+
"""
|
| 335 |
+
# Return the channel from cache.
|
| 336 |
+
return self._grpc_channel
|
| 337 |
+
|
| 338 |
+
@property
|
| 339 |
+
def create_phrase_set(
|
| 340 |
+
self,
|
| 341 |
+
) -> Callable[
|
| 342 |
+
[cloud_speech_adaptation.CreatePhraseSetRequest], Awaitable[resource.PhraseSet]
|
| 343 |
+
]:
|
| 344 |
+
r"""Return a callable for the create phrase set method over gRPC.
|
| 345 |
+
|
| 346 |
+
Create a set of phrase hints. Each item in the set
|
| 347 |
+
can be a single word or a multi-word phrase. The items
|
| 348 |
+
in the PhraseSet are favored by the recognition model
|
| 349 |
+
when you send a call that includes the PhraseSet.
|
| 350 |
+
|
| 351 |
+
Returns:
|
| 352 |
+
Callable[[~.CreatePhraseSetRequest],
|
| 353 |
+
Awaitable[~.PhraseSet]]:
|
| 354 |
+
A function that, when called, will call the underlying RPC
|
| 355 |
+
on the server.
|
| 356 |
+
"""
|
| 357 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 358 |
+
# the request.
|
| 359 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 360 |
+
# to pass in the functions for each.
|
| 361 |
+
if "create_phrase_set" not in self._stubs:
|
| 362 |
+
self._stubs["create_phrase_set"] = self._logged_channel.unary_unary(
|
| 363 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/CreatePhraseSet",
|
| 364 |
+
request_serializer=cloud_speech_adaptation.CreatePhraseSetRequest.serialize,
|
| 365 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 366 |
+
)
|
| 367 |
+
return self._stubs["create_phrase_set"]
|
| 368 |
+
|
| 369 |
+
@property
|
| 370 |
+
def get_phrase_set(
|
| 371 |
+
self,
|
| 372 |
+
) -> Callable[
|
| 373 |
+
[cloud_speech_adaptation.GetPhraseSetRequest], Awaitable[resource.PhraseSet]
|
| 374 |
+
]:
|
| 375 |
+
r"""Return a callable for the get phrase set method over gRPC.
|
| 376 |
+
|
| 377 |
+
Get a phrase set.
|
| 378 |
+
|
| 379 |
+
Returns:
|
| 380 |
+
Callable[[~.GetPhraseSetRequest],
|
| 381 |
+
Awaitable[~.PhraseSet]]:
|
| 382 |
+
A function that, when called, will call the underlying RPC
|
| 383 |
+
on the server.
|
| 384 |
+
"""
|
| 385 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 386 |
+
# the request.
|
| 387 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 388 |
+
# to pass in the functions for each.
|
| 389 |
+
if "get_phrase_set" not in self._stubs:
|
| 390 |
+
self._stubs["get_phrase_set"] = self._logged_channel.unary_unary(
|
| 391 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/GetPhraseSet",
|
| 392 |
+
request_serializer=cloud_speech_adaptation.GetPhraseSetRequest.serialize,
|
| 393 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 394 |
+
)
|
| 395 |
+
return self._stubs["get_phrase_set"]
|
| 396 |
+
|
| 397 |
+
@property
|
| 398 |
+
def list_phrase_set(
|
| 399 |
+
self,
|
| 400 |
+
) -> Callable[
|
| 401 |
+
[cloud_speech_adaptation.ListPhraseSetRequest],
|
| 402 |
+
Awaitable[cloud_speech_adaptation.ListPhraseSetResponse],
|
| 403 |
+
]:
|
| 404 |
+
r"""Return a callable for the list phrase set method over gRPC.
|
| 405 |
+
|
| 406 |
+
List phrase sets.
|
| 407 |
+
|
| 408 |
+
Returns:
|
| 409 |
+
Callable[[~.ListPhraseSetRequest],
|
| 410 |
+
Awaitable[~.ListPhraseSetResponse]]:
|
| 411 |
+
A function that, when called, will call the underlying RPC
|
| 412 |
+
on the server.
|
| 413 |
+
"""
|
| 414 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 415 |
+
# the request.
|
| 416 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 417 |
+
# to pass in the functions for each.
|
| 418 |
+
if "list_phrase_set" not in self._stubs:
|
| 419 |
+
self._stubs["list_phrase_set"] = self._logged_channel.unary_unary(
|
| 420 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/ListPhraseSet",
|
| 421 |
+
request_serializer=cloud_speech_adaptation.ListPhraseSetRequest.serialize,
|
| 422 |
+
response_deserializer=cloud_speech_adaptation.ListPhraseSetResponse.deserialize,
|
| 423 |
+
)
|
| 424 |
+
return self._stubs["list_phrase_set"]
|
| 425 |
+
|
| 426 |
+
@property
|
| 427 |
+
def update_phrase_set(
|
| 428 |
+
self,
|
| 429 |
+
) -> Callable[
|
| 430 |
+
[cloud_speech_adaptation.UpdatePhraseSetRequest], Awaitable[resource.PhraseSet]
|
| 431 |
+
]:
|
| 432 |
+
r"""Return a callable for the update phrase set method over gRPC.
|
| 433 |
+
|
| 434 |
+
Update a phrase set.
|
| 435 |
+
|
| 436 |
+
Returns:
|
| 437 |
+
Callable[[~.UpdatePhraseSetRequest],
|
| 438 |
+
Awaitable[~.PhraseSet]]:
|
| 439 |
+
A function that, when called, will call the underlying RPC
|
| 440 |
+
on the server.
|
| 441 |
+
"""
|
| 442 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 443 |
+
# the request.
|
| 444 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 445 |
+
# to pass in the functions for each.
|
| 446 |
+
if "update_phrase_set" not in self._stubs:
|
| 447 |
+
self._stubs["update_phrase_set"] = self._logged_channel.unary_unary(
|
| 448 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/UpdatePhraseSet",
|
| 449 |
+
request_serializer=cloud_speech_adaptation.UpdatePhraseSetRequest.serialize,
|
| 450 |
+
response_deserializer=resource.PhraseSet.deserialize,
|
| 451 |
+
)
|
| 452 |
+
return self._stubs["update_phrase_set"]
|
| 453 |
+
|
| 454 |
+
@property
|
| 455 |
+
def delete_phrase_set(
|
| 456 |
+
self,
|
| 457 |
+
) -> Callable[
|
| 458 |
+
[cloud_speech_adaptation.DeletePhraseSetRequest], Awaitable[empty_pb2.Empty]
|
| 459 |
+
]:
|
| 460 |
+
r"""Return a callable for the delete phrase set method over gRPC.
|
| 461 |
+
|
| 462 |
+
Delete a phrase set.
|
| 463 |
+
|
| 464 |
+
Returns:
|
| 465 |
+
Callable[[~.DeletePhraseSetRequest],
|
| 466 |
+
Awaitable[~.Empty]]:
|
| 467 |
+
A function that, when called, will call the underlying RPC
|
| 468 |
+
on the server.
|
| 469 |
+
"""
|
| 470 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 471 |
+
# the request.
|
| 472 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 473 |
+
# to pass in the functions for each.
|
| 474 |
+
if "delete_phrase_set" not in self._stubs:
|
| 475 |
+
self._stubs["delete_phrase_set"] = self._logged_channel.unary_unary(
|
| 476 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/DeletePhraseSet",
|
| 477 |
+
request_serializer=cloud_speech_adaptation.DeletePhraseSetRequest.serialize,
|
| 478 |
+
response_deserializer=empty_pb2.Empty.FromString,
|
| 479 |
+
)
|
| 480 |
+
return self._stubs["delete_phrase_set"]
|
| 481 |
+
|
| 482 |
+
@property
|
| 483 |
+
def create_custom_class(
|
| 484 |
+
self,
|
| 485 |
+
) -> Callable[
|
| 486 |
+
[cloud_speech_adaptation.CreateCustomClassRequest],
|
| 487 |
+
Awaitable[resource.CustomClass],
|
| 488 |
+
]:
|
| 489 |
+
r"""Return a callable for the create custom class method over gRPC.
|
| 490 |
+
|
| 491 |
+
Create a custom class.
|
| 492 |
+
|
| 493 |
+
Returns:
|
| 494 |
+
Callable[[~.CreateCustomClassRequest],
|
| 495 |
+
Awaitable[~.CustomClass]]:
|
| 496 |
+
A function that, when called, will call the underlying RPC
|
| 497 |
+
on the server.
|
| 498 |
+
"""
|
| 499 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 500 |
+
# the request.
|
| 501 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 502 |
+
# to pass in the functions for each.
|
| 503 |
+
if "create_custom_class" not in self._stubs:
|
| 504 |
+
self._stubs["create_custom_class"] = self._logged_channel.unary_unary(
|
| 505 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/CreateCustomClass",
|
| 506 |
+
request_serializer=cloud_speech_adaptation.CreateCustomClassRequest.serialize,
|
| 507 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 508 |
+
)
|
| 509 |
+
return self._stubs["create_custom_class"]
|
| 510 |
+
|
| 511 |
+
@property
|
| 512 |
+
def get_custom_class(
|
| 513 |
+
self,
|
| 514 |
+
) -> Callable[
|
| 515 |
+
[cloud_speech_adaptation.GetCustomClassRequest], Awaitable[resource.CustomClass]
|
| 516 |
+
]:
|
| 517 |
+
r"""Return a callable for the get custom class method over gRPC.
|
| 518 |
+
|
| 519 |
+
Get a custom class.
|
| 520 |
+
|
| 521 |
+
Returns:
|
| 522 |
+
Callable[[~.GetCustomClassRequest],
|
| 523 |
+
Awaitable[~.CustomClass]]:
|
| 524 |
+
A function that, when called, will call the underlying RPC
|
| 525 |
+
on the server.
|
| 526 |
+
"""
|
| 527 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 528 |
+
# the request.
|
| 529 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 530 |
+
# to pass in the functions for each.
|
| 531 |
+
if "get_custom_class" not in self._stubs:
|
| 532 |
+
self._stubs["get_custom_class"] = self._logged_channel.unary_unary(
|
| 533 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/GetCustomClass",
|
| 534 |
+
request_serializer=cloud_speech_adaptation.GetCustomClassRequest.serialize,
|
| 535 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 536 |
+
)
|
| 537 |
+
return self._stubs["get_custom_class"]
|
| 538 |
+
|
| 539 |
+
@property
|
| 540 |
+
def list_custom_classes(
|
| 541 |
+
self,
|
| 542 |
+
) -> Callable[
|
| 543 |
+
[cloud_speech_adaptation.ListCustomClassesRequest],
|
| 544 |
+
Awaitable[cloud_speech_adaptation.ListCustomClassesResponse],
|
| 545 |
+
]:
|
| 546 |
+
r"""Return a callable for the list custom classes method over gRPC.
|
| 547 |
+
|
| 548 |
+
List custom classes.
|
| 549 |
+
|
| 550 |
+
Returns:
|
| 551 |
+
Callable[[~.ListCustomClassesRequest],
|
| 552 |
+
Awaitable[~.ListCustomClassesResponse]]:
|
| 553 |
+
A function that, when called, will call the underlying RPC
|
| 554 |
+
on the server.
|
| 555 |
+
"""
|
| 556 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 557 |
+
# the request.
|
| 558 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 559 |
+
# to pass in the functions for each.
|
| 560 |
+
if "list_custom_classes" not in self._stubs:
|
| 561 |
+
self._stubs["list_custom_classes"] = self._logged_channel.unary_unary(
|
| 562 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/ListCustomClasses",
|
| 563 |
+
request_serializer=cloud_speech_adaptation.ListCustomClassesRequest.serialize,
|
| 564 |
+
response_deserializer=cloud_speech_adaptation.ListCustomClassesResponse.deserialize,
|
| 565 |
+
)
|
| 566 |
+
return self._stubs["list_custom_classes"]
|
| 567 |
+
|
| 568 |
+
@property
|
| 569 |
+
def update_custom_class(
|
| 570 |
+
self,
|
| 571 |
+
) -> Callable[
|
| 572 |
+
[cloud_speech_adaptation.UpdateCustomClassRequest],
|
| 573 |
+
Awaitable[resource.CustomClass],
|
| 574 |
+
]:
|
| 575 |
+
r"""Return a callable for the update custom class method over gRPC.
|
| 576 |
+
|
| 577 |
+
Update a custom class.
|
| 578 |
+
|
| 579 |
+
Returns:
|
| 580 |
+
Callable[[~.UpdateCustomClassRequest],
|
| 581 |
+
Awaitable[~.CustomClass]]:
|
| 582 |
+
A function that, when called, will call the underlying RPC
|
| 583 |
+
on the server.
|
| 584 |
+
"""
|
| 585 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 586 |
+
# the request.
|
| 587 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 588 |
+
# to pass in the functions for each.
|
| 589 |
+
if "update_custom_class" not in self._stubs:
|
| 590 |
+
self._stubs["update_custom_class"] = self._logged_channel.unary_unary(
|
| 591 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/UpdateCustomClass",
|
| 592 |
+
request_serializer=cloud_speech_adaptation.UpdateCustomClassRequest.serialize,
|
| 593 |
+
response_deserializer=resource.CustomClass.deserialize,
|
| 594 |
+
)
|
| 595 |
+
return self._stubs["update_custom_class"]
|
| 596 |
+
|
| 597 |
+
@property
|
| 598 |
+
def delete_custom_class(
|
| 599 |
+
self,
|
| 600 |
+
) -> Callable[
|
| 601 |
+
[cloud_speech_adaptation.DeleteCustomClassRequest], Awaitable[empty_pb2.Empty]
|
| 602 |
+
]:
|
| 603 |
+
r"""Return a callable for the delete custom class method over gRPC.
|
| 604 |
+
|
| 605 |
+
Delete a custom class.
|
| 606 |
+
|
| 607 |
+
Returns:
|
| 608 |
+
Callable[[~.DeleteCustomClassRequest],
|
| 609 |
+
Awaitable[~.Empty]]:
|
| 610 |
+
A function that, when called, will call the underlying RPC
|
| 611 |
+
on the server.
|
| 612 |
+
"""
|
| 613 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 614 |
+
# the request.
|
| 615 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 616 |
+
# to pass in the functions for each.
|
| 617 |
+
if "delete_custom_class" not in self._stubs:
|
| 618 |
+
self._stubs["delete_custom_class"] = self._logged_channel.unary_unary(
|
| 619 |
+
"/google.cloud.speech.v1p1beta1.Adaptation/DeleteCustomClass",
|
| 620 |
+
request_serializer=cloud_speech_adaptation.DeleteCustomClassRequest.serialize,
|
| 621 |
+
response_deserializer=empty_pb2.Empty.FromString,
|
| 622 |
+
)
|
| 623 |
+
return self._stubs["delete_custom_class"]
|
| 624 |
+
|
| 625 |
+
def _prep_wrapped_messages(self, client_info):
|
| 626 |
+
"""Precompute the wrapped methods, overriding the base class method to use async wrappers."""
|
| 627 |
+
self._wrapped_methods = {
|
| 628 |
+
self.create_phrase_set: self._wrap_method(
|
| 629 |
+
self.create_phrase_set,
|
| 630 |
+
default_timeout=None,
|
| 631 |
+
client_info=client_info,
|
| 632 |
+
),
|
| 633 |
+
self.get_phrase_set: self._wrap_method(
|
| 634 |
+
self.get_phrase_set,
|
| 635 |
+
default_timeout=None,
|
| 636 |
+
client_info=client_info,
|
| 637 |
+
),
|
| 638 |
+
self.list_phrase_set: self._wrap_method(
|
| 639 |
+
self.list_phrase_set,
|
| 640 |
+
default_timeout=None,
|
| 641 |
+
client_info=client_info,
|
| 642 |
+
),
|
| 643 |
+
self.update_phrase_set: self._wrap_method(
|
| 644 |
+
self.update_phrase_set,
|
| 645 |
+
default_timeout=None,
|
| 646 |
+
client_info=client_info,
|
| 647 |
+
),
|
| 648 |
+
self.delete_phrase_set: self._wrap_method(
|
| 649 |
+
self.delete_phrase_set,
|
| 650 |
+
default_timeout=None,
|
| 651 |
+
client_info=client_info,
|
| 652 |
+
),
|
| 653 |
+
self.create_custom_class: self._wrap_method(
|
| 654 |
+
self.create_custom_class,
|
| 655 |
+
default_timeout=None,
|
| 656 |
+
client_info=client_info,
|
| 657 |
+
),
|
| 658 |
+
self.get_custom_class: self._wrap_method(
|
| 659 |
+
self.get_custom_class,
|
| 660 |
+
default_timeout=None,
|
| 661 |
+
client_info=client_info,
|
| 662 |
+
),
|
| 663 |
+
self.list_custom_classes: self._wrap_method(
|
| 664 |
+
self.list_custom_classes,
|
| 665 |
+
default_timeout=None,
|
| 666 |
+
client_info=client_info,
|
| 667 |
+
),
|
| 668 |
+
self.update_custom_class: self._wrap_method(
|
| 669 |
+
self.update_custom_class,
|
| 670 |
+
default_timeout=None,
|
| 671 |
+
client_info=client_info,
|
| 672 |
+
),
|
| 673 |
+
self.delete_custom_class: self._wrap_method(
|
| 674 |
+
self.delete_custom_class,
|
| 675 |
+
default_timeout=None,
|
| 676 |
+
client_info=client_info,
|
| 677 |
+
),
|
| 678 |
+
self.get_operation: self._wrap_method(
|
| 679 |
+
self.get_operation,
|
| 680 |
+
default_timeout=None,
|
| 681 |
+
client_info=client_info,
|
| 682 |
+
),
|
| 683 |
+
self.list_operations: self._wrap_method(
|
| 684 |
+
self.list_operations,
|
| 685 |
+
default_timeout=None,
|
| 686 |
+
client_info=client_info,
|
| 687 |
+
),
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
def _wrap_method(self, func, *args, **kwargs):
|
| 691 |
+
if self._wrap_with_kind: # pragma: NO COVER
|
| 692 |
+
kwargs["kind"] = self.kind
|
| 693 |
+
return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
|
| 694 |
+
|
| 695 |
+
def close(self):
|
| 696 |
+
return self._logged_channel.close()
|
| 697 |
+
|
| 698 |
+
@property
|
| 699 |
+
def kind(self) -> str:
|
| 700 |
+
return "grpc_asyncio"
|
| 701 |
+
|
| 702 |
+
@property
|
| 703 |
+
def get_operation(
|
| 704 |
+
self,
|
| 705 |
+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
|
| 706 |
+
r"""Return a callable for the get_operation method over gRPC."""
|
| 707 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 708 |
+
# the request.
|
| 709 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 710 |
+
# to pass in the functions for each.
|
| 711 |
+
if "get_operation" not in self._stubs:
|
| 712 |
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
| 713 |
+
"/google.longrunning.Operations/GetOperation",
|
| 714 |
+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
| 715 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 716 |
+
)
|
| 717 |
+
return self._stubs["get_operation"]
|
| 718 |
+
|
| 719 |
+
@property
|
| 720 |
+
def list_operations(
|
| 721 |
+
self,
|
| 722 |
+
) -> Callable[
|
| 723 |
+
[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
|
| 724 |
+
]:
|
| 725 |
+
r"""Return a callable for the list_operations method over gRPC."""
|
| 726 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 727 |
+
# the request.
|
| 728 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 729 |
+
# to pass in the functions for each.
|
| 730 |
+
if "list_operations" not in self._stubs:
|
| 731 |
+
self._stubs["list_operations"] = self._logged_channel.unary_unary(
|
| 732 |
+
"/google.longrunning.Operations/ListOperations",
|
| 733 |
+
request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
|
| 734 |
+
response_deserializer=operations_pb2.ListOperationsResponse.FromString,
|
| 735 |
+
)
|
| 736 |
+
return self._stubs["list_operations"]
|
| 737 |
+
|
| 738 |
+
|
| 739 |
+
__all__ = ("AdaptationGrpcAsyncIOTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/rest.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/adaptation/transports/rest_base.py
ADDED
|
@@ -0,0 +1,653 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json # type: ignore
|
| 17 |
+
import re
|
| 18 |
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
| 19 |
+
|
| 20 |
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
| 21 |
+
from google.api_core import gapic_v1, path_template
|
| 22 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 23 |
+
from google.protobuf import json_format
|
| 24 |
+
|
| 25 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
|
| 26 |
+
|
| 27 |
+
from .base import DEFAULT_CLIENT_INFO, AdaptationTransport
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class _BaseAdaptationRestTransport(AdaptationTransport):
|
| 31 |
+
"""Base REST backend transport for Adaptation.
|
| 32 |
+
|
| 33 |
+
Note: This class is not meant to be used directly. Use its sync and
|
| 34 |
+
async sub-classes instead.
|
| 35 |
+
|
| 36 |
+
This class defines the same methods as the primary client, so the
|
| 37 |
+
primary client can load the underlying transport implementation
|
| 38 |
+
and call it.
|
| 39 |
+
|
| 40 |
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
def __init__(
|
| 44 |
+
self,
|
| 45 |
+
*,
|
| 46 |
+
host: str = "speech.googleapis.com",
|
| 47 |
+
credentials: Optional[Any] = None,
|
| 48 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 49 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 50 |
+
url_scheme: str = "https",
|
| 51 |
+
api_audience: Optional[str] = None,
|
| 52 |
+
) -> None:
|
| 53 |
+
"""Instantiate the transport.
|
| 54 |
+
Args:
|
| 55 |
+
host (Optional[str]):
|
| 56 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 57 |
+
credentials (Optional[Any]): The
|
| 58 |
+
authorization credentials to attach to requests. These
|
| 59 |
+
credentials identify the application to the service; if none
|
| 60 |
+
are specified, the client will attempt to ascertain the
|
| 61 |
+
credentials from the environment.
|
| 62 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 63 |
+
The client info used to send a user-agent string along with
|
| 64 |
+
API requests. If ``None``, then default info will be used.
|
| 65 |
+
Generally, you only need to set this if you are developing
|
| 66 |
+
your own client library.
|
| 67 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 68 |
+
be used for service account credentials.
|
| 69 |
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
| 70 |
+
"https", but for testing or local servers,
|
| 71 |
+
"http" can be specified.
|
| 72 |
+
"""
|
| 73 |
+
# Run the base constructor
|
| 74 |
+
maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
|
| 75 |
+
if maybe_url_match is None:
|
| 76 |
+
raise ValueError(
|
| 77 |
+
f"Unexpected hostname structure: {host}"
|
| 78 |
+
) # pragma: NO COVER
|
| 79 |
+
|
| 80 |
+
url_match_items = maybe_url_match.groupdict()
|
| 81 |
+
|
| 82 |
+
host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host
|
| 83 |
+
|
| 84 |
+
super().__init__(
|
| 85 |
+
host=host,
|
| 86 |
+
credentials=credentials,
|
| 87 |
+
client_info=client_info,
|
| 88 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 89 |
+
api_audience=api_audience,
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
class _BaseCreateCustomClass:
|
| 93 |
+
def __hash__(self): # pragma: NO COVER
|
| 94 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 95 |
+
|
| 96 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 97 |
+
|
| 98 |
+
@classmethod
|
| 99 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 100 |
+
return {
|
| 101 |
+
k: v
|
| 102 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 103 |
+
if k not in message_dict
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
@staticmethod
|
| 107 |
+
def _get_http_options():
|
| 108 |
+
http_options: List[Dict[str, str]] = [
|
| 109 |
+
{
|
| 110 |
+
"method": "post",
|
| 111 |
+
"uri": "/v1p1beta1/{parent=projects/*/locations/*}/customClasses",
|
| 112 |
+
"body": "*",
|
| 113 |
+
},
|
| 114 |
+
]
|
| 115 |
+
return http_options
|
| 116 |
+
|
| 117 |
+
@staticmethod
|
| 118 |
+
def _get_transcoded_request(http_options, request):
|
| 119 |
+
pb_request = cloud_speech_adaptation.CreateCustomClassRequest.pb(request)
|
| 120 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 121 |
+
return transcoded_request
|
| 122 |
+
|
| 123 |
+
@staticmethod
|
| 124 |
+
def _get_request_body_json(transcoded_request):
|
| 125 |
+
# Jsonify the request body
|
| 126 |
+
|
| 127 |
+
body = json_format.MessageToJson(
|
| 128 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 129 |
+
)
|
| 130 |
+
return body
|
| 131 |
+
|
| 132 |
+
@staticmethod
|
| 133 |
+
def _get_query_params_json(transcoded_request):
|
| 134 |
+
query_params = json.loads(
|
| 135 |
+
json_format.MessageToJson(
|
| 136 |
+
transcoded_request["query_params"],
|
| 137 |
+
use_integers_for_enums=True,
|
| 138 |
+
)
|
| 139 |
+
)
|
| 140 |
+
query_params.update(
|
| 141 |
+
_BaseAdaptationRestTransport._BaseCreateCustomClass._get_unset_required_fields(
|
| 142 |
+
query_params
|
| 143 |
+
)
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 147 |
+
return query_params
|
| 148 |
+
|
| 149 |
+
class _BaseCreatePhraseSet:
|
| 150 |
+
def __hash__(self): # pragma: NO COVER
|
| 151 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 152 |
+
|
| 153 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 154 |
+
|
| 155 |
+
@classmethod
|
| 156 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 157 |
+
return {
|
| 158 |
+
k: v
|
| 159 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 160 |
+
if k not in message_dict
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
@staticmethod
|
| 164 |
+
def _get_http_options():
|
| 165 |
+
http_options: List[Dict[str, str]] = [
|
| 166 |
+
{
|
| 167 |
+
"method": "post",
|
| 168 |
+
"uri": "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets",
|
| 169 |
+
"body": "*",
|
| 170 |
+
},
|
| 171 |
+
]
|
| 172 |
+
return http_options
|
| 173 |
+
|
| 174 |
+
@staticmethod
|
| 175 |
+
def _get_transcoded_request(http_options, request):
|
| 176 |
+
pb_request = cloud_speech_adaptation.CreatePhraseSetRequest.pb(request)
|
| 177 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 178 |
+
return transcoded_request
|
| 179 |
+
|
| 180 |
+
@staticmethod
|
| 181 |
+
def _get_request_body_json(transcoded_request):
|
| 182 |
+
# Jsonify the request body
|
| 183 |
+
|
| 184 |
+
body = json_format.MessageToJson(
|
| 185 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 186 |
+
)
|
| 187 |
+
return body
|
| 188 |
+
|
| 189 |
+
@staticmethod
|
| 190 |
+
def _get_query_params_json(transcoded_request):
|
| 191 |
+
query_params = json.loads(
|
| 192 |
+
json_format.MessageToJson(
|
| 193 |
+
transcoded_request["query_params"],
|
| 194 |
+
use_integers_for_enums=True,
|
| 195 |
+
)
|
| 196 |
+
)
|
| 197 |
+
query_params.update(
|
| 198 |
+
_BaseAdaptationRestTransport._BaseCreatePhraseSet._get_unset_required_fields(
|
| 199 |
+
query_params
|
| 200 |
+
)
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 204 |
+
return query_params
|
| 205 |
+
|
| 206 |
+
class _BaseDeleteCustomClass:
|
| 207 |
+
def __hash__(self): # pragma: NO COVER
|
| 208 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 209 |
+
|
| 210 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 211 |
+
|
| 212 |
+
@classmethod
|
| 213 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 214 |
+
return {
|
| 215 |
+
k: v
|
| 216 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 217 |
+
if k not in message_dict
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
@staticmethod
|
| 221 |
+
def _get_http_options():
|
| 222 |
+
http_options: List[Dict[str, str]] = [
|
| 223 |
+
{
|
| 224 |
+
"method": "delete",
|
| 225 |
+
"uri": "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}",
|
| 226 |
+
},
|
| 227 |
+
]
|
| 228 |
+
return http_options
|
| 229 |
+
|
| 230 |
+
@staticmethod
|
| 231 |
+
def _get_transcoded_request(http_options, request):
|
| 232 |
+
pb_request = cloud_speech_adaptation.DeleteCustomClassRequest.pb(request)
|
| 233 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 234 |
+
return transcoded_request
|
| 235 |
+
|
| 236 |
+
@staticmethod
|
| 237 |
+
def _get_query_params_json(transcoded_request):
|
| 238 |
+
query_params = json.loads(
|
| 239 |
+
json_format.MessageToJson(
|
| 240 |
+
transcoded_request["query_params"],
|
| 241 |
+
use_integers_for_enums=True,
|
| 242 |
+
)
|
| 243 |
+
)
|
| 244 |
+
query_params.update(
|
| 245 |
+
_BaseAdaptationRestTransport._BaseDeleteCustomClass._get_unset_required_fields(
|
| 246 |
+
query_params
|
| 247 |
+
)
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 251 |
+
return query_params
|
| 252 |
+
|
| 253 |
+
class _BaseDeletePhraseSet:
|
| 254 |
+
def __hash__(self): # pragma: NO COVER
|
| 255 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 256 |
+
|
| 257 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 258 |
+
|
| 259 |
+
@classmethod
|
| 260 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 261 |
+
return {
|
| 262 |
+
k: v
|
| 263 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 264 |
+
if k not in message_dict
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
@staticmethod
|
| 268 |
+
def _get_http_options():
|
| 269 |
+
http_options: List[Dict[str, str]] = [
|
| 270 |
+
{
|
| 271 |
+
"method": "delete",
|
| 272 |
+
"uri": "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}",
|
| 273 |
+
},
|
| 274 |
+
]
|
| 275 |
+
return http_options
|
| 276 |
+
|
| 277 |
+
@staticmethod
|
| 278 |
+
def _get_transcoded_request(http_options, request):
|
| 279 |
+
pb_request = cloud_speech_adaptation.DeletePhraseSetRequest.pb(request)
|
| 280 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 281 |
+
return transcoded_request
|
| 282 |
+
|
| 283 |
+
@staticmethod
|
| 284 |
+
def _get_query_params_json(transcoded_request):
|
| 285 |
+
query_params = json.loads(
|
| 286 |
+
json_format.MessageToJson(
|
| 287 |
+
transcoded_request["query_params"],
|
| 288 |
+
use_integers_for_enums=True,
|
| 289 |
+
)
|
| 290 |
+
)
|
| 291 |
+
query_params.update(
|
| 292 |
+
_BaseAdaptationRestTransport._BaseDeletePhraseSet._get_unset_required_fields(
|
| 293 |
+
query_params
|
| 294 |
+
)
|
| 295 |
+
)
|
| 296 |
+
|
| 297 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 298 |
+
return query_params
|
| 299 |
+
|
| 300 |
+
class _BaseGetCustomClass:
|
| 301 |
+
def __hash__(self): # pragma: NO COVER
|
| 302 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 303 |
+
|
| 304 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 305 |
+
|
| 306 |
+
@classmethod
|
| 307 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 308 |
+
return {
|
| 309 |
+
k: v
|
| 310 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 311 |
+
if k not in message_dict
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
@staticmethod
|
| 315 |
+
def _get_http_options():
|
| 316 |
+
http_options: List[Dict[str, str]] = [
|
| 317 |
+
{
|
| 318 |
+
"method": "get",
|
| 319 |
+
"uri": "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}",
|
| 320 |
+
},
|
| 321 |
+
]
|
| 322 |
+
return http_options
|
| 323 |
+
|
| 324 |
+
@staticmethod
|
| 325 |
+
def _get_transcoded_request(http_options, request):
|
| 326 |
+
pb_request = cloud_speech_adaptation.GetCustomClassRequest.pb(request)
|
| 327 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 328 |
+
return transcoded_request
|
| 329 |
+
|
| 330 |
+
@staticmethod
|
| 331 |
+
def _get_query_params_json(transcoded_request):
|
| 332 |
+
query_params = json.loads(
|
| 333 |
+
json_format.MessageToJson(
|
| 334 |
+
transcoded_request["query_params"],
|
| 335 |
+
use_integers_for_enums=True,
|
| 336 |
+
)
|
| 337 |
+
)
|
| 338 |
+
query_params.update(
|
| 339 |
+
_BaseAdaptationRestTransport._BaseGetCustomClass._get_unset_required_fields(
|
| 340 |
+
query_params
|
| 341 |
+
)
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 345 |
+
return query_params
|
| 346 |
+
|
| 347 |
+
class _BaseGetPhraseSet:
|
| 348 |
+
def __hash__(self): # pragma: NO COVER
|
| 349 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 350 |
+
|
| 351 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 352 |
+
|
| 353 |
+
@classmethod
|
| 354 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 355 |
+
return {
|
| 356 |
+
k: v
|
| 357 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 358 |
+
if k not in message_dict
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
@staticmethod
|
| 362 |
+
def _get_http_options():
|
| 363 |
+
http_options: List[Dict[str, str]] = [
|
| 364 |
+
{
|
| 365 |
+
"method": "get",
|
| 366 |
+
"uri": "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}",
|
| 367 |
+
},
|
| 368 |
+
]
|
| 369 |
+
return http_options
|
| 370 |
+
|
| 371 |
+
@staticmethod
|
| 372 |
+
def _get_transcoded_request(http_options, request):
|
| 373 |
+
pb_request = cloud_speech_adaptation.GetPhraseSetRequest.pb(request)
|
| 374 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 375 |
+
return transcoded_request
|
| 376 |
+
|
| 377 |
+
@staticmethod
|
| 378 |
+
def _get_query_params_json(transcoded_request):
|
| 379 |
+
query_params = json.loads(
|
| 380 |
+
json_format.MessageToJson(
|
| 381 |
+
transcoded_request["query_params"],
|
| 382 |
+
use_integers_for_enums=True,
|
| 383 |
+
)
|
| 384 |
+
)
|
| 385 |
+
query_params.update(
|
| 386 |
+
_BaseAdaptationRestTransport._BaseGetPhraseSet._get_unset_required_fields(
|
| 387 |
+
query_params
|
| 388 |
+
)
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 392 |
+
return query_params
|
| 393 |
+
|
| 394 |
+
class _BaseListCustomClasses:
|
| 395 |
+
def __hash__(self): # pragma: NO COVER
|
| 396 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 397 |
+
|
| 398 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 399 |
+
|
| 400 |
+
@classmethod
|
| 401 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 402 |
+
return {
|
| 403 |
+
k: v
|
| 404 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 405 |
+
if k not in message_dict
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
@staticmethod
|
| 409 |
+
def _get_http_options():
|
| 410 |
+
http_options: List[Dict[str, str]] = [
|
| 411 |
+
{
|
| 412 |
+
"method": "get",
|
| 413 |
+
"uri": "/v1p1beta1/{parent=projects/*/locations/*}/customClasses",
|
| 414 |
+
},
|
| 415 |
+
]
|
| 416 |
+
return http_options
|
| 417 |
+
|
| 418 |
+
@staticmethod
|
| 419 |
+
def _get_transcoded_request(http_options, request):
|
| 420 |
+
pb_request = cloud_speech_adaptation.ListCustomClassesRequest.pb(request)
|
| 421 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 422 |
+
return transcoded_request
|
| 423 |
+
|
| 424 |
+
@staticmethod
|
| 425 |
+
def _get_query_params_json(transcoded_request):
|
| 426 |
+
query_params = json.loads(
|
| 427 |
+
json_format.MessageToJson(
|
| 428 |
+
transcoded_request["query_params"],
|
| 429 |
+
use_integers_for_enums=True,
|
| 430 |
+
)
|
| 431 |
+
)
|
| 432 |
+
query_params.update(
|
| 433 |
+
_BaseAdaptationRestTransport._BaseListCustomClasses._get_unset_required_fields(
|
| 434 |
+
query_params
|
| 435 |
+
)
|
| 436 |
+
)
|
| 437 |
+
|
| 438 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 439 |
+
return query_params
|
| 440 |
+
|
| 441 |
+
class _BaseListPhraseSet:
|
| 442 |
+
def __hash__(self): # pragma: NO COVER
|
| 443 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 444 |
+
|
| 445 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 446 |
+
|
| 447 |
+
@classmethod
|
| 448 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 449 |
+
return {
|
| 450 |
+
k: v
|
| 451 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 452 |
+
if k not in message_dict
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
@staticmethod
|
| 456 |
+
def _get_http_options():
|
| 457 |
+
http_options: List[Dict[str, str]] = [
|
| 458 |
+
{
|
| 459 |
+
"method": "get",
|
| 460 |
+
"uri": "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets",
|
| 461 |
+
},
|
| 462 |
+
]
|
| 463 |
+
return http_options
|
| 464 |
+
|
| 465 |
+
@staticmethod
|
| 466 |
+
def _get_transcoded_request(http_options, request):
|
| 467 |
+
pb_request = cloud_speech_adaptation.ListPhraseSetRequest.pb(request)
|
| 468 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 469 |
+
return transcoded_request
|
| 470 |
+
|
| 471 |
+
@staticmethod
|
| 472 |
+
def _get_query_params_json(transcoded_request):
|
| 473 |
+
query_params = json.loads(
|
| 474 |
+
json_format.MessageToJson(
|
| 475 |
+
transcoded_request["query_params"],
|
| 476 |
+
use_integers_for_enums=True,
|
| 477 |
+
)
|
| 478 |
+
)
|
| 479 |
+
query_params.update(
|
| 480 |
+
_BaseAdaptationRestTransport._BaseListPhraseSet._get_unset_required_fields(
|
| 481 |
+
query_params
|
| 482 |
+
)
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 486 |
+
return query_params
|
| 487 |
+
|
| 488 |
+
class _BaseUpdateCustomClass:
|
| 489 |
+
def __hash__(self): # pragma: NO COVER
|
| 490 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 491 |
+
|
| 492 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 493 |
+
|
| 494 |
+
@classmethod
|
| 495 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 496 |
+
return {
|
| 497 |
+
k: v
|
| 498 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 499 |
+
if k not in message_dict
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
@staticmethod
|
| 503 |
+
def _get_http_options():
|
| 504 |
+
http_options: List[Dict[str, str]] = [
|
| 505 |
+
{
|
| 506 |
+
"method": "patch",
|
| 507 |
+
"uri": "/v1p1beta1/{custom_class.name=projects/*/locations/*/customClasses/*}",
|
| 508 |
+
"body": "custom_class",
|
| 509 |
+
},
|
| 510 |
+
]
|
| 511 |
+
return http_options
|
| 512 |
+
|
| 513 |
+
@staticmethod
|
| 514 |
+
def _get_transcoded_request(http_options, request):
|
| 515 |
+
pb_request = cloud_speech_adaptation.UpdateCustomClassRequest.pb(request)
|
| 516 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 517 |
+
return transcoded_request
|
| 518 |
+
|
| 519 |
+
@staticmethod
|
| 520 |
+
def _get_request_body_json(transcoded_request):
|
| 521 |
+
# Jsonify the request body
|
| 522 |
+
|
| 523 |
+
body = json_format.MessageToJson(
|
| 524 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 525 |
+
)
|
| 526 |
+
return body
|
| 527 |
+
|
| 528 |
+
@staticmethod
|
| 529 |
+
def _get_query_params_json(transcoded_request):
|
| 530 |
+
query_params = json.loads(
|
| 531 |
+
json_format.MessageToJson(
|
| 532 |
+
transcoded_request["query_params"],
|
| 533 |
+
use_integers_for_enums=True,
|
| 534 |
+
)
|
| 535 |
+
)
|
| 536 |
+
query_params.update(
|
| 537 |
+
_BaseAdaptationRestTransport._BaseUpdateCustomClass._get_unset_required_fields(
|
| 538 |
+
query_params
|
| 539 |
+
)
|
| 540 |
+
)
|
| 541 |
+
|
| 542 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 543 |
+
return query_params
|
| 544 |
+
|
| 545 |
+
class _BaseUpdatePhraseSet:
|
| 546 |
+
def __hash__(self): # pragma: NO COVER
|
| 547 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 548 |
+
|
| 549 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 550 |
+
|
| 551 |
+
@classmethod
|
| 552 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 553 |
+
return {
|
| 554 |
+
k: v
|
| 555 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 556 |
+
if k not in message_dict
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
@staticmethod
|
| 560 |
+
def _get_http_options():
|
| 561 |
+
http_options: List[Dict[str, str]] = [
|
| 562 |
+
{
|
| 563 |
+
"method": "patch",
|
| 564 |
+
"uri": "/v1p1beta1/{phrase_set.name=projects/*/locations/*/phraseSets/*}",
|
| 565 |
+
"body": "phrase_set",
|
| 566 |
+
},
|
| 567 |
+
]
|
| 568 |
+
return http_options
|
| 569 |
+
|
| 570 |
+
@staticmethod
|
| 571 |
+
def _get_transcoded_request(http_options, request):
|
| 572 |
+
pb_request = cloud_speech_adaptation.UpdatePhraseSetRequest.pb(request)
|
| 573 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 574 |
+
return transcoded_request
|
| 575 |
+
|
| 576 |
+
@staticmethod
|
| 577 |
+
def _get_request_body_json(transcoded_request):
|
| 578 |
+
# Jsonify the request body
|
| 579 |
+
|
| 580 |
+
body = json_format.MessageToJson(
|
| 581 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 582 |
+
)
|
| 583 |
+
return body
|
| 584 |
+
|
| 585 |
+
@staticmethod
|
| 586 |
+
def _get_query_params_json(transcoded_request):
|
| 587 |
+
query_params = json.loads(
|
| 588 |
+
json_format.MessageToJson(
|
| 589 |
+
transcoded_request["query_params"],
|
| 590 |
+
use_integers_for_enums=True,
|
| 591 |
+
)
|
| 592 |
+
)
|
| 593 |
+
query_params.update(
|
| 594 |
+
_BaseAdaptationRestTransport._BaseUpdatePhraseSet._get_unset_required_fields(
|
| 595 |
+
query_params
|
| 596 |
+
)
|
| 597 |
+
)
|
| 598 |
+
|
| 599 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 600 |
+
return query_params
|
| 601 |
+
|
| 602 |
+
class _BaseGetOperation:
|
| 603 |
+
def __hash__(self): # pragma: NO COVER
|
| 604 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 605 |
+
|
| 606 |
+
@staticmethod
|
| 607 |
+
def _get_http_options():
|
| 608 |
+
http_options: List[Dict[str, str]] = [
|
| 609 |
+
{
|
| 610 |
+
"method": "get",
|
| 611 |
+
"uri": "/v1p1beta1/operations/{name=**}",
|
| 612 |
+
},
|
| 613 |
+
]
|
| 614 |
+
return http_options
|
| 615 |
+
|
| 616 |
+
@staticmethod
|
| 617 |
+
def _get_transcoded_request(http_options, request):
|
| 618 |
+
request_kwargs = json_format.MessageToDict(request)
|
| 619 |
+
transcoded_request = path_template.transcode(http_options, **request_kwargs)
|
| 620 |
+
return transcoded_request
|
| 621 |
+
|
| 622 |
+
@staticmethod
|
| 623 |
+
def _get_query_params_json(transcoded_request):
|
| 624 |
+
query_params = json.loads(json.dumps(transcoded_request["query_params"]))
|
| 625 |
+
return query_params
|
| 626 |
+
|
| 627 |
+
class _BaseListOperations:
|
| 628 |
+
def __hash__(self): # pragma: NO COVER
|
| 629 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 630 |
+
|
| 631 |
+
@staticmethod
|
| 632 |
+
def _get_http_options():
|
| 633 |
+
http_options: List[Dict[str, str]] = [
|
| 634 |
+
{
|
| 635 |
+
"method": "get",
|
| 636 |
+
"uri": "/v1p1beta1/operations",
|
| 637 |
+
},
|
| 638 |
+
]
|
| 639 |
+
return http_options
|
| 640 |
+
|
| 641 |
+
@staticmethod
|
| 642 |
+
def _get_transcoded_request(http_options, request):
|
| 643 |
+
request_kwargs = json_format.MessageToDict(request)
|
| 644 |
+
transcoded_request = path_template.transcode(http_options, **request_kwargs)
|
| 645 |
+
return transcoded_request
|
| 646 |
+
|
| 647 |
+
@staticmethod
|
| 648 |
+
def _get_query_params_json(transcoded_request):
|
| 649 |
+
query_params = json.loads(json.dumps(transcoded_request["query_params"]))
|
| 650 |
+
return query_params
|
| 651 |
+
|
| 652 |
+
|
| 653 |
+
__all__ = ("_BaseAdaptationRestTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from .async_client import SpeechAsyncClient
|
| 17 |
+
from .client import SpeechClient
|
| 18 |
+
|
| 19 |
+
__all__ = (
|
| 20 |
+
"SpeechClient",
|
| 21 |
+
"SpeechAsyncClient",
|
| 22 |
+
)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/async_client.py
ADDED
|
@@ -0,0 +1,866 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import logging as std_logging
|
| 17 |
+
import re
|
| 18 |
+
from collections import OrderedDict
|
| 19 |
+
from typing import (
|
| 20 |
+
AsyncIterable,
|
| 21 |
+
AsyncIterator,
|
| 22 |
+
Awaitable,
|
| 23 |
+
Callable,
|
| 24 |
+
Dict,
|
| 25 |
+
Mapping,
|
| 26 |
+
MutableMapping,
|
| 27 |
+
MutableSequence,
|
| 28 |
+
Optional,
|
| 29 |
+
Sequence,
|
| 30 |
+
Tuple,
|
| 31 |
+
Type,
|
| 32 |
+
Union,
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
import google.protobuf
|
| 36 |
+
from google.api_core import exceptions as core_exceptions
|
| 37 |
+
from google.api_core import gapic_v1
|
| 38 |
+
from google.api_core import retry_async as retries
|
| 39 |
+
from google.api_core.client_options import ClientOptions
|
| 40 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 41 |
+
from google.oauth2 import service_account # type: ignore
|
| 42 |
+
|
| 43 |
+
from google.cloud.speech_v1p1beta1 import gapic_version as package_version
|
| 44 |
+
|
| 45 |
+
try:
|
| 46 |
+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
|
| 47 |
+
except AttributeError: # pragma: NO COVER
|
| 48 |
+
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
| 49 |
+
|
| 50 |
+
import google.api_core.operation as operation # type: ignore
|
| 51 |
+
import google.api_core.operation_async as operation_async # type: ignore
|
| 52 |
+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
|
| 53 |
+
import google.rpc.status_pb2 as status_pb2 # type: ignore
|
| 54 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 55 |
+
|
| 56 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech
|
| 57 |
+
|
| 58 |
+
from .client import SpeechClient
|
| 59 |
+
from .transports.base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 60 |
+
from .transports.grpc_asyncio import SpeechGrpcAsyncIOTransport
|
| 61 |
+
|
| 62 |
+
try:
|
| 63 |
+
from google.api_core import client_logging # type: ignore
|
| 64 |
+
|
| 65 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 66 |
+
except ImportError: # pragma: NO COVER
|
| 67 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 68 |
+
|
| 69 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class SpeechAsyncClient:
|
| 73 |
+
"""Service that implements Google Cloud Speech API."""
|
| 74 |
+
|
| 75 |
+
_client: SpeechClient
|
| 76 |
+
|
| 77 |
+
# Copy defaults from the synchronous client for use here.
|
| 78 |
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
| 79 |
+
DEFAULT_ENDPOINT = SpeechClient.DEFAULT_ENDPOINT
|
| 80 |
+
DEFAULT_MTLS_ENDPOINT = SpeechClient.DEFAULT_MTLS_ENDPOINT
|
| 81 |
+
_DEFAULT_ENDPOINT_TEMPLATE = SpeechClient._DEFAULT_ENDPOINT_TEMPLATE
|
| 82 |
+
_DEFAULT_UNIVERSE = SpeechClient._DEFAULT_UNIVERSE
|
| 83 |
+
|
| 84 |
+
crypto_key_path = staticmethod(SpeechClient.crypto_key_path)
|
| 85 |
+
parse_crypto_key_path = staticmethod(SpeechClient.parse_crypto_key_path)
|
| 86 |
+
crypto_key_version_path = staticmethod(SpeechClient.crypto_key_version_path)
|
| 87 |
+
parse_crypto_key_version_path = staticmethod(
|
| 88 |
+
SpeechClient.parse_crypto_key_version_path
|
| 89 |
+
)
|
| 90 |
+
custom_class_path = staticmethod(SpeechClient.custom_class_path)
|
| 91 |
+
parse_custom_class_path = staticmethod(SpeechClient.parse_custom_class_path)
|
| 92 |
+
phrase_set_path = staticmethod(SpeechClient.phrase_set_path)
|
| 93 |
+
parse_phrase_set_path = staticmethod(SpeechClient.parse_phrase_set_path)
|
| 94 |
+
common_billing_account_path = staticmethod(SpeechClient.common_billing_account_path)
|
| 95 |
+
parse_common_billing_account_path = staticmethod(
|
| 96 |
+
SpeechClient.parse_common_billing_account_path
|
| 97 |
+
)
|
| 98 |
+
common_folder_path = staticmethod(SpeechClient.common_folder_path)
|
| 99 |
+
parse_common_folder_path = staticmethod(SpeechClient.parse_common_folder_path)
|
| 100 |
+
common_organization_path = staticmethod(SpeechClient.common_organization_path)
|
| 101 |
+
parse_common_organization_path = staticmethod(
|
| 102 |
+
SpeechClient.parse_common_organization_path
|
| 103 |
+
)
|
| 104 |
+
common_project_path = staticmethod(SpeechClient.common_project_path)
|
| 105 |
+
parse_common_project_path = staticmethod(SpeechClient.parse_common_project_path)
|
| 106 |
+
common_location_path = staticmethod(SpeechClient.common_location_path)
|
| 107 |
+
parse_common_location_path = staticmethod(SpeechClient.parse_common_location_path)
|
| 108 |
+
|
| 109 |
+
@classmethod
|
| 110 |
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
| 111 |
+
"""Creates an instance of this client using the provided credentials
|
| 112 |
+
info.
|
| 113 |
+
|
| 114 |
+
Args:
|
| 115 |
+
info (dict): The service account private key info.
|
| 116 |
+
args: Additional arguments to pass to the constructor.
|
| 117 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 118 |
+
|
| 119 |
+
Returns:
|
| 120 |
+
SpeechAsyncClient: The constructed client.
|
| 121 |
+
"""
|
| 122 |
+
sa_info_func = (
|
| 123 |
+
SpeechClient.from_service_account_info.__func__ # type: ignore
|
| 124 |
+
)
|
| 125 |
+
return sa_info_func(SpeechAsyncClient, info, *args, **kwargs)
|
| 126 |
+
|
| 127 |
+
@classmethod
|
| 128 |
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
| 129 |
+
"""Creates an instance of this client using the provided credentials
|
| 130 |
+
file.
|
| 131 |
+
|
| 132 |
+
Args:
|
| 133 |
+
filename (str): The path to the service account private key json
|
| 134 |
+
file.
|
| 135 |
+
args: Additional arguments to pass to the constructor.
|
| 136 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 137 |
+
|
| 138 |
+
Returns:
|
| 139 |
+
SpeechAsyncClient: The constructed client.
|
| 140 |
+
"""
|
| 141 |
+
sa_file_func = (
|
| 142 |
+
SpeechClient.from_service_account_file.__func__ # type: ignore
|
| 143 |
+
)
|
| 144 |
+
return sa_file_func(SpeechAsyncClient, filename, *args, **kwargs)
|
| 145 |
+
|
| 146 |
+
from_service_account_json = from_service_account_file
|
| 147 |
+
|
| 148 |
+
@classmethod
|
| 149 |
+
def get_mtls_endpoint_and_cert_source(
|
| 150 |
+
cls, client_options: Optional[ClientOptions] = None
|
| 151 |
+
):
|
| 152 |
+
"""Return the API endpoint and client cert source for mutual TLS.
|
| 153 |
+
|
| 154 |
+
The client cert source is determined in the following order:
|
| 155 |
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
| 156 |
+
client cert source is None.
|
| 157 |
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
| 158 |
+
default client cert source exists, use the default one; otherwise the client cert
|
| 159 |
+
source is None.
|
| 160 |
+
|
| 161 |
+
The API endpoint is determined in the following order:
|
| 162 |
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
| 163 |
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
| 164 |
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
| 165 |
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
| 166 |
+
use the default API endpoint.
|
| 167 |
+
|
| 168 |
+
More details can be found at https://google.aip.dev/auth/4114.
|
| 169 |
+
|
| 170 |
+
Args:
|
| 171 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 172 |
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
| 173 |
+
in this method.
|
| 174 |
+
|
| 175 |
+
Returns:
|
| 176 |
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
| 177 |
+
client cert source to use.
|
| 178 |
+
|
| 179 |
+
Raises:
|
| 180 |
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
| 181 |
+
"""
|
| 182 |
+
return SpeechClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
|
| 183 |
+
|
| 184 |
+
@property
|
| 185 |
+
def transport(self) -> SpeechTransport:
|
| 186 |
+
"""Returns the transport used by the client instance.
|
| 187 |
+
|
| 188 |
+
Returns:
|
| 189 |
+
SpeechTransport: The transport used by the client instance.
|
| 190 |
+
"""
|
| 191 |
+
return self._client.transport
|
| 192 |
+
|
| 193 |
+
@property
|
| 194 |
+
def api_endpoint(self) -> str:
|
| 195 |
+
"""Return the API endpoint used by the client instance.
|
| 196 |
+
|
| 197 |
+
Returns:
|
| 198 |
+
str: The API endpoint used by the client instance.
|
| 199 |
+
"""
|
| 200 |
+
return self._client._api_endpoint
|
| 201 |
+
|
| 202 |
+
@property
|
| 203 |
+
def universe_domain(self) -> str:
|
| 204 |
+
"""Return the universe domain used by the client instance.
|
| 205 |
+
|
| 206 |
+
Returns:
|
| 207 |
+
str: The universe domain used
|
| 208 |
+
by the client instance.
|
| 209 |
+
"""
|
| 210 |
+
return self._client._universe_domain
|
| 211 |
+
|
| 212 |
+
get_transport_class = SpeechClient.get_transport_class
|
| 213 |
+
|
| 214 |
+
def __init__(
|
| 215 |
+
self,
|
| 216 |
+
*,
|
| 217 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 218 |
+
transport: Optional[
|
| 219 |
+
Union[str, SpeechTransport, Callable[..., SpeechTransport]]
|
| 220 |
+
] = "grpc_asyncio",
|
| 221 |
+
client_options: Optional[ClientOptions] = None,
|
| 222 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 223 |
+
) -> None:
|
| 224 |
+
"""Instantiates the speech async client.
|
| 225 |
+
|
| 226 |
+
Args:
|
| 227 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 228 |
+
authorization credentials to attach to requests. These
|
| 229 |
+
credentials identify the application to the service; if none
|
| 230 |
+
are specified, the client will attempt to ascertain the
|
| 231 |
+
credentials from the environment.
|
| 232 |
+
transport (Optional[Union[str,SpeechTransport,Callable[..., SpeechTransport]]]):
|
| 233 |
+
The transport to use, or a Callable that constructs and returns a new transport to use.
|
| 234 |
+
If a Callable is given, it will be called with the same set of initialization
|
| 235 |
+
arguments as used in the SpeechTransport constructor.
|
| 236 |
+
If set to None, a transport is chosen automatically.
|
| 237 |
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
| 238 |
+
Custom options for the client.
|
| 239 |
+
|
| 240 |
+
1. The ``api_endpoint`` property can be used to override the
|
| 241 |
+
default endpoint provided by the client when ``transport`` is
|
| 242 |
+
not explicitly provided. Only if this property is not set and
|
| 243 |
+
``transport`` was not explicitly provided, the endpoint is
|
| 244 |
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
| 245 |
+
variable, which have one of the following values:
|
| 246 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 247 |
+
use the default regular endpoint) and "auto" (auto-switch to the
|
| 248 |
+
default mTLS endpoint if client certificate is present; this is
|
| 249 |
+
the default value).
|
| 250 |
+
|
| 251 |
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 252 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 253 |
+
to provide a client certificate for mTLS transport. If
|
| 254 |
+
not provided, the default SSL client certificate will be used if
|
| 255 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 256 |
+
set, no client certificate will be used.
|
| 257 |
+
|
| 258 |
+
3. The ``universe_domain`` property can be used to override the
|
| 259 |
+
default "googleapis.com" universe. Note that ``api_endpoint``
|
| 260 |
+
property still takes precedence; and ``universe_domain`` is
|
| 261 |
+
currently not supported for mTLS.
|
| 262 |
+
|
| 263 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 264 |
+
The client info used to send a user-agent string along with
|
| 265 |
+
API requests. If ``None``, then default info will be used.
|
| 266 |
+
Generally, you only need to set this if you're developing
|
| 267 |
+
your own client library.
|
| 268 |
+
|
| 269 |
+
Raises:
|
| 270 |
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
| 271 |
+
creation failed for any reason.
|
| 272 |
+
"""
|
| 273 |
+
self._client = SpeechClient(
|
| 274 |
+
credentials=credentials,
|
| 275 |
+
transport=transport,
|
| 276 |
+
client_options=client_options,
|
| 277 |
+
client_info=client_info,
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 281 |
+
std_logging.DEBUG
|
| 282 |
+
): # pragma: NO COVER
|
| 283 |
+
_LOGGER.debug(
|
| 284 |
+
"Created client `google.cloud.speech_v1p1beta1.SpeechAsyncClient`.",
|
| 285 |
+
extra={
|
| 286 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 287 |
+
"universeDomain": getattr(
|
| 288 |
+
self._client._transport._credentials, "universe_domain", ""
|
| 289 |
+
),
|
| 290 |
+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
|
| 291 |
+
"credentialsInfo": getattr(
|
| 292 |
+
self.transport._credentials, "get_cred_info", lambda: None
|
| 293 |
+
)(),
|
| 294 |
+
}
|
| 295 |
+
if hasattr(self._client._transport, "_credentials")
|
| 296 |
+
else {
|
| 297 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 298 |
+
"credentialsType": None,
|
| 299 |
+
},
|
| 300 |
+
)
|
| 301 |
+
|
| 302 |
+
async def recognize(
|
| 303 |
+
self,
|
| 304 |
+
request: Optional[Union[cloud_speech.RecognizeRequest, dict]] = None,
|
| 305 |
+
*,
|
| 306 |
+
config: Optional[cloud_speech.RecognitionConfig] = None,
|
| 307 |
+
audio: Optional[cloud_speech.RecognitionAudio] = None,
|
| 308 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 309 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 310 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 311 |
+
) -> cloud_speech.RecognizeResponse:
|
| 312 |
+
r"""Performs synchronous speech recognition: receive
|
| 313 |
+
results after all audio has been sent and processed.
|
| 314 |
+
|
| 315 |
+
.. code-block:: python
|
| 316 |
+
|
| 317 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 318 |
+
# code template only.
|
| 319 |
+
# It will require modifications to work:
|
| 320 |
+
# - It may require correct/in-range values for request initialization.
|
| 321 |
+
# - It may require specifying regional endpoints when creating the service
|
| 322 |
+
# client as shown in:
|
| 323 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 324 |
+
from google.cloud import speech_v1p1beta1
|
| 325 |
+
|
| 326 |
+
async def sample_recognize():
|
| 327 |
+
# Create a client
|
| 328 |
+
client = speech_v1p1beta1.SpeechAsyncClient()
|
| 329 |
+
|
| 330 |
+
# Initialize request argument(s)
|
| 331 |
+
config = speech_v1p1beta1.RecognitionConfig()
|
| 332 |
+
config.language_code = "language_code_value"
|
| 333 |
+
|
| 334 |
+
audio = speech_v1p1beta1.RecognitionAudio()
|
| 335 |
+
audio.content = b'content_blob'
|
| 336 |
+
|
| 337 |
+
request = speech_v1p1beta1.RecognizeRequest(
|
| 338 |
+
config=config,
|
| 339 |
+
audio=audio,
|
| 340 |
+
)
|
| 341 |
+
|
| 342 |
+
# Make the request
|
| 343 |
+
response = await client.recognize(request=request)
|
| 344 |
+
|
| 345 |
+
# Handle the response
|
| 346 |
+
print(response)
|
| 347 |
+
|
| 348 |
+
Args:
|
| 349 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.RecognizeRequest, dict]]):
|
| 350 |
+
The request object. The top-level message sent by the client for the
|
| 351 |
+
``Recognize`` method.
|
| 352 |
+
config (:class:`google.cloud.speech_v1p1beta1.types.RecognitionConfig`):
|
| 353 |
+
Required. Provides information to the
|
| 354 |
+
recognizer that specifies how to process
|
| 355 |
+
the request.
|
| 356 |
+
|
| 357 |
+
This corresponds to the ``config`` field
|
| 358 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 359 |
+
should not be set.
|
| 360 |
+
audio (:class:`google.cloud.speech_v1p1beta1.types.RecognitionAudio`):
|
| 361 |
+
Required. The audio data to be
|
| 362 |
+
recognized.
|
| 363 |
+
|
| 364 |
+
This corresponds to the ``audio`` field
|
| 365 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 366 |
+
should not be set.
|
| 367 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 368 |
+
should be retried.
|
| 369 |
+
timeout (float): The timeout for this request.
|
| 370 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 371 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 372 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 373 |
+
be of type `bytes`.
|
| 374 |
+
|
| 375 |
+
Returns:
|
| 376 |
+
google.cloud.speech_v1p1beta1.types.RecognizeResponse:
|
| 377 |
+
The only message returned to the client by the Recognize method. It
|
| 378 |
+
contains the result as zero or more sequential
|
| 379 |
+
SpeechRecognitionResult messages.
|
| 380 |
+
|
| 381 |
+
"""
|
| 382 |
+
# Create or coerce a protobuf request object.
|
| 383 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 384 |
+
# gotten any keyword arguments that map to the request.
|
| 385 |
+
flattened_params = [config, audio]
|
| 386 |
+
has_flattened_params = (
|
| 387 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 388 |
+
)
|
| 389 |
+
if request is not None and has_flattened_params:
|
| 390 |
+
raise ValueError(
|
| 391 |
+
"If the `request` argument is set, then none of "
|
| 392 |
+
"the individual field arguments should be set."
|
| 393 |
+
)
|
| 394 |
+
|
| 395 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 396 |
+
# there are no flattened fields), or create one.
|
| 397 |
+
if not isinstance(request, cloud_speech.RecognizeRequest):
|
| 398 |
+
request = cloud_speech.RecognizeRequest(request)
|
| 399 |
+
|
| 400 |
+
# If we have keyword arguments corresponding to fields on the
|
| 401 |
+
# request, apply these.
|
| 402 |
+
if config is not None:
|
| 403 |
+
request.config = config
|
| 404 |
+
if audio is not None:
|
| 405 |
+
request.audio = audio
|
| 406 |
+
|
| 407 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 408 |
+
# and friendly error handling.
|
| 409 |
+
rpc = self._client._transport._wrapped_methods[
|
| 410 |
+
self._client._transport.recognize
|
| 411 |
+
]
|
| 412 |
+
|
| 413 |
+
# Validate the universe domain.
|
| 414 |
+
self._client._validate_universe_domain()
|
| 415 |
+
|
| 416 |
+
# Send the request.
|
| 417 |
+
response = await rpc(
|
| 418 |
+
request,
|
| 419 |
+
retry=retry,
|
| 420 |
+
timeout=timeout,
|
| 421 |
+
metadata=metadata,
|
| 422 |
+
)
|
| 423 |
+
|
| 424 |
+
# Done; return the response.
|
| 425 |
+
return response
|
| 426 |
+
|
| 427 |
+
async def long_running_recognize(
|
| 428 |
+
self,
|
| 429 |
+
request: Optional[Union[cloud_speech.LongRunningRecognizeRequest, dict]] = None,
|
| 430 |
+
*,
|
| 431 |
+
config: Optional[cloud_speech.RecognitionConfig] = None,
|
| 432 |
+
audio: Optional[cloud_speech.RecognitionAudio] = None,
|
| 433 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 434 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 435 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 436 |
+
) -> operation_async.AsyncOperation:
|
| 437 |
+
r"""Performs asynchronous speech recognition: receive results via
|
| 438 |
+
the google.longrunning.Operations interface. Returns either an
|
| 439 |
+
``Operation.error`` or an ``Operation.response`` which contains
|
| 440 |
+
a ``LongRunningRecognizeResponse`` message. For more information
|
| 441 |
+
on asynchronous speech recognition, see the
|
| 442 |
+
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
|
| 443 |
+
|
| 444 |
+
.. code-block:: python
|
| 445 |
+
|
| 446 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 447 |
+
# code template only.
|
| 448 |
+
# It will require modifications to work:
|
| 449 |
+
# - It may require correct/in-range values for request initialization.
|
| 450 |
+
# - It may require specifying regional endpoints when creating the service
|
| 451 |
+
# client as shown in:
|
| 452 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 453 |
+
from google.cloud import speech_v1p1beta1
|
| 454 |
+
|
| 455 |
+
async def sample_long_running_recognize():
|
| 456 |
+
# Create a client
|
| 457 |
+
client = speech_v1p1beta1.SpeechAsyncClient()
|
| 458 |
+
|
| 459 |
+
# Initialize request argument(s)
|
| 460 |
+
config = speech_v1p1beta1.RecognitionConfig()
|
| 461 |
+
config.language_code = "language_code_value"
|
| 462 |
+
|
| 463 |
+
audio = speech_v1p1beta1.RecognitionAudio()
|
| 464 |
+
audio.content = b'content_blob'
|
| 465 |
+
|
| 466 |
+
request = speech_v1p1beta1.LongRunningRecognizeRequest(
|
| 467 |
+
config=config,
|
| 468 |
+
audio=audio,
|
| 469 |
+
)
|
| 470 |
+
|
| 471 |
+
# Make the request
|
| 472 |
+
operation = client.long_running_recognize(request=request)
|
| 473 |
+
|
| 474 |
+
print("Waiting for operation to complete...")
|
| 475 |
+
|
| 476 |
+
response = (await operation).result()
|
| 477 |
+
|
| 478 |
+
# Handle the response
|
| 479 |
+
print(response)
|
| 480 |
+
|
| 481 |
+
Args:
|
| 482 |
+
request (Optional[Union[google.cloud.speech_v1p1beta1.types.LongRunningRecognizeRequest, dict]]):
|
| 483 |
+
The request object. The top-level message sent by the client for the
|
| 484 |
+
``LongRunningRecognize`` method.
|
| 485 |
+
config (:class:`google.cloud.speech_v1p1beta1.types.RecognitionConfig`):
|
| 486 |
+
Required. Provides information to the
|
| 487 |
+
recognizer that specifies how to process
|
| 488 |
+
the request.
|
| 489 |
+
|
| 490 |
+
This corresponds to the ``config`` field
|
| 491 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 492 |
+
should not be set.
|
| 493 |
+
audio (:class:`google.cloud.speech_v1p1beta1.types.RecognitionAudio`):
|
| 494 |
+
Required. The audio data to be
|
| 495 |
+
recognized.
|
| 496 |
+
|
| 497 |
+
This corresponds to the ``audio`` field
|
| 498 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 499 |
+
should not be set.
|
| 500 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 501 |
+
should be retried.
|
| 502 |
+
timeout (float): The timeout for this request.
|
| 503 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 504 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 505 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 506 |
+
be of type `bytes`.
|
| 507 |
+
|
| 508 |
+
Returns:
|
| 509 |
+
google.api_core.operation_async.AsyncOperation:
|
| 510 |
+
An object representing a long-running operation.
|
| 511 |
+
|
| 512 |
+
The result type for the operation will be :class:`google.cloud.speech_v1p1beta1.types.LongRunningRecognizeResponse` The only message returned to the client by the LongRunningRecognize method.
|
| 513 |
+
It contains the result as zero or more sequential
|
| 514 |
+
SpeechRecognitionResult messages. It is included in
|
| 515 |
+
the result.response field of the Operation returned
|
| 516 |
+
by the GetOperation call of the
|
| 517 |
+
google::longrunning::Operations service.
|
| 518 |
+
|
| 519 |
+
"""
|
| 520 |
+
# Create or coerce a protobuf request object.
|
| 521 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 522 |
+
# gotten any keyword arguments that map to the request.
|
| 523 |
+
flattened_params = [config, audio]
|
| 524 |
+
has_flattened_params = (
|
| 525 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 526 |
+
)
|
| 527 |
+
if request is not None and has_flattened_params:
|
| 528 |
+
raise ValueError(
|
| 529 |
+
"If the `request` argument is set, then none of "
|
| 530 |
+
"the individual field arguments should be set."
|
| 531 |
+
)
|
| 532 |
+
|
| 533 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 534 |
+
# there are no flattened fields), or create one.
|
| 535 |
+
if not isinstance(request, cloud_speech.LongRunningRecognizeRequest):
|
| 536 |
+
request = cloud_speech.LongRunningRecognizeRequest(request)
|
| 537 |
+
|
| 538 |
+
# If we have keyword arguments corresponding to fields on the
|
| 539 |
+
# request, apply these.
|
| 540 |
+
if config is not None:
|
| 541 |
+
request.config = config
|
| 542 |
+
if audio is not None:
|
| 543 |
+
request.audio = audio
|
| 544 |
+
|
| 545 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 546 |
+
# and friendly error handling.
|
| 547 |
+
rpc = self._client._transport._wrapped_methods[
|
| 548 |
+
self._client._transport.long_running_recognize
|
| 549 |
+
]
|
| 550 |
+
|
| 551 |
+
# Validate the universe domain.
|
| 552 |
+
self._client._validate_universe_domain()
|
| 553 |
+
|
| 554 |
+
# Send the request.
|
| 555 |
+
response = await rpc(
|
| 556 |
+
request,
|
| 557 |
+
retry=retry,
|
| 558 |
+
timeout=timeout,
|
| 559 |
+
metadata=metadata,
|
| 560 |
+
)
|
| 561 |
+
|
| 562 |
+
# Wrap the response in an operation future.
|
| 563 |
+
response = operation_async.from_gapic(
|
| 564 |
+
response,
|
| 565 |
+
self._client._transport.operations_client,
|
| 566 |
+
cloud_speech.LongRunningRecognizeResponse,
|
| 567 |
+
metadata_type=cloud_speech.LongRunningRecognizeMetadata,
|
| 568 |
+
)
|
| 569 |
+
|
| 570 |
+
# Done; return the response.
|
| 571 |
+
return response
|
| 572 |
+
|
| 573 |
+
def streaming_recognize(
|
| 574 |
+
self,
|
| 575 |
+
requests: Optional[
|
| 576 |
+
AsyncIterator[cloud_speech.StreamingRecognizeRequest]
|
| 577 |
+
] = None,
|
| 578 |
+
*,
|
| 579 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 580 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 581 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 582 |
+
) -> Awaitable[AsyncIterable[cloud_speech.StreamingRecognizeResponse]]:
|
| 583 |
+
r"""Performs bidirectional streaming speech recognition:
|
| 584 |
+
receive results while sending audio. This method is only
|
| 585 |
+
available via the gRPC API (not REST).
|
| 586 |
+
|
| 587 |
+
.. code-block:: python
|
| 588 |
+
|
| 589 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 590 |
+
# code template only.
|
| 591 |
+
# It will require modifications to work:
|
| 592 |
+
# - It may require correct/in-range values for request initialization.
|
| 593 |
+
# - It may require specifying regional endpoints when creating the service
|
| 594 |
+
# client as shown in:
|
| 595 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 596 |
+
from google.cloud import speech_v1p1beta1
|
| 597 |
+
|
| 598 |
+
async def sample_streaming_recognize():
|
| 599 |
+
# Create a client
|
| 600 |
+
client = speech_v1p1beta1.SpeechAsyncClient()
|
| 601 |
+
|
| 602 |
+
# Initialize request argument(s)
|
| 603 |
+
streaming_config = speech_v1p1beta1.StreamingRecognitionConfig()
|
| 604 |
+
streaming_config.config.language_code = "language_code_value"
|
| 605 |
+
|
| 606 |
+
request = speech_v1p1beta1.StreamingRecognizeRequest(
|
| 607 |
+
streaming_config=streaming_config,
|
| 608 |
+
)
|
| 609 |
+
|
| 610 |
+
# This method expects an iterator which contains
|
| 611 |
+
# 'speech_v1p1beta1.StreamingRecognizeRequest' objects
|
| 612 |
+
# Here we create a generator that yields a single `request` for
|
| 613 |
+
# demonstrative purposes.
|
| 614 |
+
requests = [request]
|
| 615 |
+
|
| 616 |
+
def request_generator():
|
| 617 |
+
for request in requests:
|
| 618 |
+
yield request
|
| 619 |
+
|
| 620 |
+
# Make the request
|
| 621 |
+
stream = await client.streaming_recognize(requests=request_generator())
|
| 622 |
+
|
| 623 |
+
# Handle the response
|
| 624 |
+
async for response in stream:
|
| 625 |
+
print(response)
|
| 626 |
+
|
| 627 |
+
Args:
|
| 628 |
+
requests (AsyncIterator[`google.cloud.speech_v1p1beta1.types.StreamingRecognizeRequest`]):
|
| 629 |
+
The request object AsyncIterator. The top-level message sent by the client for the
|
| 630 |
+
``StreamingRecognize`` method. Multiple
|
| 631 |
+
``StreamingRecognizeRequest`` messages are sent. The
|
| 632 |
+
first message must contain a ``streaming_config``
|
| 633 |
+
message and must not contain ``audio_content``. All
|
| 634 |
+
subsequent messages must contain ``audio_content`` and
|
| 635 |
+
must not contain a ``streaming_config`` message.
|
| 636 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
| 637 |
+
should be retried.
|
| 638 |
+
timeout (float): The timeout for this request.
|
| 639 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 640 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 641 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 642 |
+
be of type `bytes`.
|
| 643 |
+
|
| 644 |
+
Returns:
|
| 645 |
+
AsyncIterable[google.cloud.speech_v1p1beta1.types.StreamingRecognizeResponse]:
|
| 646 |
+
StreamingRecognizeResponse is the only message returned to the client by
|
| 647 |
+
StreamingRecognize. A series of zero or more
|
| 648 |
+
StreamingRecognizeResponse messages are streamed back
|
| 649 |
+
to the client. If there is no recognizable audio, and
|
| 650 |
+
single_utterance is set to false, then no messages
|
| 651 |
+
are streamed back to the client.
|
| 652 |
+
|
| 653 |
+
Here's an example of a series of
|
| 654 |
+
\`StreamingRecognizeResponse`s that might be returned
|
| 655 |
+
while processing audio:
|
| 656 |
+
|
| 657 |
+
1. results { alternatives { transcript: "tube" }
|
| 658 |
+
stability: 0.01 }
|
| 659 |
+
|
| 660 |
+
2. results { alternatives { transcript: "to be a" }
|
| 661 |
+
stability: 0.01 }
|
| 662 |
+
|
| 663 |
+
3. results { alternatives { transcript: "to be" }
|
| 664 |
+
stability: 0.9 } results { alternatives {
|
| 665 |
+
transcript: " or not to be" } stability: 0.01 }
|
| 666 |
+
|
| 667 |
+
4.
|
| 668 |
+
|
| 669 |
+
results { alternatives { transcript: "to be or not to be"
|
| 670 |
+
confidence: 0.92 } alternatives { transcript:
|
| 671 |
+
"to bee or not to bee" } is_final: true }
|
| 672 |
+
|
| 673 |
+
5. results { alternatives { transcript: " that's" }
|
| 674 |
+
stability: 0.01 }
|
| 675 |
+
|
| 676 |
+
6. results { alternatives { transcript: " that is" }
|
| 677 |
+
stability: 0.9 } results { alternatives {
|
| 678 |
+
transcript: " the question" } stability: 0.01 }
|
| 679 |
+
|
| 680 |
+
7.
|
| 681 |
+
|
| 682 |
+
results { alternatives { transcript: " that is the question"
|
| 683 |
+
confidence: 0.98 } alternatives { transcript: "
|
| 684 |
+
that was the question" } is_final: true }
|
| 685 |
+
|
| 686 |
+
Notes:
|
| 687 |
+
|
| 688 |
+
- Only two of the above responses #4 and #7 contain
|
| 689 |
+
final results; they are indicated by is_final:
|
| 690 |
+
true. Concatenating these together generates the
|
| 691 |
+
full transcript: "to be or not to be that is the
|
| 692 |
+
question".
|
| 693 |
+
|
| 694 |
+
- The others contain interim results. #3 and #6
|
| 695 |
+
contain two interim \`results\`: the first portion
|
| 696 |
+
has a high stability and is less likely to change;
|
| 697 |
+
the second portion has a low stability and is very
|
| 698 |
+
likely to change. A UI designer might choose to
|
| 699 |
+
show only high stability results.
|
| 700 |
+
|
| 701 |
+
- The specific stability and confidence values shown
|
| 702 |
+
above are only for illustrative purposes. Actual
|
| 703 |
+
values may vary.
|
| 704 |
+
|
| 705 |
+
-
|
| 706 |
+
|
| 707 |
+
In each response, only one of these fields will be set:
|
| 708 |
+
error, speech_event_type, or one or more
|
| 709 |
+
(repeated) results.
|
| 710 |
+
|
| 711 |
+
"""
|
| 712 |
+
|
| 713 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 714 |
+
# and friendly error handling.
|
| 715 |
+
rpc = self._client._transport._wrapped_methods[
|
| 716 |
+
self._client._transport.streaming_recognize
|
| 717 |
+
]
|
| 718 |
+
|
| 719 |
+
# Validate the universe domain.
|
| 720 |
+
self._client._validate_universe_domain()
|
| 721 |
+
|
| 722 |
+
# Send the request.
|
| 723 |
+
response = rpc(
|
| 724 |
+
requests,
|
| 725 |
+
retry=retry,
|
| 726 |
+
timeout=timeout,
|
| 727 |
+
metadata=metadata,
|
| 728 |
+
)
|
| 729 |
+
|
| 730 |
+
# Done; return the response.
|
| 731 |
+
return response
|
| 732 |
+
|
| 733 |
+
async def list_operations(
|
| 734 |
+
self,
|
| 735 |
+
request: Optional[Union[operations_pb2.ListOperationsRequest, dict]] = None,
|
| 736 |
+
*,
|
| 737 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 738 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 739 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 740 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 741 |
+
r"""Lists operations that match the specified filter in the request.
|
| 742 |
+
|
| 743 |
+
Args:
|
| 744 |
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
| 745 |
+
The request object. Request message for
|
| 746 |
+
`ListOperations` method.
|
| 747 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
| 748 |
+
if any, should be retried.
|
| 749 |
+
timeout (float): The timeout for this request.
|
| 750 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 751 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 752 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 753 |
+
be of type `bytes`.
|
| 754 |
+
Returns:
|
| 755 |
+
~.operations_pb2.ListOperationsResponse:
|
| 756 |
+
Response message for ``ListOperations`` method.
|
| 757 |
+
"""
|
| 758 |
+
# Create or coerce a protobuf request object.
|
| 759 |
+
# The request isn't a proto-plus wrapped type,
|
| 760 |
+
# so it must be constructed via keyword expansion.
|
| 761 |
+
if request is None:
|
| 762 |
+
request_pb = operations_pb2.ListOperationsRequest()
|
| 763 |
+
elif isinstance(request, dict):
|
| 764 |
+
request_pb = operations_pb2.ListOperationsRequest(**request)
|
| 765 |
+
else:
|
| 766 |
+
request_pb = request
|
| 767 |
+
|
| 768 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 769 |
+
# and friendly error handling.
|
| 770 |
+
rpc = self.transport._wrapped_methods[self._client._transport.list_operations]
|
| 771 |
+
|
| 772 |
+
# Certain fields should be provided within the metadata header;
|
| 773 |
+
# add these here.
|
| 774 |
+
metadata = tuple(metadata) + (
|
| 775 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 776 |
+
)
|
| 777 |
+
|
| 778 |
+
# Validate the universe domain.
|
| 779 |
+
self._client._validate_universe_domain()
|
| 780 |
+
|
| 781 |
+
# Send the request.
|
| 782 |
+
response = await rpc(
|
| 783 |
+
request_pb,
|
| 784 |
+
retry=retry,
|
| 785 |
+
timeout=timeout,
|
| 786 |
+
metadata=metadata,
|
| 787 |
+
)
|
| 788 |
+
|
| 789 |
+
# Done; return the response.
|
| 790 |
+
return response
|
| 791 |
+
|
| 792 |
+
async def get_operation(
|
| 793 |
+
self,
|
| 794 |
+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
|
| 795 |
+
*,
|
| 796 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 797 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 798 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 799 |
+
) -> operations_pb2.Operation:
|
| 800 |
+
r"""Gets the latest state of a long-running operation.
|
| 801 |
+
|
| 802 |
+
Args:
|
| 803 |
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
| 804 |
+
The request object. Request message for
|
| 805 |
+
`GetOperation` method.
|
| 806 |
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
| 807 |
+
if any, should be retried.
|
| 808 |
+
timeout (float): The timeout for this request.
|
| 809 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 810 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 811 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 812 |
+
be of type `bytes`.
|
| 813 |
+
Returns:
|
| 814 |
+
~.operations_pb2.Operation:
|
| 815 |
+
An ``Operation`` object.
|
| 816 |
+
"""
|
| 817 |
+
# Create or coerce a protobuf request object.
|
| 818 |
+
# The request isn't a proto-plus wrapped type,
|
| 819 |
+
# so it must be constructed via keyword expansion.
|
| 820 |
+
if request is None:
|
| 821 |
+
request_pb = operations_pb2.GetOperationRequest()
|
| 822 |
+
elif isinstance(request, dict):
|
| 823 |
+
request_pb = operations_pb2.GetOperationRequest(**request)
|
| 824 |
+
else:
|
| 825 |
+
request_pb = request
|
| 826 |
+
|
| 827 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 828 |
+
# and friendly error handling.
|
| 829 |
+
rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
|
| 830 |
+
|
| 831 |
+
# Certain fields should be provided within the metadata header;
|
| 832 |
+
# add these here.
|
| 833 |
+
metadata = tuple(metadata) + (
|
| 834 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 835 |
+
)
|
| 836 |
+
|
| 837 |
+
# Validate the universe domain.
|
| 838 |
+
self._client._validate_universe_domain()
|
| 839 |
+
|
| 840 |
+
# Send the request.
|
| 841 |
+
response = await rpc(
|
| 842 |
+
request_pb,
|
| 843 |
+
retry=retry,
|
| 844 |
+
timeout=timeout,
|
| 845 |
+
metadata=metadata,
|
| 846 |
+
)
|
| 847 |
+
|
| 848 |
+
# Done; return the response.
|
| 849 |
+
return response
|
| 850 |
+
|
| 851 |
+
async def __aenter__(self) -> "SpeechAsyncClient":
|
| 852 |
+
return self
|
| 853 |
+
|
| 854 |
+
async def __aexit__(self, exc_type, exc, tb):
|
| 855 |
+
await self.transport.close()
|
| 856 |
+
|
| 857 |
+
|
| 858 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 859 |
+
gapic_version=package_version.__version__
|
| 860 |
+
)
|
| 861 |
+
|
| 862 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 863 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 864 |
+
|
| 865 |
+
|
| 866 |
+
__all__ = ("SpeechAsyncClient",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/client.py
ADDED
|
@@ -0,0 +1,1374 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json
|
| 17 |
+
import logging as std_logging
|
| 18 |
+
import os
|
| 19 |
+
import re
|
| 20 |
+
import warnings
|
| 21 |
+
from collections import OrderedDict
|
| 22 |
+
from http import HTTPStatus
|
| 23 |
+
from typing import (
|
| 24 |
+
Callable,
|
| 25 |
+
Dict,
|
| 26 |
+
Iterable,
|
| 27 |
+
Iterator,
|
| 28 |
+
Mapping,
|
| 29 |
+
MutableMapping,
|
| 30 |
+
MutableSequence,
|
| 31 |
+
Optional,
|
| 32 |
+
Sequence,
|
| 33 |
+
Tuple,
|
| 34 |
+
Type,
|
| 35 |
+
Union,
|
| 36 |
+
cast,
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
import google.protobuf
|
| 40 |
+
from google.api_core import client_options as client_options_lib
|
| 41 |
+
from google.api_core import exceptions as core_exceptions
|
| 42 |
+
from google.api_core import gapic_v1
|
| 43 |
+
from google.api_core import retry as retries
|
| 44 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 45 |
+
from google.auth.exceptions import MutualTLSChannelError # type: ignore
|
| 46 |
+
from google.auth.transport import mtls # type: ignore
|
| 47 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 48 |
+
from google.oauth2 import service_account # type: ignore
|
| 49 |
+
|
| 50 |
+
from google.cloud.speech_v1p1beta1 import gapic_version as package_version
|
| 51 |
+
|
| 52 |
+
try:
|
| 53 |
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
| 54 |
+
except AttributeError: # pragma: NO COVER
|
| 55 |
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
from google.api_core import client_logging # type: ignore
|
| 59 |
+
|
| 60 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 61 |
+
except ImportError: # pragma: NO COVER
|
| 62 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 63 |
+
|
| 64 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 65 |
+
|
| 66 |
+
import google.api_core.operation as operation # type: ignore
|
| 67 |
+
import google.api_core.operation_async as operation_async # type: ignore
|
| 68 |
+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
|
| 69 |
+
import google.rpc.status_pb2 as status_pb2 # type: ignore
|
| 70 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 71 |
+
|
| 72 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech
|
| 73 |
+
|
| 74 |
+
from .transports.base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 75 |
+
from .transports.grpc import SpeechGrpcTransport
|
| 76 |
+
from .transports.grpc_asyncio import SpeechGrpcAsyncIOTransport
|
| 77 |
+
from .transports.rest import SpeechRestTransport
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class SpeechClientMeta(type):
|
| 81 |
+
"""Metaclass for the Speech client.
|
| 82 |
+
|
| 83 |
+
This provides class-level methods for building and retrieving
|
| 84 |
+
support objects (e.g. transport) without polluting the client instance
|
| 85 |
+
objects.
|
| 86 |
+
"""
|
| 87 |
+
|
| 88 |
+
_transport_registry = OrderedDict() # type: Dict[str, Type[SpeechTransport]]
|
| 89 |
+
_transport_registry["grpc"] = SpeechGrpcTransport
|
| 90 |
+
_transport_registry["grpc_asyncio"] = SpeechGrpcAsyncIOTransport
|
| 91 |
+
_transport_registry["rest"] = SpeechRestTransport
|
| 92 |
+
|
| 93 |
+
def get_transport_class(
|
| 94 |
+
cls,
|
| 95 |
+
label: Optional[str] = None,
|
| 96 |
+
) -> Type[SpeechTransport]:
|
| 97 |
+
"""Returns an appropriate transport class.
|
| 98 |
+
|
| 99 |
+
Args:
|
| 100 |
+
label: The name of the desired transport. If none is
|
| 101 |
+
provided, then the first transport in the registry is used.
|
| 102 |
+
|
| 103 |
+
Returns:
|
| 104 |
+
The transport class to use.
|
| 105 |
+
"""
|
| 106 |
+
# If a specific transport is requested, return that one.
|
| 107 |
+
if label:
|
| 108 |
+
return cls._transport_registry[label]
|
| 109 |
+
|
| 110 |
+
# No transport is requested; return the default (that is, the first one
|
| 111 |
+
# in the dictionary).
|
| 112 |
+
return next(iter(cls._transport_registry.values()))
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
class SpeechClient(metaclass=SpeechClientMeta):
|
| 116 |
+
"""Service that implements Google Cloud Speech API."""
|
| 117 |
+
|
| 118 |
+
@staticmethod
|
| 119 |
+
def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
|
| 120 |
+
"""Converts api endpoint to mTLS endpoint.
|
| 121 |
+
|
| 122 |
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
| 123 |
+
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
| 124 |
+
Args:
|
| 125 |
+
api_endpoint (Optional[str]): the api endpoint to convert.
|
| 126 |
+
Returns:
|
| 127 |
+
Optional[str]: converted mTLS api endpoint.
|
| 128 |
+
"""
|
| 129 |
+
if not api_endpoint:
|
| 130 |
+
return api_endpoint
|
| 131 |
+
|
| 132 |
+
mtls_endpoint_re = re.compile(
|
| 133 |
+
r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
m = mtls_endpoint_re.match(api_endpoint)
|
| 137 |
+
if m is None:
|
| 138 |
+
# Could not parse api_endpoint; return as-is.
|
| 139 |
+
return api_endpoint
|
| 140 |
+
|
| 141 |
+
name, mtls, sandbox, googledomain = m.groups()
|
| 142 |
+
if mtls or not googledomain:
|
| 143 |
+
return api_endpoint
|
| 144 |
+
|
| 145 |
+
if sandbox:
|
| 146 |
+
return api_endpoint.replace(
|
| 147 |
+
"sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
|
| 151 |
+
|
| 152 |
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
| 153 |
+
DEFAULT_ENDPOINT = "speech.googleapis.com"
|
| 154 |
+
DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
|
| 155 |
+
DEFAULT_ENDPOINT
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
_DEFAULT_ENDPOINT_TEMPLATE = "speech.{UNIVERSE_DOMAIN}"
|
| 159 |
+
_DEFAULT_UNIVERSE = "googleapis.com"
|
| 160 |
+
|
| 161 |
+
@staticmethod
|
| 162 |
+
def _use_client_cert_effective():
|
| 163 |
+
"""Returns whether client certificate should be used for mTLS if the
|
| 164 |
+
google-auth version supports should_use_client_cert automatic mTLS enablement.
|
| 165 |
+
|
| 166 |
+
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
|
| 167 |
+
|
| 168 |
+
Returns:
|
| 169 |
+
bool: whether client certificate should be used for mTLS
|
| 170 |
+
Raises:
|
| 171 |
+
ValueError: (If using a version of google-auth without should_use_client_cert and
|
| 172 |
+
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
|
| 173 |
+
"""
|
| 174 |
+
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
|
| 175 |
+
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
|
| 176 |
+
return mtls.should_use_client_cert()
|
| 177 |
+
else: # pragma: NO COVER
|
| 178 |
+
# if unsupported, fallback to reading from env var
|
| 179 |
+
use_client_cert_str = os.getenv(
|
| 180 |
+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
| 181 |
+
).lower()
|
| 182 |
+
if use_client_cert_str not in ("true", "false"):
|
| 183 |
+
raise ValueError(
|
| 184 |
+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
|
| 185 |
+
" either `true` or `false`"
|
| 186 |
+
)
|
| 187 |
+
return use_client_cert_str == "true"
|
| 188 |
+
|
| 189 |
+
@classmethod
|
| 190 |
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
| 191 |
+
"""Creates an instance of this client using the provided credentials
|
| 192 |
+
info.
|
| 193 |
+
|
| 194 |
+
Args:
|
| 195 |
+
info (dict): The service account private key info.
|
| 196 |
+
args: Additional arguments to pass to the constructor.
|
| 197 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 198 |
+
|
| 199 |
+
Returns:
|
| 200 |
+
SpeechClient: The constructed client.
|
| 201 |
+
"""
|
| 202 |
+
credentials = service_account.Credentials.from_service_account_info(info)
|
| 203 |
+
kwargs["credentials"] = credentials
|
| 204 |
+
return cls(*args, **kwargs)
|
| 205 |
+
|
| 206 |
+
@classmethod
|
| 207 |
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
| 208 |
+
"""Creates an instance of this client using the provided credentials
|
| 209 |
+
file.
|
| 210 |
+
|
| 211 |
+
Args:
|
| 212 |
+
filename (str): The path to the service account private key json
|
| 213 |
+
file.
|
| 214 |
+
args: Additional arguments to pass to the constructor.
|
| 215 |
+
kwargs: Additional arguments to pass to the constructor.
|
| 216 |
+
|
| 217 |
+
Returns:
|
| 218 |
+
SpeechClient: The constructed client.
|
| 219 |
+
"""
|
| 220 |
+
credentials = service_account.Credentials.from_service_account_file(filename)
|
| 221 |
+
kwargs["credentials"] = credentials
|
| 222 |
+
return cls(*args, **kwargs)
|
| 223 |
+
|
| 224 |
+
from_service_account_json = from_service_account_file
|
| 225 |
+
|
| 226 |
+
@property
|
| 227 |
+
def transport(self) -> SpeechTransport:
|
| 228 |
+
"""Returns the transport used by the client instance.
|
| 229 |
+
|
| 230 |
+
Returns:
|
| 231 |
+
SpeechTransport: The transport used by the client
|
| 232 |
+
instance.
|
| 233 |
+
"""
|
| 234 |
+
return self._transport
|
| 235 |
+
|
| 236 |
+
@staticmethod
|
| 237 |
+
def crypto_key_path(
|
| 238 |
+
project: str,
|
| 239 |
+
location: str,
|
| 240 |
+
key_ring: str,
|
| 241 |
+
crypto_key: str,
|
| 242 |
+
) -> str:
|
| 243 |
+
"""Returns a fully-qualified crypto_key string."""
|
| 244 |
+
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format(
|
| 245 |
+
project=project,
|
| 246 |
+
location=location,
|
| 247 |
+
key_ring=key_ring,
|
| 248 |
+
crypto_key=crypto_key,
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
@staticmethod
|
| 252 |
+
def parse_crypto_key_path(path: str) -> Dict[str, str]:
|
| 253 |
+
"""Parses a crypto_key path into its component segments."""
|
| 254 |
+
m = re.match(
|
| 255 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)$",
|
| 256 |
+
path,
|
| 257 |
+
)
|
| 258 |
+
return m.groupdict() if m else {}
|
| 259 |
+
|
| 260 |
+
@staticmethod
|
| 261 |
+
def crypto_key_version_path(
|
| 262 |
+
project: str,
|
| 263 |
+
location: str,
|
| 264 |
+
key_ring: str,
|
| 265 |
+
crypto_key: str,
|
| 266 |
+
crypto_key_version: str,
|
| 267 |
+
) -> str:
|
| 268 |
+
"""Returns a fully-qualified crypto_key_version string."""
|
| 269 |
+
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format(
|
| 270 |
+
project=project,
|
| 271 |
+
location=location,
|
| 272 |
+
key_ring=key_ring,
|
| 273 |
+
crypto_key=crypto_key,
|
| 274 |
+
crypto_key_version=crypto_key_version,
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
@staticmethod
|
| 278 |
+
def parse_crypto_key_version_path(path: str) -> Dict[str, str]:
|
| 279 |
+
"""Parses a crypto_key_version path into its component segments."""
|
| 280 |
+
m = re.match(
|
| 281 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)/cryptoKeyVersions/(?P<crypto_key_version>.+?)$",
|
| 282 |
+
path,
|
| 283 |
+
)
|
| 284 |
+
return m.groupdict() if m else {}
|
| 285 |
+
|
| 286 |
+
@staticmethod
|
| 287 |
+
def custom_class_path(
|
| 288 |
+
project: str,
|
| 289 |
+
location: str,
|
| 290 |
+
custom_class: str,
|
| 291 |
+
) -> str:
|
| 292 |
+
"""Returns a fully-qualified custom_class string."""
|
| 293 |
+
return "projects/{project}/locations/{location}/customClasses/{custom_class}".format(
|
| 294 |
+
project=project,
|
| 295 |
+
location=location,
|
| 296 |
+
custom_class=custom_class,
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
@staticmethod
|
| 300 |
+
def parse_custom_class_path(path: str) -> Dict[str, str]:
|
| 301 |
+
"""Parses a custom_class path into its component segments."""
|
| 302 |
+
m = re.match(
|
| 303 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/customClasses/(?P<custom_class>.+?)$",
|
| 304 |
+
path,
|
| 305 |
+
)
|
| 306 |
+
return m.groupdict() if m else {}
|
| 307 |
+
|
| 308 |
+
@staticmethod
|
| 309 |
+
def phrase_set_path(
|
| 310 |
+
project: str,
|
| 311 |
+
location: str,
|
| 312 |
+
phrase_set: str,
|
| 313 |
+
) -> str:
|
| 314 |
+
"""Returns a fully-qualified phrase_set string."""
|
| 315 |
+
return "projects/{project}/locations/{location}/phraseSets/{phrase_set}".format(
|
| 316 |
+
project=project,
|
| 317 |
+
location=location,
|
| 318 |
+
phrase_set=phrase_set,
|
| 319 |
+
)
|
| 320 |
+
|
| 321 |
+
@staticmethod
|
| 322 |
+
def parse_phrase_set_path(path: str) -> Dict[str, str]:
|
| 323 |
+
"""Parses a phrase_set path into its component segments."""
|
| 324 |
+
m = re.match(
|
| 325 |
+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/phraseSets/(?P<phrase_set>.+?)$",
|
| 326 |
+
path,
|
| 327 |
+
)
|
| 328 |
+
return m.groupdict() if m else {}
|
| 329 |
+
|
| 330 |
+
@staticmethod
|
| 331 |
+
def common_billing_account_path(
|
| 332 |
+
billing_account: str,
|
| 333 |
+
) -> str:
|
| 334 |
+
"""Returns a fully-qualified billing_account string."""
|
| 335 |
+
return "billingAccounts/{billing_account}".format(
|
| 336 |
+
billing_account=billing_account,
|
| 337 |
+
)
|
| 338 |
+
|
| 339 |
+
@staticmethod
|
| 340 |
+
def parse_common_billing_account_path(path: str) -> Dict[str, str]:
|
| 341 |
+
"""Parse a billing_account path into its component segments."""
|
| 342 |
+
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
|
| 343 |
+
return m.groupdict() if m else {}
|
| 344 |
+
|
| 345 |
+
@staticmethod
|
| 346 |
+
def common_folder_path(
|
| 347 |
+
folder: str,
|
| 348 |
+
) -> str:
|
| 349 |
+
"""Returns a fully-qualified folder string."""
|
| 350 |
+
return "folders/{folder}".format(
|
| 351 |
+
folder=folder,
|
| 352 |
+
)
|
| 353 |
+
|
| 354 |
+
@staticmethod
|
| 355 |
+
def parse_common_folder_path(path: str) -> Dict[str, str]:
|
| 356 |
+
"""Parse a folder path into its component segments."""
|
| 357 |
+
m = re.match(r"^folders/(?P<folder>.+?)$", path)
|
| 358 |
+
return m.groupdict() if m else {}
|
| 359 |
+
|
| 360 |
+
@staticmethod
|
| 361 |
+
def common_organization_path(
|
| 362 |
+
organization: str,
|
| 363 |
+
) -> str:
|
| 364 |
+
"""Returns a fully-qualified organization string."""
|
| 365 |
+
return "organizations/{organization}".format(
|
| 366 |
+
organization=organization,
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
@staticmethod
|
| 370 |
+
def parse_common_organization_path(path: str) -> Dict[str, str]:
|
| 371 |
+
"""Parse a organization path into its component segments."""
|
| 372 |
+
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
|
| 373 |
+
return m.groupdict() if m else {}
|
| 374 |
+
|
| 375 |
+
@staticmethod
|
| 376 |
+
def common_project_path(
|
| 377 |
+
project: str,
|
| 378 |
+
) -> str:
|
| 379 |
+
"""Returns a fully-qualified project string."""
|
| 380 |
+
return "projects/{project}".format(
|
| 381 |
+
project=project,
|
| 382 |
+
)
|
| 383 |
+
|
| 384 |
+
@staticmethod
|
| 385 |
+
def parse_common_project_path(path: str) -> Dict[str, str]:
|
| 386 |
+
"""Parse a project path into its component segments."""
|
| 387 |
+
m = re.match(r"^projects/(?P<project>.+?)$", path)
|
| 388 |
+
return m.groupdict() if m else {}
|
| 389 |
+
|
| 390 |
+
@staticmethod
|
| 391 |
+
def common_location_path(
|
| 392 |
+
project: str,
|
| 393 |
+
location: str,
|
| 394 |
+
) -> str:
|
| 395 |
+
"""Returns a fully-qualified location string."""
|
| 396 |
+
return "projects/{project}/locations/{location}".format(
|
| 397 |
+
project=project,
|
| 398 |
+
location=location,
|
| 399 |
+
)
|
| 400 |
+
|
| 401 |
+
@staticmethod
|
| 402 |
+
def parse_common_location_path(path: str) -> Dict[str, str]:
|
| 403 |
+
"""Parse a location path into its component segments."""
|
| 404 |
+
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
|
| 405 |
+
return m.groupdict() if m else {}
|
| 406 |
+
|
| 407 |
+
@classmethod
|
| 408 |
+
def get_mtls_endpoint_and_cert_source(
|
| 409 |
+
cls, client_options: Optional[client_options_lib.ClientOptions] = None
|
| 410 |
+
):
|
| 411 |
+
"""Deprecated. Return the API endpoint and client cert source for mutual TLS.
|
| 412 |
+
|
| 413 |
+
The client cert source is determined in the following order:
|
| 414 |
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
| 415 |
+
client cert source is None.
|
| 416 |
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
| 417 |
+
default client cert source exists, use the default one; otherwise the client cert
|
| 418 |
+
source is None.
|
| 419 |
+
|
| 420 |
+
The API endpoint is determined in the following order:
|
| 421 |
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
| 422 |
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
| 423 |
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
| 424 |
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
| 425 |
+
use the default API endpoint.
|
| 426 |
+
|
| 427 |
+
More details can be found at https://google.aip.dev/auth/4114.
|
| 428 |
+
|
| 429 |
+
Args:
|
| 430 |
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
| 431 |
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
| 432 |
+
in this method.
|
| 433 |
+
|
| 434 |
+
Returns:
|
| 435 |
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
| 436 |
+
client cert source to use.
|
| 437 |
+
|
| 438 |
+
Raises:
|
| 439 |
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
| 440 |
+
"""
|
| 441 |
+
|
| 442 |
+
warnings.warn(
|
| 443 |
+
"get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
|
| 444 |
+
DeprecationWarning,
|
| 445 |
+
)
|
| 446 |
+
if client_options is None:
|
| 447 |
+
client_options = client_options_lib.ClientOptions()
|
| 448 |
+
use_client_cert = SpeechClient._use_client_cert_effective()
|
| 449 |
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
|
| 450 |
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
| 451 |
+
raise MutualTLSChannelError(
|
| 452 |
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
| 453 |
+
)
|
| 454 |
+
|
| 455 |
+
# Figure out the client cert source to use.
|
| 456 |
+
client_cert_source = None
|
| 457 |
+
if use_client_cert:
|
| 458 |
+
if client_options.client_cert_source:
|
| 459 |
+
client_cert_source = client_options.client_cert_source
|
| 460 |
+
elif mtls.has_default_client_cert_source():
|
| 461 |
+
client_cert_source = mtls.default_client_cert_source()
|
| 462 |
+
|
| 463 |
+
# Figure out which api endpoint to use.
|
| 464 |
+
if client_options.api_endpoint is not None:
|
| 465 |
+
api_endpoint = client_options.api_endpoint
|
| 466 |
+
elif use_mtls_endpoint == "always" or (
|
| 467 |
+
use_mtls_endpoint == "auto" and client_cert_source
|
| 468 |
+
):
|
| 469 |
+
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
|
| 470 |
+
else:
|
| 471 |
+
api_endpoint = cls.DEFAULT_ENDPOINT
|
| 472 |
+
|
| 473 |
+
return api_endpoint, client_cert_source
|
| 474 |
+
|
| 475 |
+
@staticmethod
|
| 476 |
+
def _read_environment_variables():
|
| 477 |
+
"""Returns the environment variables used by the client.
|
| 478 |
+
|
| 479 |
+
Returns:
|
| 480 |
+
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
|
| 481 |
+
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
|
| 482 |
+
|
| 483 |
+
Raises:
|
| 484 |
+
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
|
| 485 |
+
any of ["true", "false"].
|
| 486 |
+
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
| 487 |
+
is not any of ["auto", "never", "always"].
|
| 488 |
+
"""
|
| 489 |
+
use_client_cert = SpeechClient._use_client_cert_effective()
|
| 490 |
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
| 491 |
+
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
| 492 |
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
| 493 |
+
raise MutualTLSChannelError(
|
| 494 |
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
| 495 |
+
)
|
| 496 |
+
return use_client_cert, use_mtls_endpoint, universe_domain_env
|
| 497 |
+
|
| 498 |
+
@staticmethod
|
| 499 |
+
def _get_client_cert_source(provided_cert_source, use_cert_flag):
|
| 500 |
+
"""Return the client cert source to be used by the client.
|
| 501 |
+
|
| 502 |
+
Args:
|
| 503 |
+
provided_cert_source (bytes): The client certificate source provided.
|
| 504 |
+
use_cert_flag (bool): A flag indicating whether to use the client certificate.
|
| 505 |
+
|
| 506 |
+
Returns:
|
| 507 |
+
bytes or None: The client cert source to be used by the client.
|
| 508 |
+
"""
|
| 509 |
+
client_cert_source = None
|
| 510 |
+
if use_cert_flag:
|
| 511 |
+
if provided_cert_source:
|
| 512 |
+
client_cert_source = provided_cert_source
|
| 513 |
+
elif mtls.has_default_client_cert_source():
|
| 514 |
+
client_cert_source = mtls.default_client_cert_source()
|
| 515 |
+
return client_cert_source
|
| 516 |
+
|
| 517 |
+
@staticmethod
|
| 518 |
+
def _get_api_endpoint(
|
| 519 |
+
api_override, client_cert_source, universe_domain, use_mtls_endpoint
|
| 520 |
+
) -> str:
|
| 521 |
+
"""Return the API endpoint used by the client.
|
| 522 |
+
|
| 523 |
+
Args:
|
| 524 |
+
api_override (str): The API endpoint override. If specified, this is always
|
| 525 |
+
the return value of this function and the other arguments are not used.
|
| 526 |
+
client_cert_source (bytes): The client certificate source used by the client.
|
| 527 |
+
universe_domain (str): The universe domain used by the client.
|
| 528 |
+
use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
|
| 529 |
+
Possible values are "always", "auto", or "never".
|
| 530 |
+
|
| 531 |
+
Returns:
|
| 532 |
+
str: The API endpoint to be used by the client.
|
| 533 |
+
"""
|
| 534 |
+
if api_override is not None:
|
| 535 |
+
api_endpoint = api_override
|
| 536 |
+
elif use_mtls_endpoint == "always" or (
|
| 537 |
+
use_mtls_endpoint == "auto" and client_cert_source
|
| 538 |
+
):
|
| 539 |
+
_default_universe = SpeechClient._DEFAULT_UNIVERSE
|
| 540 |
+
if universe_domain != _default_universe:
|
| 541 |
+
raise MutualTLSChannelError(
|
| 542 |
+
f"mTLS is not supported in any universe other than {_default_universe}."
|
| 543 |
+
)
|
| 544 |
+
api_endpoint = SpeechClient.DEFAULT_MTLS_ENDPOINT
|
| 545 |
+
else:
|
| 546 |
+
api_endpoint = SpeechClient._DEFAULT_ENDPOINT_TEMPLATE.format(
|
| 547 |
+
UNIVERSE_DOMAIN=universe_domain
|
| 548 |
+
)
|
| 549 |
+
return api_endpoint
|
| 550 |
+
|
| 551 |
+
@staticmethod
|
| 552 |
+
def _get_universe_domain(
|
| 553 |
+
client_universe_domain: Optional[str], universe_domain_env: Optional[str]
|
| 554 |
+
) -> str:
|
| 555 |
+
"""Return the universe domain used by the client.
|
| 556 |
+
|
| 557 |
+
Args:
|
| 558 |
+
client_universe_domain (Optional[str]): The universe domain configured via the client options.
|
| 559 |
+
universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
|
| 560 |
+
|
| 561 |
+
Returns:
|
| 562 |
+
str: The universe domain to be used by the client.
|
| 563 |
+
|
| 564 |
+
Raises:
|
| 565 |
+
ValueError: If the universe domain is an empty string.
|
| 566 |
+
"""
|
| 567 |
+
universe_domain = SpeechClient._DEFAULT_UNIVERSE
|
| 568 |
+
if client_universe_domain is not None:
|
| 569 |
+
universe_domain = client_universe_domain
|
| 570 |
+
elif universe_domain_env is not None:
|
| 571 |
+
universe_domain = universe_domain_env
|
| 572 |
+
if len(universe_domain.strip()) == 0:
|
| 573 |
+
raise ValueError("Universe Domain cannot be an empty string.")
|
| 574 |
+
return universe_domain
|
| 575 |
+
|
| 576 |
+
def _validate_universe_domain(self):
|
| 577 |
+
"""Validates client's and credentials' universe domains are consistent.
|
| 578 |
+
|
| 579 |
+
Returns:
|
| 580 |
+
bool: True iff the configured universe domain is valid.
|
| 581 |
+
|
| 582 |
+
Raises:
|
| 583 |
+
ValueError: If the configured universe domain is not valid.
|
| 584 |
+
"""
|
| 585 |
+
|
| 586 |
+
# NOTE (b/349488459): universe validation is disabled until further notice.
|
| 587 |
+
return True
|
| 588 |
+
|
| 589 |
+
def _add_cred_info_for_auth_errors(
|
| 590 |
+
self, error: core_exceptions.GoogleAPICallError
|
| 591 |
+
) -> None:
|
| 592 |
+
"""Adds credential info string to error details for 401/403/404 errors.
|
| 593 |
+
|
| 594 |
+
Args:
|
| 595 |
+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
|
| 596 |
+
"""
|
| 597 |
+
if error.code not in [
|
| 598 |
+
HTTPStatus.UNAUTHORIZED,
|
| 599 |
+
HTTPStatus.FORBIDDEN,
|
| 600 |
+
HTTPStatus.NOT_FOUND,
|
| 601 |
+
]:
|
| 602 |
+
return
|
| 603 |
+
|
| 604 |
+
cred = self._transport._credentials
|
| 605 |
+
|
| 606 |
+
# get_cred_info is only available in google-auth>=2.35.0
|
| 607 |
+
if not hasattr(cred, "get_cred_info"):
|
| 608 |
+
return
|
| 609 |
+
|
| 610 |
+
# ignore the type check since pypy test fails when get_cred_info
|
| 611 |
+
# is not available
|
| 612 |
+
cred_info = cred.get_cred_info() # type: ignore
|
| 613 |
+
if cred_info and hasattr(error._details, "append"):
|
| 614 |
+
error._details.append(json.dumps(cred_info))
|
| 615 |
+
|
| 616 |
+
@property
|
| 617 |
+
def api_endpoint(self) -> str:
|
| 618 |
+
"""Return the API endpoint used by the client instance.
|
| 619 |
+
|
| 620 |
+
Returns:
|
| 621 |
+
str: The API endpoint used by the client instance.
|
| 622 |
+
"""
|
| 623 |
+
return self._api_endpoint
|
| 624 |
+
|
| 625 |
+
@property
|
| 626 |
+
def universe_domain(self) -> str:
|
| 627 |
+
"""Return the universe domain used by the client instance.
|
| 628 |
+
|
| 629 |
+
Returns:
|
| 630 |
+
str: The universe domain used by the client instance.
|
| 631 |
+
"""
|
| 632 |
+
return self._universe_domain
|
| 633 |
+
|
| 634 |
+
def __init__(
|
| 635 |
+
self,
|
| 636 |
+
*,
|
| 637 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 638 |
+
transport: Optional[
|
| 639 |
+
Union[str, SpeechTransport, Callable[..., SpeechTransport]]
|
| 640 |
+
] = None,
|
| 641 |
+
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
|
| 642 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 643 |
+
) -> None:
|
| 644 |
+
"""Instantiates the speech client.
|
| 645 |
+
|
| 646 |
+
Args:
|
| 647 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 648 |
+
authorization credentials to attach to requests. These
|
| 649 |
+
credentials identify the application to the service; if none
|
| 650 |
+
are specified, the client will attempt to ascertain the
|
| 651 |
+
credentials from the environment.
|
| 652 |
+
transport (Optional[Union[str,SpeechTransport,Callable[..., SpeechTransport]]]):
|
| 653 |
+
The transport to use, or a Callable that constructs and returns a new transport.
|
| 654 |
+
If a Callable is given, it will be called with the same set of initialization
|
| 655 |
+
arguments as used in the SpeechTransport constructor.
|
| 656 |
+
If set to None, a transport is chosen automatically.
|
| 657 |
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
| 658 |
+
Custom options for the client.
|
| 659 |
+
|
| 660 |
+
1. The ``api_endpoint`` property can be used to override the
|
| 661 |
+
default endpoint provided by the client when ``transport`` is
|
| 662 |
+
not explicitly provided. Only if this property is not set and
|
| 663 |
+
``transport`` was not explicitly provided, the endpoint is
|
| 664 |
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
| 665 |
+
variable, which have one of the following values:
|
| 666 |
+
"always" (always use the default mTLS endpoint), "never" (always
|
| 667 |
+
use the default regular endpoint) and "auto" (auto-switch to the
|
| 668 |
+
default mTLS endpoint if client certificate is present; this is
|
| 669 |
+
the default value).
|
| 670 |
+
|
| 671 |
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
| 672 |
+
is "true", then the ``client_cert_source`` property can be used
|
| 673 |
+
to provide a client certificate for mTLS transport. If
|
| 674 |
+
not provided, the default SSL client certificate will be used if
|
| 675 |
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
| 676 |
+
set, no client certificate will be used.
|
| 677 |
+
|
| 678 |
+
3. The ``universe_domain`` property can be used to override the
|
| 679 |
+
default "googleapis.com" universe. Note that the ``api_endpoint``
|
| 680 |
+
property still takes precedence; and ``universe_domain`` is
|
| 681 |
+
currently not supported for mTLS.
|
| 682 |
+
|
| 683 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 684 |
+
The client info used to send a user-agent string along with
|
| 685 |
+
API requests. If ``None``, then default info will be used.
|
| 686 |
+
Generally, you only need to set this if you're developing
|
| 687 |
+
your own client library.
|
| 688 |
+
|
| 689 |
+
Raises:
|
| 690 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 691 |
+
creation failed for any reason.
|
| 692 |
+
"""
|
| 693 |
+
self._client_options = client_options
|
| 694 |
+
if isinstance(self._client_options, dict):
|
| 695 |
+
self._client_options = client_options_lib.from_dict(self._client_options)
|
| 696 |
+
if self._client_options is None:
|
| 697 |
+
self._client_options = client_options_lib.ClientOptions()
|
| 698 |
+
self._client_options = cast(
|
| 699 |
+
client_options_lib.ClientOptions, self._client_options
|
| 700 |
+
)
|
| 701 |
+
|
| 702 |
+
universe_domain_opt = getattr(self._client_options, "universe_domain", None)
|
| 703 |
+
|
| 704 |
+
self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
|
| 705 |
+
SpeechClient._read_environment_variables()
|
| 706 |
+
)
|
| 707 |
+
self._client_cert_source = SpeechClient._get_client_cert_source(
|
| 708 |
+
self._client_options.client_cert_source, self._use_client_cert
|
| 709 |
+
)
|
| 710 |
+
self._universe_domain = SpeechClient._get_universe_domain(
|
| 711 |
+
universe_domain_opt, self._universe_domain_env
|
| 712 |
+
)
|
| 713 |
+
self._api_endpoint: str = "" # updated below, depending on `transport`
|
| 714 |
+
|
| 715 |
+
# Initialize the universe domain validation.
|
| 716 |
+
self._is_universe_domain_valid = False
|
| 717 |
+
|
| 718 |
+
if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
|
| 719 |
+
# Setup logging.
|
| 720 |
+
client_logging.initialize_logging()
|
| 721 |
+
|
| 722 |
+
api_key_value = getattr(self._client_options, "api_key", None)
|
| 723 |
+
if api_key_value and credentials:
|
| 724 |
+
raise ValueError(
|
| 725 |
+
"client_options.api_key and credentials are mutually exclusive"
|
| 726 |
+
)
|
| 727 |
+
|
| 728 |
+
# Save or instantiate the transport.
|
| 729 |
+
# Ordinarily, we provide the transport, but allowing a custom transport
|
| 730 |
+
# instance provides an extensibility point for unusual situations.
|
| 731 |
+
transport_provided = isinstance(transport, SpeechTransport)
|
| 732 |
+
if transport_provided:
|
| 733 |
+
# transport is a SpeechTransport instance.
|
| 734 |
+
if credentials or self._client_options.credentials_file or api_key_value:
|
| 735 |
+
raise ValueError(
|
| 736 |
+
"When providing a transport instance, "
|
| 737 |
+
"provide its credentials directly."
|
| 738 |
+
)
|
| 739 |
+
if self._client_options.scopes:
|
| 740 |
+
raise ValueError(
|
| 741 |
+
"When providing a transport instance, provide its scopes directly."
|
| 742 |
+
)
|
| 743 |
+
self._transport = cast(SpeechTransport, transport)
|
| 744 |
+
self._api_endpoint = self._transport.host
|
| 745 |
+
|
| 746 |
+
self._api_endpoint = self._api_endpoint or SpeechClient._get_api_endpoint(
|
| 747 |
+
self._client_options.api_endpoint,
|
| 748 |
+
self._client_cert_source,
|
| 749 |
+
self._universe_domain,
|
| 750 |
+
self._use_mtls_endpoint,
|
| 751 |
+
)
|
| 752 |
+
|
| 753 |
+
if not transport_provided:
|
| 754 |
+
import google.auth._default # type: ignore
|
| 755 |
+
|
| 756 |
+
if api_key_value and hasattr(
|
| 757 |
+
google.auth._default, "get_api_key_credentials"
|
| 758 |
+
):
|
| 759 |
+
credentials = google.auth._default.get_api_key_credentials(
|
| 760 |
+
api_key_value
|
| 761 |
+
)
|
| 762 |
+
|
| 763 |
+
transport_init: Union[
|
| 764 |
+
Type[SpeechTransport], Callable[..., SpeechTransport]
|
| 765 |
+
] = (
|
| 766 |
+
SpeechClient.get_transport_class(transport)
|
| 767 |
+
if isinstance(transport, str) or transport is None
|
| 768 |
+
else cast(Callable[..., SpeechTransport], transport)
|
| 769 |
+
)
|
| 770 |
+
# initialize with the provided callable or the passed in class
|
| 771 |
+
self._transport = transport_init(
|
| 772 |
+
credentials=credentials,
|
| 773 |
+
credentials_file=self._client_options.credentials_file,
|
| 774 |
+
host=self._api_endpoint,
|
| 775 |
+
scopes=self._client_options.scopes,
|
| 776 |
+
client_cert_source_for_mtls=self._client_cert_source,
|
| 777 |
+
quota_project_id=self._client_options.quota_project_id,
|
| 778 |
+
client_info=client_info,
|
| 779 |
+
always_use_jwt_access=True,
|
| 780 |
+
api_audience=self._client_options.api_audience,
|
| 781 |
+
)
|
| 782 |
+
|
| 783 |
+
if "async" not in str(self._transport):
|
| 784 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 785 |
+
std_logging.DEBUG
|
| 786 |
+
): # pragma: NO COVER
|
| 787 |
+
_LOGGER.debug(
|
| 788 |
+
"Created client `google.cloud.speech_v1p1beta1.SpeechClient`.",
|
| 789 |
+
extra={
|
| 790 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 791 |
+
"universeDomain": getattr(
|
| 792 |
+
self._transport._credentials, "universe_domain", ""
|
| 793 |
+
),
|
| 794 |
+
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
|
| 795 |
+
"credentialsInfo": getattr(
|
| 796 |
+
self.transport._credentials, "get_cred_info", lambda: None
|
| 797 |
+
)(),
|
| 798 |
+
}
|
| 799 |
+
if hasattr(self._transport, "_credentials")
|
| 800 |
+
else {
|
| 801 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 802 |
+
"credentialsType": None,
|
| 803 |
+
},
|
| 804 |
+
)
|
| 805 |
+
|
| 806 |
+
def recognize(
|
| 807 |
+
self,
|
| 808 |
+
request: Optional[Union[cloud_speech.RecognizeRequest, dict]] = None,
|
| 809 |
+
*,
|
| 810 |
+
config: Optional[cloud_speech.RecognitionConfig] = None,
|
| 811 |
+
audio: Optional[cloud_speech.RecognitionAudio] = None,
|
| 812 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 813 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 814 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 815 |
+
) -> cloud_speech.RecognizeResponse:
|
| 816 |
+
r"""Performs synchronous speech recognition: receive
|
| 817 |
+
results after all audio has been sent and processed.
|
| 818 |
+
|
| 819 |
+
.. code-block:: python
|
| 820 |
+
|
| 821 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 822 |
+
# code template only.
|
| 823 |
+
# It will require modifications to work:
|
| 824 |
+
# - It may require correct/in-range values for request initialization.
|
| 825 |
+
# - It may require specifying regional endpoints when creating the service
|
| 826 |
+
# client as shown in:
|
| 827 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 828 |
+
from google.cloud import speech_v1p1beta1
|
| 829 |
+
|
| 830 |
+
def sample_recognize():
|
| 831 |
+
# Create a client
|
| 832 |
+
client = speech_v1p1beta1.SpeechClient()
|
| 833 |
+
|
| 834 |
+
# Initialize request argument(s)
|
| 835 |
+
config = speech_v1p1beta1.RecognitionConfig()
|
| 836 |
+
config.language_code = "language_code_value"
|
| 837 |
+
|
| 838 |
+
audio = speech_v1p1beta1.RecognitionAudio()
|
| 839 |
+
audio.content = b'content_blob'
|
| 840 |
+
|
| 841 |
+
request = speech_v1p1beta1.RecognizeRequest(
|
| 842 |
+
config=config,
|
| 843 |
+
audio=audio,
|
| 844 |
+
)
|
| 845 |
+
|
| 846 |
+
# Make the request
|
| 847 |
+
response = client.recognize(request=request)
|
| 848 |
+
|
| 849 |
+
# Handle the response
|
| 850 |
+
print(response)
|
| 851 |
+
|
| 852 |
+
Args:
|
| 853 |
+
request (Union[google.cloud.speech_v1p1beta1.types.RecognizeRequest, dict]):
|
| 854 |
+
The request object. The top-level message sent by the client for the
|
| 855 |
+
``Recognize`` method.
|
| 856 |
+
config (google.cloud.speech_v1p1beta1.types.RecognitionConfig):
|
| 857 |
+
Required. Provides information to the
|
| 858 |
+
recognizer that specifies how to process
|
| 859 |
+
the request.
|
| 860 |
+
|
| 861 |
+
This corresponds to the ``config`` field
|
| 862 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 863 |
+
should not be set.
|
| 864 |
+
audio (google.cloud.speech_v1p1beta1.types.RecognitionAudio):
|
| 865 |
+
Required. The audio data to be
|
| 866 |
+
recognized.
|
| 867 |
+
|
| 868 |
+
This corresponds to the ``audio`` field
|
| 869 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 870 |
+
should not be set.
|
| 871 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 872 |
+
should be retried.
|
| 873 |
+
timeout (float): The timeout for this request.
|
| 874 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 875 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 876 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 877 |
+
be of type `bytes`.
|
| 878 |
+
|
| 879 |
+
Returns:
|
| 880 |
+
google.cloud.speech_v1p1beta1.types.RecognizeResponse:
|
| 881 |
+
The only message returned to the client by the Recognize method. It
|
| 882 |
+
contains the result as zero or more sequential
|
| 883 |
+
SpeechRecognitionResult messages.
|
| 884 |
+
|
| 885 |
+
"""
|
| 886 |
+
# Create or coerce a protobuf request object.
|
| 887 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 888 |
+
# gotten any keyword arguments that map to the request.
|
| 889 |
+
flattened_params = [config, audio]
|
| 890 |
+
has_flattened_params = (
|
| 891 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 892 |
+
)
|
| 893 |
+
if request is not None and has_flattened_params:
|
| 894 |
+
raise ValueError(
|
| 895 |
+
"If the `request` argument is set, then none of "
|
| 896 |
+
"the individual field arguments should be set."
|
| 897 |
+
)
|
| 898 |
+
|
| 899 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 900 |
+
# there are no flattened fields), or create one.
|
| 901 |
+
if not isinstance(request, cloud_speech.RecognizeRequest):
|
| 902 |
+
request = cloud_speech.RecognizeRequest(request)
|
| 903 |
+
# If we have keyword arguments corresponding to fields on the
|
| 904 |
+
# request, apply these.
|
| 905 |
+
if config is not None:
|
| 906 |
+
request.config = config
|
| 907 |
+
if audio is not None:
|
| 908 |
+
request.audio = audio
|
| 909 |
+
|
| 910 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 911 |
+
# and friendly error handling.
|
| 912 |
+
rpc = self._transport._wrapped_methods[self._transport.recognize]
|
| 913 |
+
|
| 914 |
+
# Validate the universe domain.
|
| 915 |
+
self._validate_universe_domain()
|
| 916 |
+
|
| 917 |
+
# Send the request.
|
| 918 |
+
response = rpc(
|
| 919 |
+
request,
|
| 920 |
+
retry=retry,
|
| 921 |
+
timeout=timeout,
|
| 922 |
+
metadata=metadata,
|
| 923 |
+
)
|
| 924 |
+
|
| 925 |
+
# Done; return the response.
|
| 926 |
+
return response
|
| 927 |
+
|
| 928 |
+
def long_running_recognize(
|
| 929 |
+
self,
|
| 930 |
+
request: Optional[Union[cloud_speech.LongRunningRecognizeRequest, dict]] = None,
|
| 931 |
+
*,
|
| 932 |
+
config: Optional[cloud_speech.RecognitionConfig] = None,
|
| 933 |
+
audio: Optional[cloud_speech.RecognitionAudio] = None,
|
| 934 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 935 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 936 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 937 |
+
) -> operation.Operation:
|
| 938 |
+
r"""Performs asynchronous speech recognition: receive results via
|
| 939 |
+
the google.longrunning.Operations interface. Returns either an
|
| 940 |
+
``Operation.error`` or an ``Operation.response`` which contains
|
| 941 |
+
a ``LongRunningRecognizeResponse`` message. For more information
|
| 942 |
+
on asynchronous speech recognition, see the
|
| 943 |
+
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
|
| 944 |
+
|
| 945 |
+
.. code-block:: python
|
| 946 |
+
|
| 947 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 948 |
+
# code template only.
|
| 949 |
+
# It will require modifications to work:
|
| 950 |
+
# - It may require correct/in-range values for request initialization.
|
| 951 |
+
# - It may require specifying regional endpoints when creating the service
|
| 952 |
+
# client as shown in:
|
| 953 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 954 |
+
from google.cloud import speech_v1p1beta1
|
| 955 |
+
|
| 956 |
+
def sample_long_running_recognize():
|
| 957 |
+
# Create a client
|
| 958 |
+
client = speech_v1p1beta1.SpeechClient()
|
| 959 |
+
|
| 960 |
+
# Initialize request argument(s)
|
| 961 |
+
config = speech_v1p1beta1.RecognitionConfig()
|
| 962 |
+
config.language_code = "language_code_value"
|
| 963 |
+
|
| 964 |
+
audio = speech_v1p1beta1.RecognitionAudio()
|
| 965 |
+
audio.content = b'content_blob'
|
| 966 |
+
|
| 967 |
+
request = speech_v1p1beta1.LongRunningRecognizeRequest(
|
| 968 |
+
config=config,
|
| 969 |
+
audio=audio,
|
| 970 |
+
)
|
| 971 |
+
|
| 972 |
+
# Make the request
|
| 973 |
+
operation = client.long_running_recognize(request=request)
|
| 974 |
+
|
| 975 |
+
print("Waiting for operation to complete...")
|
| 976 |
+
|
| 977 |
+
response = operation.result()
|
| 978 |
+
|
| 979 |
+
# Handle the response
|
| 980 |
+
print(response)
|
| 981 |
+
|
| 982 |
+
Args:
|
| 983 |
+
request (Union[google.cloud.speech_v1p1beta1.types.LongRunningRecognizeRequest, dict]):
|
| 984 |
+
The request object. The top-level message sent by the client for the
|
| 985 |
+
``LongRunningRecognize`` method.
|
| 986 |
+
config (google.cloud.speech_v1p1beta1.types.RecognitionConfig):
|
| 987 |
+
Required. Provides information to the
|
| 988 |
+
recognizer that specifies how to process
|
| 989 |
+
the request.
|
| 990 |
+
|
| 991 |
+
This corresponds to the ``config`` field
|
| 992 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 993 |
+
should not be set.
|
| 994 |
+
audio (google.cloud.speech_v1p1beta1.types.RecognitionAudio):
|
| 995 |
+
Required. The audio data to be
|
| 996 |
+
recognized.
|
| 997 |
+
|
| 998 |
+
This corresponds to the ``audio`` field
|
| 999 |
+
on the ``request`` instance; if ``request`` is provided, this
|
| 1000 |
+
should not be set.
|
| 1001 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1002 |
+
should be retried.
|
| 1003 |
+
timeout (float): The timeout for this request.
|
| 1004 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1005 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1006 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1007 |
+
be of type `bytes`.
|
| 1008 |
+
|
| 1009 |
+
Returns:
|
| 1010 |
+
google.api_core.operation.Operation:
|
| 1011 |
+
An object representing a long-running operation.
|
| 1012 |
+
|
| 1013 |
+
The result type for the operation will be :class:`google.cloud.speech_v1p1beta1.types.LongRunningRecognizeResponse` The only message returned to the client by the LongRunningRecognize method.
|
| 1014 |
+
It contains the result as zero or more sequential
|
| 1015 |
+
SpeechRecognitionResult messages. It is included in
|
| 1016 |
+
the result.response field of the Operation returned
|
| 1017 |
+
by the GetOperation call of the
|
| 1018 |
+
google::longrunning::Operations service.
|
| 1019 |
+
|
| 1020 |
+
"""
|
| 1021 |
+
# Create or coerce a protobuf request object.
|
| 1022 |
+
# - Quick check: If we got a request object, we should *not* have
|
| 1023 |
+
# gotten any keyword arguments that map to the request.
|
| 1024 |
+
flattened_params = [config, audio]
|
| 1025 |
+
has_flattened_params = (
|
| 1026 |
+
len([param for param in flattened_params if param is not None]) > 0
|
| 1027 |
+
)
|
| 1028 |
+
if request is not None and has_flattened_params:
|
| 1029 |
+
raise ValueError(
|
| 1030 |
+
"If the `request` argument is set, then none of "
|
| 1031 |
+
"the individual field arguments should be set."
|
| 1032 |
+
)
|
| 1033 |
+
|
| 1034 |
+
# - Use the request object if provided (there's no risk of modifying the input as
|
| 1035 |
+
# there are no flattened fields), or create one.
|
| 1036 |
+
if not isinstance(request, cloud_speech.LongRunningRecognizeRequest):
|
| 1037 |
+
request = cloud_speech.LongRunningRecognizeRequest(request)
|
| 1038 |
+
# If we have keyword arguments corresponding to fields on the
|
| 1039 |
+
# request, apply these.
|
| 1040 |
+
if config is not None:
|
| 1041 |
+
request.config = config
|
| 1042 |
+
if audio is not None:
|
| 1043 |
+
request.audio = audio
|
| 1044 |
+
|
| 1045 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1046 |
+
# and friendly error handling.
|
| 1047 |
+
rpc = self._transport._wrapped_methods[self._transport.long_running_recognize]
|
| 1048 |
+
|
| 1049 |
+
# Validate the universe domain.
|
| 1050 |
+
self._validate_universe_domain()
|
| 1051 |
+
|
| 1052 |
+
# Send the request.
|
| 1053 |
+
response = rpc(
|
| 1054 |
+
request,
|
| 1055 |
+
retry=retry,
|
| 1056 |
+
timeout=timeout,
|
| 1057 |
+
metadata=metadata,
|
| 1058 |
+
)
|
| 1059 |
+
|
| 1060 |
+
# Wrap the response in an operation future.
|
| 1061 |
+
response = operation.from_gapic(
|
| 1062 |
+
response,
|
| 1063 |
+
self._transport.operations_client,
|
| 1064 |
+
cloud_speech.LongRunningRecognizeResponse,
|
| 1065 |
+
metadata_type=cloud_speech.LongRunningRecognizeMetadata,
|
| 1066 |
+
)
|
| 1067 |
+
|
| 1068 |
+
# Done; return the response.
|
| 1069 |
+
return response
|
| 1070 |
+
|
| 1071 |
+
def streaming_recognize(
|
| 1072 |
+
self,
|
| 1073 |
+
requests: Optional[Iterator[cloud_speech.StreamingRecognizeRequest]] = None,
|
| 1074 |
+
*,
|
| 1075 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1076 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1077 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1078 |
+
) -> Iterable[cloud_speech.StreamingRecognizeResponse]:
|
| 1079 |
+
r"""Performs bidirectional streaming speech recognition:
|
| 1080 |
+
receive results while sending audio. This method is only
|
| 1081 |
+
available via the gRPC API (not REST).
|
| 1082 |
+
|
| 1083 |
+
.. code-block:: python
|
| 1084 |
+
|
| 1085 |
+
# This snippet has been automatically generated and should be regarded as a
|
| 1086 |
+
# code template only.
|
| 1087 |
+
# It will require modifications to work:
|
| 1088 |
+
# - It may require correct/in-range values for request initialization.
|
| 1089 |
+
# - It may require specifying regional endpoints when creating the service
|
| 1090 |
+
# client as shown in:
|
| 1091 |
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
| 1092 |
+
from google.cloud import speech_v1p1beta1
|
| 1093 |
+
|
| 1094 |
+
def sample_streaming_recognize():
|
| 1095 |
+
# Create a client
|
| 1096 |
+
client = speech_v1p1beta1.SpeechClient()
|
| 1097 |
+
|
| 1098 |
+
# Initialize request argument(s)
|
| 1099 |
+
streaming_config = speech_v1p1beta1.StreamingRecognitionConfig()
|
| 1100 |
+
streaming_config.config.language_code = "language_code_value"
|
| 1101 |
+
|
| 1102 |
+
request = speech_v1p1beta1.StreamingRecognizeRequest(
|
| 1103 |
+
streaming_config=streaming_config,
|
| 1104 |
+
)
|
| 1105 |
+
|
| 1106 |
+
# This method expects an iterator which contains
|
| 1107 |
+
# 'speech_v1p1beta1.StreamingRecognizeRequest' objects
|
| 1108 |
+
# Here we create a generator that yields a single `request` for
|
| 1109 |
+
# demonstrative purposes.
|
| 1110 |
+
requests = [request]
|
| 1111 |
+
|
| 1112 |
+
def request_generator():
|
| 1113 |
+
for request in requests:
|
| 1114 |
+
yield request
|
| 1115 |
+
|
| 1116 |
+
# Make the request
|
| 1117 |
+
stream = client.streaming_recognize(requests=request_generator())
|
| 1118 |
+
|
| 1119 |
+
# Handle the response
|
| 1120 |
+
for response in stream:
|
| 1121 |
+
print(response)
|
| 1122 |
+
|
| 1123 |
+
Args:
|
| 1124 |
+
requests (Iterator[google.cloud.speech_v1p1beta1.types.StreamingRecognizeRequest]):
|
| 1125 |
+
The request object iterator. The top-level message sent by the client for the
|
| 1126 |
+
``StreamingRecognize`` method. Multiple
|
| 1127 |
+
``StreamingRecognizeRequest`` messages are sent. The
|
| 1128 |
+
first message must contain a ``streaming_config``
|
| 1129 |
+
message and must not contain ``audio_content``. All
|
| 1130 |
+
subsequent messages must contain ``audio_content`` and
|
| 1131 |
+
must not contain a ``streaming_config`` message.
|
| 1132 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 1133 |
+
should be retried.
|
| 1134 |
+
timeout (float): The timeout for this request.
|
| 1135 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1136 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1137 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1138 |
+
be of type `bytes`.
|
| 1139 |
+
|
| 1140 |
+
Returns:
|
| 1141 |
+
Iterable[google.cloud.speech_v1p1beta1.types.StreamingRecognizeResponse]:
|
| 1142 |
+
StreamingRecognizeResponse is the only message returned to the client by
|
| 1143 |
+
StreamingRecognize. A series of zero or more
|
| 1144 |
+
StreamingRecognizeResponse messages are streamed back
|
| 1145 |
+
to the client. If there is no recognizable audio, and
|
| 1146 |
+
single_utterance is set to false, then no messages
|
| 1147 |
+
are streamed back to the client.
|
| 1148 |
+
|
| 1149 |
+
Here's an example of a series of
|
| 1150 |
+
\`StreamingRecognizeResponse`s that might be returned
|
| 1151 |
+
while processing audio:
|
| 1152 |
+
|
| 1153 |
+
1. results { alternatives { transcript: "tube" }
|
| 1154 |
+
stability: 0.01 }
|
| 1155 |
+
|
| 1156 |
+
2. results { alternatives { transcript: "to be a" }
|
| 1157 |
+
stability: 0.01 }
|
| 1158 |
+
|
| 1159 |
+
3. results { alternatives { transcript: "to be" }
|
| 1160 |
+
stability: 0.9 } results { alternatives {
|
| 1161 |
+
transcript: " or not to be" } stability: 0.01 }
|
| 1162 |
+
|
| 1163 |
+
4.
|
| 1164 |
+
|
| 1165 |
+
results { alternatives { transcript: "to be or not to be"
|
| 1166 |
+
confidence: 0.92 } alternatives { transcript:
|
| 1167 |
+
"to bee or not to bee" } is_final: true }
|
| 1168 |
+
|
| 1169 |
+
5. results { alternatives { transcript: " that's" }
|
| 1170 |
+
stability: 0.01 }
|
| 1171 |
+
|
| 1172 |
+
6. results { alternatives { transcript: " that is" }
|
| 1173 |
+
stability: 0.9 } results { alternatives {
|
| 1174 |
+
transcript: " the question" } stability: 0.01 }
|
| 1175 |
+
|
| 1176 |
+
7.
|
| 1177 |
+
|
| 1178 |
+
results { alternatives { transcript: " that is the question"
|
| 1179 |
+
confidence: 0.98 } alternatives { transcript: "
|
| 1180 |
+
that was the question" } is_final: true }
|
| 1181 |
+
|
| 1182 |
+
Notes:
|
| 1183 |
+
|
| 1184 |
+
- Only two of the above responses #4 and #7 contain
|
| 1185 |
+
final results; they are indicated by is_final:
|
| 1186 |
+
true. Concatenating these together generates the
|
| 1187 |
+
full transcript: "to be or not to be that is the
|
| 1188 |
+
question".
|
| 1189 |
+
|
| 1190 |
+
- The others contain interim results. #3 and #6
|
| 1191 |
+
contain two interim \`results\`: the first portion
|
| 1192 |
+
has a high stability and is less likely to change;
|
| 1193 |
+
the second portion has a low stability and is very
|
| 1194 |
+
likely to change. A UI designer might choose to
|
| 1195 |
+
show only high stability results.
|
| 1196 |
+
|
| 1197 |
+
- The specific stability and confidence values shown
|
| 1198 |
+
above are only for illustrative purposes. Actual
|
| 1199 |
+
values may vary.
|
| 1200 |
+
|
| 1201 |
+
-
|
| 1202 |
+
|
| 1203 |
+
In each response, only one of these fields will be set:
|
| 1204 |
+
error, speech_event_type, or one or more
|
| 1205 |
+
(repeated) results.
|
| 1206 |
+
|
| 1207 |
+
"""
|
| 1208 |
+
|
| 1209 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1210 |
+
# and friendly error handling.
|
| 1211 |
+
rpc = self._transport._wrapped_methods[self._transport.streaming_recognize]
|
| 1212 |
+
|
| 1213 |
+
# Validate the universe domain.
|
| 1214 |
+
self._validate_universe_domain()
|
| 1215 |
+
|
| 1216 |
+
# Send the request.
|
| 1217 |
+
response = rpc(
|
| 1218 |
+
requests,
|
| 1219 |
+
retry=retry,
|
| 1220 |
+
timeout=timeout,
|
| 1221 |
+
metadata=metadata,
|
| 1222 |
+
)
|
| 1223 |
+
|
| 1224 |
+
# Done; return the response.
|
| 1225 |
+
return response
|
| 1226 |
+
|
| 1227 |
+
def __enter__(self) -> "SpeechClient":
|
| 1228 |
+
return self
|
| 1229 |
+
|
| 1230 |
+
def __exit__(self, type, value, traceback):
|
| 1231 |
+
"""Releases underlying transport's resources.
|
| 1232 |
+
|
| 1233 |
+
.. warning::
|
| 1234 |
+
ONLY use as a context manager if the transport is NOT shared
|
| 1235 |
+
with other clients! Exiting the with block will CLOSE the transport
|
| 1236 |
+
and may cause errors in other clients!
|
| 1237 |
+
"""
|
| 1238 |
+
self.transport.close()
|
| 1239 |
+
|
| 1240 |
+
def list_operations(
|
| 1241 |
+
self,
|
| 1242 |
+
request: Optional[Union[operations_pb2.ListOperationsRequest, dict]] = None,
|
| 1243 |
+
*,
|
| 1244 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1245 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1246 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1247 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 1248 |
+
r"""Lists operations that match the specified filter in the request.
|
| 1249 |
+
|
| 1250 |
+
Args:
|
| 1251 |
+
request (:class:`~.operations_pb2.ListOperationsRequest`):
|
| 1252 |
+
The request object. Request message for
|
| 1253 |
+
`ListOperations` method.
|
| 1254 |
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
| 1255 |
+
if any, should be retried.
|
| 1256 |
+
timeout (float): The timeout for this request.
|
| 1257 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1258 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1259 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1260 |
+
be of type `bytes`.
|
| 1261 |
+
Returns:
|
| 1262 |
+
~.operations_pb2.ListOperationsResponse:
|
| 1263 |
+
Response message for ``ListOperations`` method.
|
| 1264 |
+
"""
|
| 1265 |
+
# Create or coerce a protobuf request object.
|
| 1266 |
+
# The request isn't a proto-plus wrapped type,
|
| 1267 |
+
# so it must be constructed via keyword expansion.
|
| 1268 |
+
if request is None:
|
| 1269 |
+
request_pb = operations_pb2.ListOperationsRequest()
|
| 1270 |
+
elif isinstance(request, dict):
|
| 1271 |
+
request_pb = operations_pb2.ListOperationsRequest(**request)
|
| 1272 |
+
else:
|
| 1273 |
+
request_pb = request
|
| 1274 |
+
|
| 1275 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1276 |
+
# and friendly error handling.
|
| 1277 |
+
rpc = self._transport._wrapped_methods[self._transport.list_operations]
|
| 1278 |
+
|
| 1279 |
+
# Certain fields should be provided within the metadata header;
|
| 1280 |
+
# add these here.
|
| 1281 |
+
metadata = tuple(metadata) + (
|
| 1282 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 1283 |
+
)
|
| 1284 |
+
|
| 1285 |
+
# Validate the universe domain.
|
| 1286 |
+
self._validate_universe_domain()
|
| 1287 |
+
|
| 1288 |
+
try:
|
| 1289 |
+
# Send the request.
|
| 1290 |
+
response = rpc(
|
| 1291 |
+
request_pb,
|
| 1292 |
+
retry=retry,
|
| 1293 |
+
timeout=timeout,
|
| 1294 |
+
metadata=metadata,
|
| 1295 |
+
)
|
| 1296 |
+
|
| 1297 |
+
# Done; return the response.
|
| 1298 |
+
return response
|
| 1299 |
+
except core_exceptions.GoogleAPICallError as e:
|
| 1300 |
+
self._add_cred_info_for_auth_errors(e)
|
| 1301 |
+
raise e
|
| 1302 |
+
|
| 1303 |
+
def get_operation(
|
| 1304 |
+
self,
|
| 1305 |
+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
|
| 1306 |
+
*,
|
| 1307 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 1308 |
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
| 1309 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 1310 |
+
) -> operations_pb2.Operation:
|
| 1311 |
+
r"""Gets the latest state of a long-running operation.
|
| 1312 |
+
|
| 1313 |
+
Args:
|
| 1314 |
+
request (:class:`~.operations_pb2.GetOperationRequest`):
|
| 1315 |
+
The request object. Request message for
|
| 1316 |
+
`GetOperation` method.
|
| 1317 |
+
retry (google.api_core.retry.Retry): Designation of what errors,
|
| 1318 |
+
if any, should be retried.
|
| 1319 |
+
timeout (float): The timeout for this request.
|
| 1320 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 1321 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 1322 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 1323 |
+
be of type `bytes`.
|
| 1324 |
+
Returns:
|
| 1325 |
+
~.operations_pb2.Operation:
|
| 1326 |
+
An ``Operation`` object.
|
| 1327 |
+
"""
|
| 1328 |
+
# Create or coerce a protobuf request object.
|
| 1329 |
+
# The request isn't a proto-plus wrapped type,
|
| 1330 |
+
# so it must be constructed via keyword expansion.
|
| 1331 |
+
if request is None:
|
| 1332 |
+
request_pb = operations_pb2.GetOperationRequest()
|
| 1333 |
+
elif isinstance(request, dict):
|
| 1334 |
+
request_pb = operations_pb2.GetOperationRequest(**request)
|
| 1335 |
+
else:
|
| 1336 |
+
request_pb = request
|
| 1337 |
+
|
| 1338 |
+
# Wrap the RPC method; this adds retry and timeout information,
|
| 1339 |
+
# and friendly error handling.
|
| 1340 |
+
rpc = self._transport._wrapped_methods[self._transport.get_operation]
|
| 1341 |
+
|
| 1342 |
+
# Certain fields should be provided within the metadata header;
|
| 1343 |
+
# add these here.
|
| 1344 |
+
metadata = tuple(metadata) + (
|
| 1345 |
+
gapic_v1.routing_header.to_grpc_metadata((("name", request_pb.name),)),
|
| 1346 |
+
)
|
| 1347 |
+
|
| 1348 |
+
# Validate the universe domain.
|
| 1349 |
+
self._validate_universe_domain()
|
| 1350 |
+
|
| 1351 |
+
try:
|
| 1352 |
+
# Send the request.
|
| 1353 |
+
response = rpc(
|
| 1354 |
+
request_pb,
|
| 1355 |
+
retry=retry,
|
| 1356 |
+
timeout=timeout,
|
| 1357 |
+
metadata=metadata,
|
| 1358 |
+
)
|
| 1359 |
+
|
| 1360 |
+
# Done; return the response.
|
| 1361 |
+
return response
|
| 1362 |
+
except core_exceptions.GoogleAPICallError as e:
|
| 1363 |
+
self._add_cred_info_for_auth_errors(e)
|
| 1364 |
+
raise e
|
| 1365 |
+
|
| 1366 |
+
|
| 1367 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 1368 |
+
gapic_version=package_version.__version__
|
| 1369 |
+
)
|
| 1370 |
+
|
| 1371 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 1372 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 1373 |
+
|
| 1374 |
+
__all__ = ("SpeechClient",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from collections import OrderedDict
|
| 17 |
+
from typing import Dict, Type
|
| 18 |
+
|
| 19 |
+
from .base import SpeechTransport
|
| 20 |
+
from .grpc import SpeechGrpcTransport
|
| 21 |
+
from .grpc_asyncio import SpeechGrpcAsyncIOTransport
|
| 22 |
+
from .rest import SpeechRestInterceptor, SpeechRestTransport
|
| 23 |
+
|
| 24 |
+
# Compile a registry of transports.
|
| 25 |
+
_transport_registry = OrderedDict() # type: Dict[str, Type[SpeechTransport]]
|
| 26 |
+
_transport_registry["grpc"] = SpeechGrpcTransport
|
| 27 |
+
_transport_registry["grpc_asyncio"] = SpeechGrpcAsyncIOTransport
|
| 28 |
+
_transport_registry["rest"] = SpeechRestTransport
|
| 29 |
+
|
| 30 |
+
__all__ = (
|
| 31 |
+
"SpeechTransport",
|
| 32 |
+
"SpeechGrpcTransport",
|
| 33 |
+
"SpeechGrpcAsyncIOTransport",
|
| 34 |
+
"SpeechRestTransport",
|
| 35 |
+
"SpeechRestInterceptor",
|
| 36 |
+
)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/base.py
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import abc
|
| 17 |
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
|
| 18 |
+
|
| 19 |
+
import google.api_core
|
| 20 |
+
import google.auth # type: ignore
|
| 21 |
+
import google.protobuf
|
| 22 |
+
from google.api_core import exceptions as core_exceptions
|
| 23 |
+
from google.api_core import gapic_v1, operations_v1
|
| 24 |
+
from google.api_core import retry as retries
|
| 25 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 26 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 27 |
+
from google.oauth2 import service_account # type: ignore
|
| 28 |
+
|
| 29 |
+
from google.cloud.speech_v1p1beta1 import gapic_version as package_version
|
| 30 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech
|
| 31 |
+
|
| 32 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 33 |
+
gapic_version=package_version.__version__
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 37 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class SpeechTransport(abc.ABC):
|
| 41 |
+
"""Abstract transport class for Speech."""
|
| 42 |
+
|
| 43 |
+
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
|
| 44 |
+
|
| 45 |
+
DEFAULT_HOST: str = "speech.googleapis.com"
|
| 46 |
+
|
| 47 |
+
def __init__(
|
| 48 |
+
self,
|
| 49 |
+
*,
|
| 50 |
+
host: str = DEFAULT_HOST,
|
| 51 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 52 |
+
credentials_file: Optional[str] = None,
|
| 53 |
+
scopes: Optional[Sequence[str]] = None,
|
| 54 |
+
quota_project_id: Optional[str] = None,
|
| 55 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 56 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 57 |
+
api_audience: Optional[str] = None,
|
| 58 |
+
**kwargs,
|
| 59 |
+
) -> None:
|
| 60 |
+
"""Instantiate the transport.
|
| 61 |
+
|
| 62 |
+
Args:
|
| 63 |
+
host (Optional[str]):
|
| 64 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 65 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 66 |
+
authorization credentials to attach to requests. These
|
| 67 |
+
credentials identify the application to the service; if none
|
| 68 |
+
are specified, the client will attempt to ascertain the
|
| 69 |
+
credentials from the environment.
|
| 70 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 71 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 72 |
+
This argument is mutually exclusive with credentials. This argument will be
|
| 73 |
+
removed in the next major version of this library.
|
| 74 |
+
scopes (Optional[Sequence[str]]): A list of scopes.
|
| 75 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 76 |
+
and quota.
|
| 77 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 78 |
+
The client info used to send a user-agent string along with
|
| 79 |
+
API requests. If ``None``, then default info will be used.
|
| 80 |
+
Generally, you only need to set this if you're developing
|
| 81 |
+
your own client library.
|
| 82 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 83 |
+
be used for service account credentials.
|
| 84 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 85 |
+
to the service that will be set when using certain 3rd party
|
| 86 |
+
authentication flows. Audience is typically a resource identifier.
|
| 87 |
+
If not set, the host value will be used as a default.
|
| 88 |
+
"""
|
| 89 |
+
|
| 90 |
+
# Save the scopes.
|
| 91 |
+
self._scopes = scopes
|
| 92 |
+
if not hasattr(self, "_ignore_credentials"):
|
| 93 |
+
self._ignore_credentials: bool = False
|
| 94 |
+
|
| 95 |
+
# If no credentials are provided, then determine the appropriate
|
| 96 |
+
# defaults.
|
| 97 |
+
if credentials and credentials_file:
|
| 98 |
+
raise core_exceptions.DuplicateCredentialArgs(
|
| 99 |
+
"'credentials_file' and 'credentials' are mutually exclusive"
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
if credentials_file is not None:
|
| 103 |
+
credentials, _ = google.auth.load_credentials_from_file(
|
| 104 |
+
credentials_file,
|
| 105 |
+
scopes=scopes,
|
| 106 |
+
quota_project_id=quota_project_id,
|
| 107 |
+
default_scopes=self.AUTH_SCOPES,
|
| 108 |
+
)
|
| 109 |
+
elif credentials is None and not self._ignore_credentials:
|
| 110 |
+
credentials, _ = google.auth.default(
|
| 111 |
+
scopes=scopes,
|
| 112 |
+
quota_project_id=quota_project_id,
|
| 113 |
+
default_scopes=self.AUTH_SCOPES,
|
| 114 |
+
)
|
| 115 |
+
# Don't apply audience if the credentials file passed from user.
|
| 116 |
+
if hasattr(credentials, "with_gdch_audience"):
|
| 117 |
+
credentials = credentials.with_gdch_audience(
|
| 118 |
+
api_audience if api_audience else host
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
# If the credentials are service account credentials, then always try to use self signed JWT.
|
| 122 |
+
if (
|
| 123 |
+
always_use_jwt_access
|
| 124 |
+
and isinstance(credentials, service_account.Credentials)
|
| 125 |
+
and hasattr(service_account.Credentials, "with_always_use_jwt_access")
|
| 126 |
+
):
|
| 127 |
+
credentials = credentials.with_always_use_jwt_access(True)
|
| 128 |
+
|
| 129 |
+
# Save the credentials.
|
| 130 |
+
self._credentials = credentials
|
| 131 |
+
|
| 132 |
+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
|
| 133 |
+
if ":" not in host:
|
| 134 |
+
host += ":443"
|
| 135 |
+
self._host = host
|
| 136 |
+
|
| 137 |
+
self._wrapped_methods: Dict[Callable, Callable] = {}
|
| 138 |
+
|
| 139 |
+
@property
|
| 140 |
+
def host(self):
|
| 141 |
+
return self._host
|
| 142 |
+
|
| 143 |
+
def _prep_wrapped_messages(self, client_info):
|
| 144 |
+
# Precompute the wrapped methods.
|
| 145 |
+
self._wrapped_methods = {
|
| 146 |
+
self.recognize: gapic_v1.method.wrap_method(
|
| 147 |
+
self.recognize,
|
| 148 |
+
default_retry=retries.Retry(
|
| 149 |
+
initial=0.1,
|
| 150 |
+
maximum=60.0,
|
| 151 |
+
multiplier=1.3,
|
| 152 |
+
predicate=retries.if_exception_type(
|
| 153 |
+
core_exceptions.DeadlineExceeded,
|
| 154 |
+
core_exceptions.ServiceUnavailable,
|
| 155 |
+
),
|
| 156 |
+
deadline=5000.0,
|
| 157 |
+
),
|
| 158 |
+
default_timeout=5000.0,
|
| 159 |
+
client_info=client_info,
|
| 160 |
+
),
|
| 161 |
+
self.long_running_recognize: gapic_v1.method.wrap_method(
|
| 162 |
+
self.long_running_recognize,
|
| 163 |
+
default_timeout=5000.0,
|
| 164 |
+
client_info=client_info,
|
| 165 |
+
),
|
| 166 |
+
self.streaming_recognize: gapic_v1.method.wrap_method(
|
| 167 |
+
self.streaming_recognize,
|
| 168 |
+
default_retry=retries.Retry(
|
| 169 |
+
initial=0.1,
|
| 170 |
+
maximum=60.0,
|
| 171 |
+
multiplier=1.3,
|
| 172 |
+
predicate=retries.if_exception_type(
|
| 173 |
+
core_exceptions.DeadlineExceeded,
|
| 174 |
+
core_exceptions.ServiceUnavailable,
|
| 175 |
+
),
|
| 176 |
+
deadline=5000.0,
|
| 177 |
+
),
|
| 178 |
+
default_timeout=5000.0,
|
| 179 |
+
client_info=client_info,
|
| 180 |
+
),
|
| 181 |
+
self.get_operation: gapic_v1.method.wrap_method(
|
| 182 |
+
self.get_operation,
|
| 183 |
+
default_timeout=None,
|
| 184 |
+
client_info=client_info,
|
| 185 |
+
),
|
| 186 |
+
self.list_operations: gapic_v1.method.wrap_method(
|
| 187 |
+
self.list_operations,
|
| 188 |
+
default_timeout=None,
|
| 189 |
+
client_info=client_info,
|
| 190 |
+
),
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
def close(self):
|
| 194 |
+
"""Closes resources associated with the transport.
|
| 195 |
+
|
| 196 |
+
.. warning::
|
| 197 |
+
Only call this method if the transport is NOT shared
|
| 198 |
+
with other clients - this may cause errors in other clients!
|
| 199 |
+
"""
|
| 200 |
+
raise NotImplementedError()
|
| 201 |
+
|
| 202 |
+
@property
|
| 203 |
+
def operations_client(self):
|
| 204 |
+
"""Return the client designed to process long-running operations."""
|
| 205 |
+
raise NotImplementedError()
|
| 206 |
+
|
| 207 |
+
@property
|
| 208 |
+
def recognize(
|
| 209 |
+
self,
|
| 210 |
+
) -> Callable[
|
| 211 |
+
[cloud_speech.RecognizeRequest],
|
| 212 |
+
Union[
|
| 213 |
+
cloud_speech.RecognizeResponse, Awaitable[cloud_speech.RecognizeResponse]
|
| 214 |
+
],
|
| 215 |
+
]:
|
| 216 |
+
raise NotImplementedError()
|
| 217 |
+
|
| 218 |
+
@property
|
| 219 |
+
def long_running_recognize(
|
| 220 |
+
self,
|
| 221 |
+
) -> Callable[
|
| 222 |
+
[cloud_speech.LongRunningRecognizeRequest],
|
| 223 |
+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
|
| 224 |
+
]:
|
| 225 |
+
raise NotImplementedError()
|
| 226 |
+
|
| 227 |
+
@property
|
| 228 |
+
def streaming_recognize(
|
| 229 |
+
self,
|
| 230 |
+
) -> Callable[
|
| 231 |
+
[cloud_speech.StreamingRecognizeRequest],
|
| 232 |
+
Union[
|
| 233 |
+
cloud_speech.StreamingRecognizeResponse,
|
| 234 |
+
Awaitable[cloud_speech.StreamingRecognizeResponse],
|
| 235 |
+
],
|
| 236 |
+
]:
|
| 237 |
+
raise NotImplementedError()
|
| 238 |
+
|
| 239 |
+
@property
|
| 240 |
+
def list_operations(
|
| 241 |
+
self,
|
| 242 |
+
) -> Callable[
|
| 243 |
+
[operations_pb2.ListOperationsRequest],
|
| 244 |
+
Union[
|
| 245 |
+
operations_pb2.ListOperationsResponse,
|
| 246 |
+
Awaitable[operations_pb2.ListOperationsResponse],
|
| 247 |
+
],
|
| 248 |
+
]:
|
| 249 |
+
raise NotImplementedError()
|
| 250 |
+
|
| 251 |
+
@property
|
| 252 |
+
def get_operation(
|
| 253 |
+
self,
|
| 254 |
+
) -> Callable[
|
| 255 |
+
[operations_pb2.GetOperationRequest],
|
| 256 |
+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
|
| 257 |
+
]:
|
| 258 |
+
raise NotImplementedError()
|
| 259 |
+
|
| 260 |
+
@property
|
| 261 |
+
def kind(self) -> str:
|
| 262 |
+
raise NotImplementedError()
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
__all__ = ("SpeechTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/grpc.py
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json
|
| 17 |
+
import logging as std_logging
|
| 18 |
+
import pickle
|
| 19 |
+
import warnings
|
| 20 |
+
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
|
| 21 |
+
|
| 22 |
+
import google.auth # type: ignore
|
| 23 |
+
import google.protobuf.message
|
| 24 |
+
import grpc # type: ignore
|
| 25 |
+
import proto # type: ignore
|
| 26 |
+
from google.api_core import gapic_v1, grpc_helpers, operations_v1
|
| 27 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 28 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 29 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 30 |
+
from google.protobuf.json_format import MessageToJson
|
| 31 |
+
|
| 32 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech
|
| 33 |
+
|
| 34 |
+
from .base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 35 |
+
|
| 36 |
+
try:
|
| 37 |
+
from google.api_core import client_logging # type: ignore
|
| 38 |
+
|
| 39 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 40 |
+
except ImportError: # pragma: NO COVER
|
| 41 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 42 |
+
|
| 43 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
|
| 47 |
+
def intercept_unary_unary(self, continuation, client_call_details, request):
|
| 48 |
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 49 |
+
std_logging.DEBUG
|
| 50 |
+
)
|
| 51 |
+
if logging_enabled: # pragma: NO COVER
|
| 52 |
+
request_metadata = client_call_details.metadata
|
| 53 |
+
if isinstance(request, proto.Message):
|
| 54 |
+
request_payload = type(request).to_json(request)
|
| 55 |
+
elif isinstance(request, google.protobuf.message.Message):
|
| 56 |
+
request_payload = MessageToJson(request)
|
| 57 |
+
else:
|
| 58 |
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
|
| 59 |
+
|
| 60 |
+
request_metadata = {
|
| 61 |
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
| 62 |
+
for key, value in request_metadata
|
| 63 |
+
}
|
| 64 |
+
grpc_request = {
|
| 65 |
+
"payload": request_payload,
|
| 66 |
+
"requestMethod": "grpc",
|
| 67 |
+
"metadata": dict(request_metadata),
|
| 68 |
+
}
|
| 69 |
+
_LOGGER.debug(
|
| 70 |
+
f"Sending request for {client_call_details.method}",
|
| 71 |
+
extra={
|
| 72 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 73 |
+
"rpcName": str(client_call_details.method),
|
| 74 |
+
"request": grpc_request,
|
| 75 |
+
"metadata": grpc_request["metadata"],
|
| 76 |
+
},
|
| 77 |
+
)
|
| 78 |
+
response = continuation(client_call_details, request)
|
| 79 |
+
if logging_enabled: # pragma: NO COVER
|
| 80 |
+
response_metadata = response.trailing_metadata()
|
| 81 |
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
| 82 |
+
metadata = (
|
| 83 |
+
dict([(k, str(v)) for k, v in response_metadata])
|
| 84 |
+
if response_metadata
|
| 85 |
+
else None
|
| 86 |
+
)
|
| 87 |
+
result = response.result()
|
| 88 |
+
if isinstance(result, proto.Message):
|
| 89 |
+
response_payload = type(result).to_json(result)
|
| 90 |
+
elif isinstance(result, google.protobuf.message.Message):
|
| 91 |
+
response_payload = MessageToJson(result)
|
| 92 |
+
else:
|
| 93 |
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
|
| 94 |
+
grpc_response = {
|
| 95 |
+
"payload": response_payload,
|
| 96 |
+
"metadata": metadata,
|
| 97 |
+
"status": "OK",
|
| 98 |
+
}
|
| 99 |
+
_LOGGER.debug(
|
| 100 |
+
f"Received response for {client_call_details.method}.",
|
| 101 |
+
extra={
|
| 102 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 103 |
+
"rpcName": client_call_details.method,
|
| 104 |
+
"response": grpc_response,
|
| 105 |
+
"metadata": grpc_response["metadata"],
|
| 106 |
+
},
|
| 107 |
+
)
|
| 108 |
+
return response
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
class SpeechGrpcTransport(SpeechTransport):
|
| 112 |
+
"""gRPC backend transport for Speech.
|
| 113 |
+
|
| 114 |
+
Service that implements Google Cloud Speech API.
|
| 115 |
+
|
| 116 |
+
This class defines the same methods as the primary client, so the
|
| 117 |
+
primary client can load the underlying transport implementation
|
| 118 |
+
and call it.
|
| 119 |
+
|
| 120 |
+
It sends protocol buffers over the wire using gRPC (which is built on
|
| 121 |
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
_stubs: Dict[str, Callable]
|
| 125 |
+
|
| 126 |
+
def __init__(
|
| 127 |
+
self,
|
| 128 |
+
*,
|
| 129 |
+
host: str = "speech.googleapis.com",
|
| 130 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 131 |
+
credentials_file: Optional[str] = None,
|
| 132 |
+
scopes: Optional[Sequence[str]] = None,
|
| 133 |
+
channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
|
| 134 |
+
api_mtls_endpoint: Optional[str] = None,
|
| 135 |
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 136 |
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
| 137 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 138 |
+
quota_project_id: Optional[str] = None,
|
| 139 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 140 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 141 |
+
api_audience: Optional[str] = None,
|
| 142 |
+
) -> None:
|
| 143 |
+
"""Instantiate the transport.
|
| 144 |
+
|
| 145 |
+
Args:
|
| 146 |
+
host (Optional[str]):
|
| 147 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 148 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 149 |
+
authorization credentials to attach to requests. These
|
| 150 |
+
credentials identify the application to the service; if none
|
| 151 |
+
are specified, the client will attempt to ascertain the
|
| 152 |
+
credentials from the environment.
|
| 153 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 154 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 155 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 156 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 157 |
+
This argument will be removed in the next major version of this library.
|
| 158 |
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
| 159 |
+
ignored if a ``channel`` instance is provided.
|
| 160 |
+
channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
|
| 161 |
+
A ``Channel`` instance through which to make calls, or a Callable
|
| 162 |
+
that constructs and returns one. If set to None, ``self.create_channel``
|
| 163 |
+
is used to create the channel. If a Callable is given, it will be called
|
| 164 |
+
with the same arguments as used in ``self.create_channel``.
|
| 165 |
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
| 166 |
+
If provided, it overrides the ``host`` argument and tries to create
|
| 167 |
+
a mutual TLS channel with client SSL credentials from
|
| 168 |
+
``client_cert_source`` or application default SSL credentials.
|
| 169 |
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 170 |
+
Deprecated. A callback to provide client SSL certificate bytes and
|
| 171 |
+
private key bytes, both in PEM format. It is ignored if
|
| 172 |
+
``api_mtls_endpoint`` is None.
|
| 173 |
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
| 174 |
+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
|
| 175 |
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 176 |
+
A callback to provide client certificate bytes and private key bytes,
|
| 177 |
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
| 178 |
+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
|
| 179 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 180 |
+
and quota.
|
| 181 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 182 |
+
The client info used to send a user-agent string along with
|
| 183 |
+
API requests. If ``None``, then default info will be used.
|
| 184 |
+
Generally, you only need to set this if you're developing
|
| 185 |
+
your own client library.
|
| 186 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 187 |
+
be used for service account credentials.
|
| 188 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 189 |
+
to the service that will be set when using certain 3rd party
|
| 190 |
+
authentication flows. Audience is typically a resource identifier.
|
| 191 |
+
If not set, the host value will be used as a default.
|
| 192 |
+
|
| 193 |
+
Raises:
|
| 194 |
+
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
|
| 195 |
+
creation failed for any reason.
|
| 196 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 197 |
+
and ``credentials_file`` are passed.
|
| 198 |
+
"""
|
| 199 |
+
self._grpc_channel = None
|
| 200 |
+
self._ssl_channel_credentials = ssl_channel_credentials
|
| 201 |
+
self._stubs: Dict[str, Callable] = {}
|
| 202 |
+
self._operations_client: Optional[operations_v1.OperationsClient] = None
|
| 203 |
+
|
| 204 |
+
if api_mtls_endpoint:
|
| 205 |
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
| 206 |
+
if client_cert_source:
|
| 207 |
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
| 208 |
+
|
| 209 |
+
if isinstance(channel, grpc.Channel):
|
| 210 |
+
# Ignore credentials if a channel was passed.
|
| 211 |
+
credentials = None
|
| 212 |
+
self._ignore_credentials = True
|
| 213 |
+
# If a channel was explicitly provided, set it.
|
| 214 |
+
self._grpc_channel = channel
|
| 215 |
+
self._ssl_channel_credentials = None
|
| 216 |
+
|
| 217 |
+
else:
|
| 218 |
+
if api_mtls_endpoint:
|
| 219 |
+
host = api_mtls_endpoint
|
| 220 |
+
|
| 221 |
+
# Create SSL credentials with client_cert_source or application
|
| 222 |
+
# default SSL credentials.
|
| 223 |
+
if client_cert_source:
|
| 224 |
+
cert, key = client_cert_source()
|
| 225 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 226 |
+
certificate_chain=cert, private_key=key
|
| 227 |
+
)
|
| 228 |
+
else:
|
| 229 |
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
| 230 |
+
|
| 231 |
+
else:
|
| 232 |
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
| 233 |
+
cert, key = client_cert_source_for_mtls()
|
| 234 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 235 |
+
certificate_chain=cert, private_key=key
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
# The base transport sets the host, credentials and scopes
|
| 239 |
+
super().__init__(
|
| 240 |
+
host=host,
|
| 241 |
+
credentials=credentials,
|
| 242 |
+
credentials_file=credentials_file,
|
| 243 |
+
scopes=scopes,
|
| 244 |
+
quota_project_id=quota_project_id,
|
| 245 |
+
client_info=client_info,
|
| 246 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 247 |
+
api_audience=api_audience,
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
if not self._grpc_channel:
|
| 251 |
+
# initialize with the provided callable or the default channel
|
| 252 |
+
channel_init = channel or type(self).create_channel
|
| 253 |
+
self._grpc_channel = channel_init(
|
| 254 |
+
self._host,
|
| 255 |
+
# use the credentials which are saved
|
| 256 |
+
credentials=self._credentials,
|
| 257 |
+
# Set ``credentials_file`` to ``None`` here as
|
| 258 |
+
# the credentials that we saved earlier should be used.
|
| 259 |
+
credentials_file=None,
|
| 260 |
+
scopes=self._scopes,
|
| 261 |
+
ssl_credentials=self._ssl_channel_credentials,
|
| 262 |
+
quota_project_id=quota_project_id,
|
| 263 |
+
options=[
|
| 264 |
+
("grpc.max_send_message_length", -1),
|
| 265 |
+
("grpc.max_receive_message_length", -1),
|
| 266 |
+
],
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
self._interceptor = _LoggingClientInterceptor()
|
| 270 |
+
self._logged_channel = grpc.intercept_channel(
|
| 271 |
+
self._grpc_channel, self._interceptor
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
# Wrap messages. This must be done after self._logged_channel exists
|
| 275 |
+
self._prep_wrapped_messages(client_info)
|
| 276 |
+
|
| 277 |
+
@classmethod
|
| 278 |
+
def create_channel(
|
| 279 |
+
cls,
|
| 280 |
+
host: str = "speech.googleapis.com",
|
| 281 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 282 |
+
credentials_file: Optional[str] = None,
|
| 283 |
+
scopes: Optional[Sequence[str]] = None,
|
| 284 |
+
quota_project_id: Optional[str] = None,
|
| 285 |
+
**kwargs,
|
| 286 |
+
) -> grpc.Channel:
|
| 287 |
+
"""Create and return a gRPC channel object.
|
| 288 |
+
Args:
|
| 289 |
+
host (Optional[str]): The host for the channel to use.
|
| 290 |
+
credentials (Optional[~.Credentials]): The
|
| 291 |
+
authorization credentials to attach to requests. These
|
| 292 |
+
credentials identify this application to the service. If
|
| 293 |
+
none are specified, the client will attempt to ascertain
|
| 294 |
+
the credentials from the environment.
|
| 295 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 296 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 297 |
+
This argument is mutually exclusive with credentials. This argument will be
|
| 298 |
+
removed in the next major version of this library.
|
| 299 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 300 |
+
service. These are only used when credentials are not specified and
|
| 301 |
+
are passed to :func:`google.auth.default`.
|
| 302 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 303 |
+
and quota.
|
| 304 |
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
| 305 |
+
channel creation.
|
| 306 |
+
Returns:
|
| 307 |
+
grpc.Channel: A gRPC channel object.
|
| 308 |
+
|
| 309 |
+
Raises:
|
| 310 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 311 |
+
and ``credentials_file`` are passed.
|
| 312 |
+
"""
|
| 313 |
+
|
| 314 |
+
return grpc_helpers.create_channel(
|
| 315 |
+
host,
|
| 316 |
+
credentials=credentials,
|
| 317 |
+
credentials_file=credentials_file,
|
| 318 |
+
quota_project_id=quota_project_id,
|
| 319 |
+
default_scopes=cls.AUTH_SCOPES,
|
| 320 |
+
scopes=scopes,
|
| 321 |
+
default_host=cls.DEFAULT_HOST,
|
| 322 |
+
**kwargs,
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
@property
|
| 326 |
+
def grpc_channel(self) -> grpc.Channel:
|
| 327 |
+
"""Return the channel designed to connect to this service."""
|
| 328 |
+
return self._grpc_channel
|
| 329 |
+
|
| 330 |
+
@property
|
| 331 |
+
def operations_client(self) -> operations_v1.OperationsClient:
|
| 332 |
+
"""Create the client designed to process long-running operations.
|
| 333 |
+
|
| 334 |
+
This property caches on the instance; repeated calls return the same
|
| 335 |
+
client.
|
| 336 |
+
"""
|
| 337 |
+
# Quick check: Only create a new client if we do not already have one.
|
| 338 |
+
if self._operations_client is None:
|
| 339 |
+
self._operations_client = operations_v1.OperationsClient(
|
| 340 |
+
self._logged_channel
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
# Return the client from cache.
|
| 344 |
+
return self._operations_client
|
| 345 |
+
|
| 346 |
+
@property
|
| 347 |
+
def recognize(
|
| 348 |
+
self,
|
| 349 |
+
) -> Callable[[cloud_speech.RecognizeRequest], cloud_speech.RecognizeResponse]:
|
| 350 |
+
r"""Return a callable for the recognize method over gRPC.
|
| 351 |
+
|
| 352 |
+
Performs synchronous speech recognition: receive
|
| 353 |
+
results after all audio has been sent and processed.
|
| 354 |
+
|
| 355 |
+
Returns:
|
| 356 |
+
Callable[[~.RecognizeRequest],
|
| 357 |
+
~.RecognizeResponse]:
|
| 358 |
+
A function that, when called, will call the underlying RPC
|
| 359 |
+
on the server.
|
| 360 |
+
"""
|
| 361 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 362 |
+
# the request.
|
| 363 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 364 |
+
# to pass in the functions for each.
|
| 365 |
+
if "recognize" not in self._stubs:
|
| 366 |
+
self._stubs["recognize"] = self._logged_channel.unary_unary(
|
| 367 |
+
"/google.cloud.speech.v1p1beta1.Speech/Recognize",
|
| 368 |
+
request_serializer=cloud_speech.RecognizeRequest.serialize,
|
| 369 |
+
response_deserializer=cloud_speech.RecognizeResponse.deserialize,
|
| 370 |
+
)
|
| 371 |
+
return self._stubs["recognize"]
|
| 372 |
+
|
| 373 |
+
@property
|
| 374 |
+
def long_running_recognize(
|
| 375 |
+
self,
|
| 376 |
+
) -> Callable[[cloud_speech.LongRunningRecognizeRequest], operations_pb2.Operation]:
|
| 377 |
+
r"""Return a callable for the long running recognize method over gRPC.
|
| 378 |
+
|
| 379 |
+
Performs asynchronous speech recognition: receive results via
|
| 380 |
+
the google.longrunning.Operations interface. Returns either an
|
| 381 |
+
``Operation.error`` or an ``Operation.response`` which contains
|
| 382 |
+
a ``LongRunningRecognizeResponse`` message. For more information
|
| 383 |
+
on asynchronous speech recognition, see the
|
| 384 |
+
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
|
| 385 |
+
|
| 386 |
+
Returns:
|
| 387 |
+
Callable[[~.LongRunningRecognizeRequest],
|
| 388 |
+
~.Operation]:
|
| 389 |
+
A function that, when called, will call the underlying RPC
|
| 390 |
+
on the server.
|
| 391 |
+
"""
|
| 392 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 393 |
+
# the request.
|
| 394 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 395 |
+
# to pass in the functions for each.
|
| 396 |
+
if "long_running_recognize" not in self._stubs:
|
| 397 |
+
self._stubs["long_running_recognize"] = self._logged_channel.unary_unary(
|
| 398 |
+
"/google.cloud.speech.v1p1beta1.Speech/LongRunningRecognize",
|
| 399 |
+
request_serializer=cloud_speech.LongRunningRecognizeRequest.serialize,
|
| 400 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 401 |
+
)
|
| 402 |
+
return self._stubs["long_running_recognize"]
|
| 403 |
+
|
| 404 |
+
@property
|
| 405 |
+
def streaming_recognize(
|
| 406 |
+
self,
|
| 407 |
+
) -> Callable[
|
| 408 |
+
[cloud_speech.StreamingRecognizeRequest],
|
| 409 |
+
cloud_speech.StreamingRecognizeResponse,
|
| 410 |
+
]:
|
| 411 |
+
r"""Return a callable for the streaming recognize method over gRPC.
|
| 412 |
+
|
| 413 |
+
Performs bidirectional streaming speech recognition:
|
| 414 |
+
receive results while sending audio. This method is only
|
| 415 |
+
available via the gRPC API (not REST).
|
| 416 |
+
|
| 417 |
+
Returns:
|
| 418 |
+
Callable[[~.StreamingRecognizeRequest],
|
| 419 |
+
~.StreamingRecognizeResponse]:
|
| 420 |
+
A function that, when called, will call the underlying RPC
|
| 421 |
+
on the server.
|
| 422 |
+
"""
|
| 423 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 424 |
+
# the request.
|
| 425 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 426 |
+
# to pass in the functions for each.
|
| 427 |
+
if "streaming_recognize" not in self._stubs:
|
| 428 |
+
self._stubs["streaming_recognize"] = self._logged_channel.stream_stream(
|
| 429 |
+
"/google.cloud.speech.v1p1beta1.Speech/StreamingRecognize",
|
| 430 |
+
request_serializer=cloud_speech.StreamingRecognizeRequest.serialize,
|
| 431 |
+
response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize,
|
| 432 |
+
)
|
| 433 |
+
return self._stubs["streaming_recognize"]
|
| 434 |
+
|
| 435 |
+
def close(self):
|
| 436 |
+
self._logged_channel.close()
|
| 437 |
+
|
| 438 |
+
@property
|
| 439 |
+
def get_operation(
|
| 440 |
+
self,
|
| 441 |
+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
|
| 442 |
+
r"""Return a callable for the get_operation method over gRPC."""
|
| 443 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 444 |
+
# the request.
|
| 445 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 446 |
+
# to pass in the functions for each.
|
| 447 |
+
if "get_operation" not in self._stubs:
|
| 448 |
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
| 449 |
+
"/google.longrunning.Operations/GetOperation",
|
| 450 |
+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
| 451 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 452 |
+
)
|
| 453 |
+
return self._stubs["get_operation"]
|
| 454 |
+
|
| 455 |
+
@property
|
| 456 |
+
def list_operations(
|
| 457 |
+
self,
|
| 458 |
+
) -> Callable[
|
| 459 |
+
[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
|
| 460 |
+
]:
|
| 461 |
+
r"""Return a callable for the list_operations method over gRPC."""
|
| 462 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 463 |
+
# the request.
|
| 464 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 465 |
+
# to pass in the functions for each.
|
| 466 |
+
if "list_operations" not in self._stubs:
|
| 467 |
+
self._stubs["list_operations"] = self._logged_channel.unary_unary(
|
| 468 |
+
"/google.longrunning.Operations/ListOperations",
|
| 469 |
+
request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
|
| 470 |
+
response_deserializer=operations_pb2.ListOperationsResponse.FromString,
|
| 471 |
+
)
|
| 472 |
+
return self._stubs["list_operations"]
|
| 473 |
+
|
| 474 |
+
@property
|
| 475 |
+
def kind(self) -> str:
|
| 476 |
+
return "grpc"
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
__all__ = ("SpeechGrpcTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/grpc_asyncio.py
ADDED
|
@@ -0,0 +1,546 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import inspect
|
| 17 |
+
import json
|
| 18 |
+
import logging as std_logging
|
| 19 |
+
import pickle
|
| 20 |
+
import warnings
|
| 21 |
+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
|
| 22 |
+
|
| 23 |
+
import google.protobuf.message
|
| 24 |
+
import grpc # type: ignore
|
| 25 |
+
import proto # type: ignore
|
| 26 |
+
from google.api_core import exceptions as core_exceptions
|
| 27 |
+
from google.api_core import gapic_v1, grpc_helpers_async, operations_v1
|
| 28 |
+
from google.api_core import retry_async as retries
|
| 29 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 30 |
+
from google.auth.transport.grpc import SslCredentials # type: ignore
|
| 31 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 32 |
+
from google.protobuf.json_format import MessageToJson
|
| 33 |
+
from grpc.experimental import aio # type: ignore
|
| 34 |
+
|
| 35 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech
|
| 36 |
+
|
| 37 |
+
from .base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 38 |
+
from .grpc import SpeechGrpcTransport
|
| 39 |
+
|
| 40 |
+
try:
|
| 41 |
+
from google.api_core import client_logging # type: ignore
|
| 42 |
+
|
| 43 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 44 |
+
except ImportError: # pragma: NO COVER
|
| 45 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 46 |
+
|
| 47 |
+
_LOGGER = std_logging.getLogger(__name__)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class _LoggingClientAIOInterceptor(
|
| 51 |
+
grpc.aio.UnaryUnaryClientInterceptor
|
| 52 |
+
): # pragma: NO COVER
|
| 53 |
+
async def intercept_unary_unary(self, continuation, client_call_details, request):
|
| 54 |
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 55 |
+
std_logging.DEBUG
|
| 56 |
+
)
|
| 57 |
+
if logging_enabled: # pragma: NO COVER
|
| 58 |
+
request_metadata = client_call_details.metadata
|
| 59 |
+
if isinstance(request, proto.Message):
|
| 60 |
+
request_payload = type(request).to_json(request)
|
| 61 |
+
elif isinstance(request, google.protobuf.message.Message):
|
| 62 |
+
request_payload = MessageToJson(request)
|
| 63 |
+
else:
|
| 64 |
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
|
| 65 |
+
|
| 66 |
+
request_metadata = {
|
| 67 |
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
| 68 |
+
for key, value in request_metadata
|
| 69 |
+
}
|
| 70 |
+
grpc_request = {
|
| 71 |
+
"payload": request_payload,
|
| 72 |
+
"requestMethod": "grpc",
|
| 73 |
+
"metadata": dict(request_metadata),
|
| 74 |
+
}
|
| 75 |
+
_LOGGER.debug(
|
| 76 |
+
f"Sending request for {client_call_details.method}",
|
| 77 |
+
extra={
|
| 78 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 79 |
+
"rpcName": str(client_call_details.method),
|
| 80 |
+
"request": grpc_request,
|
| 81 |
+
"metadata": grpc_request["metadata"],
|
| 82 |
+
},
|
| 83 |
+
)
|
| 84 |
+
response = await continuation(client_call_details, request)
|
| 85 |
+
if logging_enabled: # pragma: NO COVER
|
| 86 |
+
response_metadata = await response.trailing_metadata()
|
| 87 |
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
| 88 |
+
metadata = (
|
| 89 |
+
dict([(k, str(v)) for k, v in response_metadata])
|
| 90 |
+
if response_metadata
|
| 91 |
+
else None
|
| 92 |
+
)
|
| 93 |
+
result = await response
|
| 94 |
+
if isinstance(result, proto.Message):
|
| 95 |
+
response_payload = type(result).to_json(result)
|
| 96 |
+
elif isinstance(result, google.protobuf.message.Message):
|
| 97 |
+
response_payload = MessageToJson(result)
|
| 98 |
+
else:
|
| 99 |
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
|
| 100 |
+
grpc_response = {
|
| 101 |
+
"payload": response_payload,
|
| 102 |
+
"metadata": metadata,
|
| 103 |
+
"status": "OK",
|
| 104 |
+
}
|
| 105 |
+
_LOGGER.debug(
|
| 106 |
+
f"Received response to rpc {client_call_details.method}.",
|
| 107 |
+
extra={
|
| 108 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 109 |
+
"rpcName": str(client_call_details.method),
|
| 110 |
+
"response": grpc_response,
|
| 111 |
+
"metadata": grpc_response["metadata"],
|
| 112 |
+
},
|
| 113 |
+
)
|
| 114 |
+
return response
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
class SpeechGrpcAsyncIOTransport(SpeechTransport):
|
| 118 |
+
"""gRPC AsyncIO backend transport for Speech.
|
| 119 |
+
|
| 120 |
+
Service that implements Google Cloud Speech API.
|
| 121 |
+
|
| 122 |
+
This class defines the same methods as the primary client, so the
|
| 123 |
+
primary client can load the underlying transport implementation
|
| 124 |
+
and call it.
|
| 125 |
+
|
| 126 |
+
It sends protocol buffers over the wire using gRPC (which is built on
|
| 127 |
+
top of HTTP/2); the ``grpcio`` package must be installed.
|
| 128 |
+
"""
|
| 129 |
+
|
| 130 |
+
_grpc_channel: aio.Channel
|
| 131 |
+
_stubs: Dict[str, Callable] = {}
|
| 132 |
+
|
| 133 |
+
@classmethod
|
| 134 |
+
def create_channel(
|
| 135 |
+
cls,
|
| 136 |
+
host: str = "speech.googleapis.com",
|
| 137 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 138 |
+
credentials_file: Optional[str] = None,
|
| 139 |
+
scopes: Optional[Sequence[str]] = None,
|
| 140 |
+
quota_project_id: Optional[str] = None,
|
| 141 |
+
**kwargs,
|
| 142 |
+
) -> aio.Channel:
|
| 143 |
+
"""Create and return a gRPC AsyncIO channel object.
|
| 144 |
+
Args:
|
| 145 |
+
host (Optional[str]): The host for the channel to use.
|
| 146 |
+
credentials (Optional[~.Credentials]): The
|
| 147 |
+
authorization credentials to attach to requests. These
|
| 148 |
+
credentials identify this application to the service. If
|
| 149 |
+
none are specified, the client will attempt to ascertain
|
| 150 |
+
the credentials from the environment.
|
| 151 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 152 |
+
be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be
|
| 153 |
+
removed in the next major version of this library.
|
| 154 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 155 |
+
service. These are only used when credentials are not specified and
|
| 156 |
+
are passed to :func:`google.auth.default`.
|
| 157 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 158 |
+
and quota.
|
| 159 |
+
kwargs (Optional[dict]): Keyword arguments, which are passed to the
|
| 160 |
+
channel creation.
|
| 161 |
+
Returns:
|
| 162 |
+
aio.Channel: A gRPC AsyncIO channel object.
|
| 163 |
+
"""
|
| 164 |
+
|
| 165 |
+
return grpc_helpers_async.create_channel(
|
| 166 |
+
host,
|
| 167 |
+
credentials=credentials,
|
| 168 |
+
credentials_file=credentials_file,
|
| 169 |
+
quota_project_id=quota_project_id,
|
| 170 |
+
default_scopes=cls.AUTH_SCOPES,
|
| 171 |
+
scopes=scopes,
|
| 172 |
+
default_host=cls.DEFAULT_HOST,
|
| 173 |
+
**kwargs,
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
def __init__(
|
| 177 |
+
self,
|
| 178 |
+
*,
|
| 179 |
+
host: str = "speech.googleapis.com",
|
| 180 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 181 |
+
credentials_file: Optional[str] = None,
|
| 182 |
+
scopes: Optional[Sequence[str]] = None,
|
| 183 |
+
channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
|
| 184 |
+
api_mtls_endpoint: Optional[str] = None,
|
| 185 |
+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 186 |
+
ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
|
| 187 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 188 |
+
quota_project_id: Optional[str] = None,
|
| 189 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 190 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 191 |
+
api_audience: Optional[str] = None,
|
| 192 |
+
) -> None:
|
| 193 |
+
"""Instantiate the transport.
|
| 194 |
+
|
| 195 |
+
Args:
|
| 196 |
+
host (Optional[str]):
|
| 197 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 198 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 199 |
+
authorization credentials to attach to requests. These
|
| 200 |
+
credentials identify the application to the service; if none
|
| 201 |
+
are specified, the client will attempt to ascertain the
|
| 202 |
+
credentials from the environment.
|
| 203 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 204 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 205 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 206 |
+
This argument is ignored if a ``channel`` instance is provided.
|
| 207 |
+
This argument will be removed in the next major version of this library.
|
| 208 |
+
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
|
| 209 |
+
service. These are only used when credentials are not specified and
|
| 210 |
+
are passed to :func:`google.auth.default`.
|
| 211 |
+
channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
|
| 212 |
+
A ``Channel`` instance through which to make calls, or a Callable
|
| 213 |
+
that constructs and returns one. If set to None, ``self.create_channel``
|
| 214 |
+
is used to create the channel. If a Callable is given, it will be called
|
| 215 |
+
with the same arguments as used in ``self.create_channel``.
|
| 216 |
+
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
|
| 217 |
+
If provided, it overrides the ``host`` argument and tries to create
|
| 218 |
+
a mutual TLS channel with client SSL credentials from
|
| 219 |
+
``client_cert_source`` or application default SSL credentials.
|
| 220 |
+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 221 |
+
Deprecated. A callback to provide client SSL certificate bytes and
|
| 222 |
+
private key bytes, both in PEM format. It is ignored if
|
| 223 |
+
``api_mtls_endpoint`` is None.
|
| 224 |
+
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
|
| 225 |
+
for the grpc channel. It is ignored if a ``channel`` instance is provided.
|
| 226 |
+
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
|
| 227 |
+
A callback to provide client certificate bytes and private key bytes,
|
| 228 |
+
both in PEM format. It is used to configure a mutual TLS channel. It is
|
| 229 |
+
ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
|
| 230 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 231 |
+
and quota.
|
| 232 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 233 |
+
The client info used to send a user-agent string along with
|
| 234 |
+
API requests. If ``None``, then default info will be used.
|
| 235 |
+
Generally, you only need to set this if you're developing
|
| 236 |
+
your own client library.
|
| 237 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 238 |
+
be used for service account credentials.
|
| 239 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 240 |
+
to the service that will be set when using certain 3rd party
|
| 241 |
+
authentication flows. Audience is typically a resource identifier.
|
| 242 |
+
If not set, the host value will be used as a default.
|
| 243 |
+
|
| 244 |
+
Raises:
|
| 245 |
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
| 246 |
+
creation failed for any reason.
|
| 247 |
+
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
|
| 248 |
+
and ``credentials_file`` are passed.
|
| 249 |
+
"""
|
| 250 |
+
self._grpc_channel = None
|
| 251 |
+
self._ssl_channel_credentials = ssl_channel_credentials
|
| 252 |
+
self._stubs: Dict[str, Callable] = {}
|
| 253 |
+
self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None
|
| 254 |
+
|
| 255 |
+
if api_mtls_endpoint:
|
| 256 |
+
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
|
| 257 |
+
if client_cert_source:
|
| 258 |
+
warnings.warn("client_cert_source is deprecated", DeprecationWarning)
|
| 259 |
+
|
| 260 |
+
if isinstance(channel, aio.Channel):
|
| 261 |
+
# Ignore credentials if a channel was passed.
|
| 262 |
+
credentials = None
|
| 263 |
+
self._ignore_credentials = True
|
| 264 |
+
# If a channel was explicitly provided, set it.
|
| 265 |
+
self._grpc_channel = channel
|
| 266 |
+
self._ssl_channel_credentials = None
|
| 267 |
+
else:
|
| 268 |
+
if api_mtls_endpoint:
|
| 269 |
+
host = api_mtls_endpoint
|
| 270 |
+
|
| 271 |
+
# Create SSL credentials with client_cert_source or application
|
| 272 |
+
# default SSL credentials.
|
| 273 |
+
if client_cert_source:
|
| 274 |
+
cert, key = client_cert_source()
|
| 275 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 276 |
+
certificate_chain=cert, private_key=key
|
| 277 |
+
)
|
| 278 |
+
else:
|
| 279 |
+
self._ssl_channel_credentials = SslCredentials().ssl_credentials
|
| 280 |
+
|
| 281 |
+
else:
|
| 282 |
+
if client_cert_source_for_mtls and not ssl_channel_credentials:
|
| 283 |
+
cert, key = client_cert_source_for_mtls()
|
| 284 |
+
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
|
| 285 |
+
certificate_chain=cert, private_key=key
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
# The base transport sets the host, credentials and scopes
|
| 289 |
+
super().__init__(
|
| 290 |
+
host=host,
|
| 291 |
+
credentials=credentials,
|
| 292 |
+
credentials_file=credentials_file,
|
| 293 |
+
scopes=scopes,
|
| 294 |
+
quota_project_id=quota_project_id,
|
| 295 |
+
client_info=client_info,
|
| 296 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 297 |
+
api_audience=api_audience,
|
| 298 |
+
)
|
| 299 |
+
|
| 300 |
+
if not self._grpc_channel:
|
| 301 |
+
# initialize with the provided callable or the default channel
|
| 302 |
+
channel_init = channel or type(self).create_channel
|
| 303 |
+
self._grpc_channel = channel_init(
|
| 304 |
+
self._host,
|
| 305 |
+
# use the credentials which are saved
|
| 306 |
+
credentials=self._credentials,
|
| 307 |
+
# Set ``credentials_file`` to ``None`` here as
|
| 308 |
+
# the credentials that we saved earlier should be used.
|
| 309 |
+
credentials_file=None,
|
| 310 |
+
scopes=self._scopes,
|
| 311 |
+
ssl_credentials=self._ssl_channel_credentials,
|
| 312 |
+
quota_project_id=quota_project_id,
|
| 313 |
+
options=[
|
| 314 |
+
("grpc.max_send_message_length", -1),
|
| 315 |
+
("grpc.max_receive_message_length", -1),
|
| 316 |
+
],
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
+
self._interceptor = _LoggingClientAIOInterceptor()
|
| 320 |
+
self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
|
| 321 |
+
self._logged_channel = self._grpc_channel
|
| 322 |
+
self._wrap_with_kind = (
|
| 323 |
+
"kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
|
| 324 |
+
)
|
| 325 |
+
# Wrap messages. This must be done after self._logged_channel exists
|
| 326 |
+
self._prep_wrapped_messages(client_info)
|
| 327 |
+
|
| 328 |
+
@property
|
| 329 |
+
def grpc_channel(self) -> aio.Channel:
|
| 330 |
+
"""Create the channel designed to connect to this service.
|
| 331 |
+
|
| 332 |
+
This property caches on the instance; repeated calls return
|
| 333 |
+
the same channel.
|
| 334 |
+
"""
|
| 335 |
+
# Return the channel from cache.
|
| 336 |
+
return self._grpc_channel
|
| 337 |
+
|
| 338 |
+
@property
|
| 339 |
+
def operations_client(self) -> operations_v1.OperationsAsyncClient:
|
| 340 |
+
"""Create the client designed to process long-running operations.
|
| 341 |
+
|
| 342 |
+
This property caches on the instance; repeated calls return the same
|
| 343 |
+
client.
|
| 344 |
+
"""
|
| 345 |
+
# Quick check: Only create a new client if we do not already have one.
|
| 346 |
+
if self._operations_client is None:
|
| 347 |
+
self._operations_client = operations_v1.OperationsAsyncClient(
|
| 348 |
+
self._logged_channel
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
+
# Return the client from cache.
|
| 352 |
+
return self._operations_client
|
| 353 |
+
|
| 354 |
+
@property
|
| 355 |
+
def recognize(
|
| 356 |
+
self,
|
| 357 |
+
) -> Callable[
|
| 358 |
+
[cloud_speech.RecognizeRequest], Awaitable[cloud_speech.RecognizeResponse]
|
| 359 |
+
]:
|
| 360 |
+
r"""Return a callable for the recognize method over gRPC.
|
| 361 |
+
|
| 362 |
+
Performs synchronous speech recognition: receive
|
| 363 |
+
results after all audio has been sent and processed.
|
| 364 |
+
|
| 365 |
+
Returns:
|
| 366 |
+
Callable[[~.RecognizeRequest],
|
| 367 |
+
Awaitable[~.RecognizeResponse]]:
|
| 368 |
+
A function that, when called, will call the underlying RPC
|
| 369 |
+
on the server.
|
| 370 |
+
"""
|
| 371 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 372 |
+
# the request.
|
| 373 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 374 |
+
# to pass in the functions for each.
|
| 375 |
+
if "recognize" not in self._stubs:
|
| 376 |
+
self._stubs["recognize"] = self._logged_channel.unary_unary(
|
| 377 |
+
"/google.cloud.speech.v1p1beta1.Speech/Recognize",
|
| 378 |
+
request_serializer=cloud_speech.RecognizeRequest.serialize,
|
| 379 |
+
response_deserializer=cloud_speech.RecognizeResponse.deserialize,
|
| 380 |
+
)
|
| 381 |
+
return self._stubs["recognize"]
|
| 382 |
+
|
| 383 |
+
@property
|
| 384 |
+
def long_running_recognize(
|
| 385 |
+
self,
|
| 386 |
+
) -> Callable[
|
| 387 |
+
[cloud_speech.LongRunningRecognizeRequest], Awaitable[operations_pb2.Operation]
|
| 388 |
+
]:
|
| 389 |
+
r"""Return a callable for the long running recognize method over gRPC.
|
| 390 |
+
|
| 391 |
+
Performs asynchronous speech recognition: receive results via
|
| 392 |
+
the google.longrunning.Operations interface. Returns either an
|
| 393 |
+
``Operation.error`` or an ``Operation.response`` which contains
|
| 394 |
+
a ``LongRunningRecognizeResponse`` message. For more information
|
| 395 |
+
on asynchronous speech recognition, see the
|
| 396 |
+
`how-to <https://cloud.google.com/speech-to-text/docs/async-recognize>`__.
|
| 397 |
+
|
| 398 |
+
Returns:
|
| 399 |
+
Callable[[~.LongRunningRecognizeRequest],
|
| 400 |
+
Awaitable[~.Operation]]:
|
| 401 |
+
A function that, when called, will call the underlying RPC
|
| 402 |
+
on the server.
|
| 403 |
+
"""
|
| 404 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 405 |
+
# the request.
|
| 406 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 407 |
+
# to pass in the functions for each.
|
| 408 |
+
if "long_running_recognize" not in self._stubs:
|
| 409 |
+
self._stubs["long_running_recognize"] = self._logged_channel.unary_unary(
|
| 410 |
+
"/google.cloud.speech.v1p1beta1.Speech/LongRunningRecognize",
|
| 411 |
+
request_serializer=cloud_speech.LongRunningRecognizeRequest.serialize,
|
| 412 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 413 |
+
)
|
| 414 |
+
return self._stubs["long_running_recognize"]
|
| 415 |
+
|
| 416 |
+
@property
|
| 417 |
+
def streaming_recognize(
|
| 418 |
+
self,
|
| 419 |
+
) -> Callable[
|
| 420 |
+
[cloud_speech.StreamingRecognizeRequest],
|
| 421 |
+
Awaitable[cloud_speech.StreamingRecognizeResponse],
|
| 422 |
+
]:
|
| 423 |
+
r"""Return a callable for the streaming recognize method over gRPC.
|
| 424 |
+
|
| 425 |
+
Performs bidirectional streaming speech recognition:
|
| 426 |
+
receive results while sending audio. This method is only
|
| 427 |
+
available via the gRPC API (not REST).
|
| 428 |
+
|
| 429 |
+
Returns:
|
| 430 |
+
Callable[[~.StreamingRecognizeRequest],
|
| 431 |
+
Awaitable[~.StreamingRecognizeResponse]]:
|
| 432 |
+
A function that, when called, will call the underlying RPC
|
| 433 |
+
on the server.
|
| 434 |
+
"""
|
| 435 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 436 |
+
# the request.
|
| 437 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 438 |
+
# to pass in the functions for each.
|
| 439 |
+
if "streaming_recognize" not in self._stubs:
|
| 440 |
+
self._stubs["streaming_recognize"] = self._logged_channel.stream_stream(
|
| 441 |
+
"/google.cloud.speech.v1p1beta1.Speech/StreamingRecognize",
|
| 442 |
+
request_serializer=cloud_speech.StreamingRecognizeRequest.serialize,
|
| 443 |
+
response_deserializer=cloud_speech.StreamingRecognizeResponse.deserialize,
|
| 444 |
+
)
|
| 445 |
+
return self._stubs["streaming_recognize"]
|
| 446 |
+
|
| 447 |
+
def _prep_wrapped_messages(self, client_info):
|
| 448 |
+
"""Precompute the wrapped methods, overriding the base class method to use async wrappers."""
|
| 449 |
+
self._wrapped_methods = {
|
| 450 |
+
self.recognize: self._wrap_method(
|
| 451 |
+
self.recognize,
|
| 452 |
+
default_retry=retries.AsyncRetry(
|
| 453 |
+
initial=0.1,
|
| 454 |
+
maximum=60.0,
|
| 455 |
+
multiplier=1.3,
|
| 456 |
+
predicate=retries.if_exception_type(
|
| 457 |
+
core_exceptions.DeadlineExceeded,
|
| 458 |
+
core_exceptions.ServiceUnavailable,
|
| 459 |
+
),
|
| 460 |
+
deadline=5000.0,
|
| 461 |
+
),
|
| 462 |
+
default_timeout=5000.0,
|
| 463 |
+
client_info=client_info,
|
| 464 |
+
),
|
| 465 |
+
self.long_running_recognize: self._wrap_method(
|
| 466 |
+
self.long_running_recognize,
|
| 467 |
+
default_timeout=5000.0,
|
| 468 |
+
client_info=client_info,
|
| 469 |
+
),
|
| 470 |
+
self.streaming_recognize: self._wrap_method(
|
| 471 |
+
self.streaming_recognize,
|
| 472 |
+
default_retry=retries.AsyncRetry(
|
| 473 |
+
initial=0.1,
|
| 474 |
+
maximum=60.0,
|
| 475 |
+
multiplier=1.3,
|
| 476 |
+
predicate=retries.if_exception_type(
|
| 477 |
+
core_exceptions.DeadlineExceeded,
|
| 478 |
+
core_exceptions.ServiceUnavailable,
|
| 479 |
+
),
|
| 480 |
+
deadline=5000.0,
|
| 481 |
+
),
|
| 482 |
+
default_timeout=5000.0,
|
| 483 |
+
client_info=client_info,
|
| 484 |
+
),
|
| 485 |
+
self.get_operation: self._wrap_method(
|
| 486 |
+
self.get_operation,
|
| 487 |
+
default_timeout=None,
|
| 488 |
+
client_info=client_info,
|
| 489 |
+
),
|
| 490 |
+
self.list_operations: self._wrap_method(
|
| 491 |
+
self.list_operations,
|
| 492 |
+
default_timeout=None,
|
| 493 |
+
client_info=client_info,
|
| 494 |
+
),
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
def _wrap_method(self, func, *args, **kwargs):
|
| 498 |
+
if self._wrap_with_kind: # pragma: NO COVER
|
| 499 |
+
kwargs["kind"] = self.kind
|
| 500 |
+
return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
|
| 501 |
+
|
| 502 |
+
def close(self):
|
| 503 |
+
return self._logged_channel.close()
|
| 504 |
+
|
| 505 |
+
@property
|
| 506 |
+
def kind(self) -> str:
|
| 507 |
+
return "grpc_asyncio"
|
| 508 |
+
|
| 509 |
+
@property
|
| 510 |
+
def get_operation(
|
| 511 |
+
self,
|
| 512 |
+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
|
| 513 |
+
r"""Return a callable for the get_operation method over gRPC."""
|
| 514 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 515 |
+
# the request.
|
| 516 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 517 |
+
# to pass in the functions for each.
|
| 518 |
+
if "get_operation" not in self._stubs:
|
| 519 |
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
| 520 |
+
"/google.longrunning.Operations/GetOperation",
|
| 521 |
+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
| 522 |
+
response_deserializer=operations_pb2.Operation.FromString,
|
| 523 |
+
)
|
| 524 |
+
return self._stubs["get_operation"]
|
| 525 |
+
|
| 526 |
+
@property
|
| 527 |
+
def list_operations(
|
| 528 |
+
self,
|
| 529 |
+
) -> Callable[
|
| 530 |
+
[operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
|
| 531 |
+
]:
|
| 532 |
+
r"""Return a callable for the list_operations method over gRPC."""
|
| 533 |
+
# Generate a "stub function" on-the-fly which will actually make
|
| 534 |
+
# the request.
|
| 535 |
+
# gRPC handles serialization and deserialization, so we just need
|
| 536 |
+
# to pass in the functions for each.
|
| 537 |
+
if "list_operations" not in self._stubs:
|
| 538 |
+
self._stubs["list_operations"] = self._logged_channel.unary_unary(
|
| 539 |
+
"/google.longrunning.Operations/ListOperations",
|
| 540 |
+
request_serializer=operations_pb2.ListOperationsRequest.SerializeToString,
|
| 541 |
+
response_deserializer=operations_pb2.ListOperationsResponse.FromString,
|
| 542 |
+
)
|
| 543 |
+
return self._stubs["list_operations"]
|
| 544 |
+
|
| 545 |
+
|
| 546 |
+
__all__ = ("SpeechGrpcAsyncIOTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/rest.py
ADDED
|
@@ -0,0 +1,1023 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import dataclasses
|
| 17 |
+
import json # type: ignore
|
| 18 |
+
import logging
|
| 19 |
+
import warnings
|
| 20 |
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
| 21 |
+
|
| 22 |
+
import google.protobuf
|
| 23 |
+
from google.api_core import exceptions as core_exceptions
|
| 24 |
+
from google.api_core import gapic_v1, operations_v1, rest_helpers, rest_streaming
|
| 25 |
+
from google.api_core import retry as retries
|
| 26 |
+
from google.auth import credentials as ga_credentials # type: ignore
|
| 27 |
+
from google.auth.transport.requests import AuthorizedSession # type: ignore
|
| 28 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 29 |
+
from google.protobuf import json_format
|
| 30 |
+
from requests import __version__ as requests_version
|
| 31 |
+
|
| 32 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech
|
| 33 |
+
|
| 34 |
+
from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
|
| 35 |
+
from .rest_base import _BaseSpeechRestTransport
|
| 36 |
+
|
| 37 |
+
try:
|
| 38 |
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
| 39 |
+
except AttributeError: # pragma: NO COVER
|
| 40 |
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
| 41 |
+
|
| 42 |
+
try:
|
| 43 |
+
from google.api_core import client_logging # type: ignore
|
| 44 |
+
|
| 45 |
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
| 46 |
+
except ImportError: # pragma: NO COVER
|
| 47 |
+
CLIENT_LOGGING_SUPPORTED = False
|
| 48 |
+
|
| 49 |
+
_LOGGER = logging.getLogger(__name__)
|
| 50 |
+
|
| 51 |
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
| 52 |
+
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
|
| 53 |
+
grpc_version=None,
|
| 54 |
+
rest_version=f"requests@{requests_version}",
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
| 58 |
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class SpeechRestInterceptor:
|
| 62 |
+
"""Interceptor for Speech.
|
| 63 |
+
|
| 64 |
+
Interceptors are used to manipulate requests, request metadata, and responses
|
| 65 |
+
in arbitrary ways.
|
| 66 |
+
Example use cases include:
|
| 67 |
+
* Logging
|
| 68 |
+
* Verifying requests according to service or custom semantics
|
| 69 |
+
* Stripping extraneous information from responses
|
| 70 |
+
|
| 71 |
+
These use cases and more can be enabled by injecting an
|
| 72 |
+
instance of a custom subclass when constructing the SpeechRestTransport.
|
| 73 |
+
|
| 74 |
+
.. code-block:: python
|
| 75 |
+
class MyCustomSpeechInterceptor(SpeechRestInterceptor):
|
| 76 |
+
def pre_long_running_recognize(self, request, metadata):
|
| 77 |
+
logging.log(f"Received request: {request}")
|
| 78 |
+
return request, metadata
|
| 79 |
+
|
| 80 |
+
def post_long_running_recognize(self, response):
|
| 81 |
+
logging.log(f"Received response: {response}")
|
| 82 |
+
return response
|
| 83 |
+
|
| 84 |
+
def pre_recognize(self, request, metadata):
|
| 85 |
+
logging.log(f"Received request: {request}")
|
| 86 |
+
return request, metadata
|
| 87 |
+
|
| 88 |
+
def post_recognize(self, response):
|
| 89 |
+
logging.log(f"Received response: {response}")
|
| 90 |
+
return response
|
| 91 |
+
|
| 92 |
+
transport = SpeechRestTransport(interceptor=MyCustomSpeechInterceptor())
|
| 93 |
+
client = SpeechClient(transport=transport)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
"""
|
| 97 |
+
|
| 98 |
+
def pre_long_running_recognize(
|
| 99 |
+
self,
|
| 100 |
+
request: cloud_speech.LongRunningRecognizeRequest,
|
| 101 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 102 |
+
) -> Tuple[
|
| 103 |
+
cloud_speech.LongRunningRecognizeRequest,
|
| 104 |
+
Sequence[Tuple[str, Union[str, bytes]]],
|
| 105 |
+
]:
|
| 106 |
+
"""Pre-rpc interceptor for long_running_recognize
|
| 107 |
+
|
| 108 |
+
Override in a subclass to manipulate the request or metadata
|
| 109 |
+
before they are sent to the Speech server.
|
| 110 |
+
"""
|
| 111 |
+
return request, metadata
|
| 112 |
+
|
| 113 |
+
def post_long_running_recognize(
|
| 114 |
+
self, response: operations_pb2.Operation
|
| 115 |
+
) -> operations_pb2.Operation:
|
| 116 |
+
"""Post-rpc interceptor for long_running_recognize
|
| 117 |
+
|
| 118 |
+
DEPRECATED. Please use the `post_long_running_recognize_with_metadata`
|
| 119 |
+
interceptor instead.
|
| 120 |
+
|
| 121 |
+
Override in a subclass to read or manipulate the response
|
| 122 |
+
after it is returned by the Speech server but before
|
| 123 |
+
it is returned to user code. This `post_long_running_recognize` interceptor runs
|
| 124 |
+
before the `post_long_running_recognize_with_metadata` interceptor.
|
| 125 |
+
"""
|
| 126 |
+
return response
|
| 127 |
+
|
| 128 |
+
def post_long_running_recognize_with_metadata(
|
| 129 |
+
self,
|
| 130 |
+
response: operations_pb2.Operation,
|
| 131 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 132 |
+
) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]:
|
| 133 |
+
"""Post-rpc interceptor for long_running_recognize
|
| 134 |
+
|
| 135 |
+
Override in a subclass to read or manipulate the response or metadata after it
|
| 136 |
+
is returned by the Speech server but before it is returned to user code.
|
| 137 |
+
|
| 138 |
+
We recommend only using this `post_long_running_recognize_with_metadata`
|
| 139 |
+
interceptor in new development instead of the `post_long_running_recognize` interceptor.
|
| 140 |
+
When both interceptors are used, this `post_long_running_recognize_with_metadata` interceptor runs after the
|
| 141 |
+
`post_long_running_recognize` interceptor. The (possibly modified) response returned by
|
| 142 |
+
`post_long_running_recognize` will be passed to
|
| 143 |
+
`post_long_running_recognize_with_metadata`.
|
| 144 |
+
"""
|
| 145 |
+
return response, metadata
|
| 146 |
+
|
| 147 |
+
def pre_recognize(
|
| 148 |
+
self,
|
| 149 |
+
request: cloud_speech.RecognizeRequest,
|
| 150 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 151 |
+
) -> Tuple[cloud_speech.RecognizeRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
|
| 152 |
+
"""Pre-rpc interceptor for recognize
|
| 153 |
+
|
| 154 |
+
Override in a subclass to manipulate the request or metadata
|
| 155 |
+
before they are sent to the Speech server.
|
| 156 |
+
"""
|
| 157 |
+
return request, metadata
|
| 158 |
+
|
| 159 |
+
def post_recognize(
|
| 160 |
+
self, response: cloud_speech.RecognizeResponse
|
| 161 |
+
) -> cloud_speech.RecognizeResponse:
|
| 162 |
+
"""Post-rpc interceptor for recognize
|
| 163 |
+
|
| 164 |
+
DEPRECATED. Please use the `post_recognize_with_metadata`
|
| 165 |
+
interceptor instead.
|
| 166 |
+
|
| 167 |
+
Override in a subclass to read or manipulate the response
|
| 168 |
+
after it is returned by the Speech server but before
|
| 169 |
+
it is returned to user code. This `post_recognize` interceptor runs
|
| 170 |
+
before the `post_recognize_with_metadata` interceptor.
|
| 171 |
+
"""
|
| 172 |
+
return response
|
| 173 |
+
|
| 174 |
+
def post_recognize_with_metadata(
|
| 175 |
+
self,
|
| 176 |
+
response: cloud_speech.RecognizeResponse,
|
| 177 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 178 |
+
) -> Tuple[cloud_speech.RecognizeResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
|
| 179 |
+
"""Post-rpc interceptor for recognize
|
| 180 |
+
|
| 181 |
+
Override in a subclass to read or manipulate the response or metadata after it
|
| 182 |
+
is returned by the Speech server but before it is returned to user code.
|
| 183 |
+
|
| 184 |
+
We recommend only using this `post_recognize_with_metadata`
|
| 185 |
+
interceptor in new development instead of the `post_recognize` interceptor.
|
| 186 |
+
When both interceptors are used, this `post_recognize_with_metadata` interceptor runs after the
|
| 187 |
+
`post_recognize` interceptor. The (possibly modified) response returned by
|
| 188 |
+
`post_recognize` will be passed to
|
| 189 |
+
`post_recognize_with_metadata`.
|
| 190 |
+
"""
|
| 191 |
+
return response, metadata
|
| 192 |
+
|
| 193 |
+
def pre_get_operation(
|
| 194 |
+
self,
|
| 195 |
+
request: operations_pb2.GetOperationRequest,
|
| 196 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 197 |
+
) -> Tuple[
|
| 198 |
+
operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
| 199 |
+
]:
|
| 200 |
+
"""Pre-rpc interceptor for get_operation
|
| 201 |
+
|
| 202 |
+
Override in a subclass to manipulate the request or metadata
|
| 203 |
+
before they are sent to the Speech server.
|
| 204 |
+
"""
|
| 205 |
+
return request, metadata
|
| 206 |
+
|
| 207 |
+
def post_get_operation(
|
| 208 |
+
self, response: operations_pb2.Operation
|
| 209 |
+
) -> operations_pb2.Operation:
|
| 210 |
+
"""Post-rpc interceptor for get_operation
|
| 211 |
+
|
| 212 |
+
Override in a subclass to manipulate the response
|
| 213 |
+
after it is returned by the Speech server but before
|
| 214 |
+
it is returned to user code.
|
| 215 |
+
"""
|
| 216 |
+
return response
|
| 217 |
+
|
| 218 |
+
def pre_list_operations(
|
| 219 |
+
self,
|
| 220 |
+
request: operations_pb2.ListOperationsRequest,
|
| 221 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
| 222 |
+
) -> Tuple[
|
| 223 |
+
operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
| 224 |
+
]:
|
| 225 |
+
"""Pre-rpc interceptor for list_operations
|
| 226 |
+
|
| 227 |
+
Override in a subclass to manipulate the request or metadata
|
| 228 |
+
before they are sent to the Speech server.
|
| 229 |
+
"""
|
| 230 |
+
return request, metadata
|
| 231 |
+
|
| 232 |
+
def post_list_operations(
|
| 233 |
+
self, response: operations_pb2.ListOperationsResponse
|
| 234 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 235 |
+
"""Post-rpc interceptor for list_operations
|
| 236 |
+
|
| 237 |
+
Override in a subclass to manipulate the response
|
| 238 |
+
after it is returned by the Speech server but before
|
| 239 |
+
it is returned to user code.
|
| 240 |
+
"""
|
| 241 |
+
return response
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
@dataclasses.dataclass
|
| 245 |
+
class SpeechRestStub:
|
| 246 |
+
_session: AuthorizedSession
|
| 247 |
+
_host: str
|
| 248 |
+
_interceptor: SpeechRestInterceptor
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
class SpeechRestTransport(_BaseSpeechRestTransport):
|
| 252 |
+
"""REST backend synchronous transport for Speech.
|
| 253 |
+
|
| 254 |
+
Service that implements Google Cloud Speech API.
|
| 255 |
+
|
| 256 |
+
This class defines the same methods as the primary client, so the
|
| 257 |
+
primary client can load the underlying transport implementation
|
| 258 |
+
and call it.
|
| 259 |
+
|
| 260 |
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
| 261 |
+
"""
|
| 262 |
+
|
| 263 |
+
def __init__(
|
| 264 |
+
self,
|
| 265 |
+
*,
|
| 266 |
+
host: str = "speech.googleapis.com",
|
| 267 |
+
credentials: Optional[ga_credentials.Credentials] = None,
|
| 268 |
+
credentials_file: Optional[str] = None,
|
| 269 |
+
scopes: Optional[Sequence[str]] = None,
|
| 270 |
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
| 271 |
+
quota_project_id: Optional[str] = None,
|
| 272 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 273 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 274 |
+
url_scheme: str = "https",
|
| 275 |
+
interceptor: Optional[SpeechRestInterceptor] = None,
|
| 276 |
+
api_audience: Optional[str] = None,
|
| 277 |
+
) -> None:
|
| 278 |
+
"""Instantiate the transport.
|
| 279 |
+
|
| 280 |
+
Args:
|
| 281 |
+
host (Optional[str]):
|
| 282 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 283 |
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
| 284 |
+
authorization credentials to attach to requests. These
|
| 285 |
+
credentials identify the application to the service; if none
|
| 286 |
+
are specified, the client will attempt to ascertain the
|
| 287 |
+
credentials from the environment.
|
| 288 |
+
|
| 289 |
+
credentials_file (Optional[str]): Deprecated. A file with credentials that can
|
| 290 |
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
| 291 |
+
This argument is ignored if ``channel`` is provided. This argument will be
|
| 292 |
+
removed in the next major version of this library.
|
| 293 |
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
| 294 |
+
ignored if ``channel`` is provided.
|
| 295 |
+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
|
| 296 |
+
certificate to configure mutual TLS HTTP channel. It is ignored
|
| 297 |
+
if ``channel`` is provided.
|
| 298 |
+
quota_project_id (Optional[str]): An optional project to use for billing
|
| 299 |
+
and quota.
|
| 300 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 301 |
+
The client info used to send a user-agent string along with
|
| 302 |
+
API requests. If ``None``, then default info will be used.
|
| 303 |
+
Generally, you only need to set this if you are developing
|
| 304 |
+
your own client library.
|
| 305 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 306 |
+
be used for service account credentials.
|
| 307 |
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
| 308 |
+
"https", but for testing or local servers,
|
| 309 |
+
"http" can be specified.
|
| 310 |
+
interceptor (Optional[SpeechRestInterceptor]): Interceptor used
|
| 311 |
+
to manipulate requests, request metadata, and responses.
|
| 312 |
+
api_audience (Optional[str]): The intended audience for the API calls
|
| 313 |
+
to the service that will be set when using certain 3rd party
|
| 314 |
+
authentication flows. Audience is typically a resource identifier.
|
| 315 |
+
If not set, the host value will be used as a default.
|
| 316 |
+
"""
|
| 317 |
+
# Run the base constructor
|
| 318 |
+
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
|
| 319 |
+
# TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
|
| 320 |
+
# credentials object
|
| 321 |
+
super().__init__(
|
| 322 |
+
host=host,
|
| 323 |
+
credentials=credentials,
|
| 324 |
+
client_info=client_info,
|
| 325 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 326 |
+
url_scheme=url_scheme,
|
| 327 |
+
api_audience=api_audience,
|
| 328 |
+
)
|
| 329 |
+
self._session = AuthorizedSession(
|
| 330 |
+
self._credentials, default_host=self.DEFAULT_HOST
|
| 331 |
+
)
|
| 332 |
+
self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None
|
| 333 |
+
if client_cert_source_for_mtls:
|
| 334 |
+
self._session.configure_mtls_channel(client_cert_source_for_mtls)
|
| 335 |
+
self._interceptor = interceptor or SpeechRestInterceptor()
|
| 336 |
+
self._prep_wrapped_messages(client_info)
|
| 337 |
+
|
| 338 |
+
@property
|
| 339 |
+
def operations_client(self) -> operations_v1.AbstractOperationsClient:
|
| 340 |
+
"""Create the client designed to process long-running operations.
|
| 341 |
+
|
| 342 |
+
This property caches on the instance; repeated calls return the same
|
| 343 |
+
client.
|
| 344 |
+
"""
|
| 345 |
+
# Only create a new client if we do not already have one.
|
| 346 |
+
if self._operations_client is None:
|
| 347 |
+
http_options: Dict[str, List[Dict[str, str]]] = {
|
| 348 |
+
"google.longrunning.Operations.GetOperation": [
|
| 349 |
+
{
|
| 350 |
+
"method": "get",
|
| 351 |
+
"uri": "/v1p1beta1/operations/{name=**}",
|
| 352 |
+
},
|
| 353 |
+
],
|
| 354 |
+
"google.longrunning.Operations.ListOperations": [
|
| 355 |
+
{
|
| 356 |
+
"method": "get",
|
| 357 |
+
"uri": "/v1p1beta1/operations",
|
| 358 |
+
},
|
| 359 |
+
],
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
rest_transport = operations_v1.OperationsRestTransport(
|
| 363 |
+
host=self._host,
|
| 364 |
+
# use the credentials which are saved
|
| 365 |
+
credentials=self._credentials,
|
| 366 |
+
scopes=self._scopes,
|
| 367 |
+
http_options=http_options,
|
| 368 |
+
path_prefix="v1p1beta1",
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
self._operations_client = operations_v1.AbstractOperationsClient(
|
| 372 |
+
transport=rest_transport
|
| 373 |
+
)
|
| 374 |
+
|
| 375 |
+
# Return the client from cache.
|
| 376 |
+
return self._operations_client
|
| 377 |
+
|
| 378 |
+
class _LongRunningRecognize(
|
| 379 |
+
_BaseSpeechRestTransport._BaseLongRunningRecognize, SpeechRestStub
|
| 380 |
+
):
|
| 381 |
+
def __hash__(self):
|
| 382 |
+
return hash("SpeechRestTransport.LongRunningRecognize")
|
| 383 |
+
|
| 384 |
+
@staticmethod
|
| 385 |
+
def _get_response(
|
| 386 |
+
host,
|
| 387 |
+
metadata,
|
| 388 |
+
query_params,
|
| 389 |
+
session,
|
| 390 |
+
timeout,
|
| 391 |
+
transcoded_request,
|
| 392 |
+
body=None,
|
| 393 |
+
):
|
| 394 |
+
uri = transcoded_request["uri"]
|
| 395 |
+
method = transcoded_request["method"]
|
| 396 |
+
headers = dict(metadata)
|
| 397 |
+
headers["Content-Type"] = "application/json"
|
| 398 |
+
response = getattr(session, method)(
|
| 399 |
+
"{host}{uri}".format(host=host, uri=uri),
|
| 400 |
+
timeout=timeout,
|
| 401 |
+
headers=headers,
|
| 402 |
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
| 403 |
+
data=body,
|
| 404 |
+
)
|
| 405 |
+
return response
|
| 406 |
+
|
| 407 |
+
def __call__(
|
| 408 |
+
self,
|
| 409 |
+
request: cloud_speech.LongRunningRecognizeRequest,
|
| 410 |
+
*,
|
| 411 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 412 |
+
timeout: Optional[float] = None,
|
| 413 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 414 |
+
) -> operations_pb2.Operation:
|
| 415 |
+
r"""Call the long running recognize method over HTTP.
|
| 416 |
+
|
| 417 |
+
Args:
|
| 418 |
+
request (~.cloud_speech.LongRunningRecognizeRequest):
|
| 419 |
+
The request object. The top-level message sent by the client for the
|
| 420 |
+
``LongRunningRecognize`` method.
|
| 421 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 422 |
+
should be retried.
|
| 423 |
+
timeout (float): The timeout for this request.
|
| 424 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 425 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 426 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 427 |
+
be of type `bytes`.
|
| 428 |
+
|
| 429 |
+
Returns:
|
| 430 |
+
~.operations_pb2.Operation:
|
| 431 |
+
This resource represents a
|
| 432 |
+
long-running operation that is the
|
| 433 |
+
result of a network API call.
|
| 434 |
+
|
| 435 |
+
"""
|
| 436 |
+
|
| 437 |
+
http_options = (
|
| 438 |
+
_BaseSpeechRestTransport._BaseLongRunningRecognize._get_http_options()
|
| 439 |
+
)
|
| 440 |
+
|
| 441 |
+
request, metadata = self._interceptor.pre_long_running_recognize(
|
| 442 |
+
request, metadata
|
| 443 |
+
)
|
| 444 |
+
transcoded_request = _BaseSpeechRestTransport._BaseLongRunningRecognize._get_transcoded_request(
|
| 445 |
+
http_options, request
|
| 446 |
+
)
|
| 447 |
+
|
| 448 |
+
body = _BaseSpeechRestTransport._BaseLongRunningRecognize._get_request_body_json(
|
| 449 |
+
transcoded_request
|
| 450 |
+
)
|
| 451 |
+
|
| 452 |
+
# Jsonify the query params
|
| 453 |
+
query_params = _BaseSpeechRestTransport._BaseLongRunningRecognize._get_query_params_json(
|
| 454 |
+
transcoded_request
|
| 455 |
+
)
|
| 456 |
+
|
| 457 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 458 |
+
logging.DEBUG
|
| 459 |
+
): # pragma: NO COVER
|
| 460 |
+
request_url = "{host}{uri}".format(
|
| 461 |
+
host=self._host, uri=transcoded_request["uri"]
|
| 462 |
+
)
|
| 463 |
+
method = transcoded_request["method"]
|
| 464 |
+
try:
|
| 465 |
+
request_payload = type(request).to_json(request)
|
| 466 |
+
except:
|
| 467 |
+
request_payload = None
|
| 468 |
+
http_request = {
|
| 469 |
+
"payload": request_payload,
|
| 470 |
+
"requestMethod": method,
|
| 471 |
+
"requestUrl": request_url,
|
| 472 |
+
"headers": dict(metadata),
|
| 473 |
+
}
|
| 474 |
+
_LOGGER.debug(
|
| 475 |
+
f"Sending request for google.cloud.speech_v1p1beta1.SpeechClient.LongRunningRecognize",
|
| 476 |
+
extra={
|
| 477 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 478 |
+
"rpcName": "LongRunningRecognize",
|
| 479 |
+
"httpRequest": http_request,
|
| 480 |
+
"metadata": http_request["headers"],
|
| 481 |
+
},
|
| 482 |
+
)
|
| 483 |
+
|
| 484 |
+
# Send the request
|
| 485 |
+
response = SpeechRestTransport._LongRunningRecognize._get_response(
|
| 486 |
+
self._host,
|
| 487 |
+
metadata,
|
| 488 |
+
query_params,
|
| 489 |
+
self._session,
|
| 490 |
+
timeout,
|
| 491 |
+
transcoded_request,
|
| 492 |
+
body,
|
| 493 |
+
)
|
| 494 |
+
|
| 495 |
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
| 496 |
+
# subclass.
|
| 497 |
+
if response.status_code >= 400:
|
| 498 |
+
raise core_exceptions.from_http_response(response)
|
| 499 |
+
|
| 500 |
+
# Return the response
|
| 501 |
+
resp = operations_pb2.Operation()
|
| 502 |
+
json_format.Parse(response.content, resp, ignore_unknown_fields=True)
|
| 503 |
+
|
| 504 |
+
resp = self._interceptor.post_long_running_recognize(resp)
|
| 505 |
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
| 506 |
+
resp, _ = self._interceptor.post_long_running_recognize_with_metadata(
|
| 507 |
+
resp, response_metadata
|
| 508 |
+
)
|
| 509 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 510 |
+
logging.DEBUG
|
| 511 |
+
): # pragma: NO COVER
|
| 512 |
+
try:
|
| 513 |
+
response_payload = json_format.MessageToJson(resp)
|
| 514 |
+
except:
|
| 515 |
+
response_payload = None
|
| 516 |
+
http_response = {
|
| 517 |
+
"payload": response_payload,
|
| 518 |
+
"headers": dict(response.headers),
|
| 519 |
+
"status": response.status_code,
|
| 520 |
+
}
|
| 521 |
+
_LOGGER.debug(
|
| 522 |
+
"Received response for google.cloud.speech_v1p1beta1.SpeechClient.long_running_recognize",
|
| 523 |
+
extra={
|
| 524 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 525 |
+
"rpcName": "LongRunningRecognize",
|
| 526 |
+
"metadata": http_response["headers"],
|
| 527 |
+
"httpResponse": http_response,
|
| 528 |
+
},
|
| 529 |
+
)
|
| 530 |
+
return resp
|
| 531 |
+
|
| 532 |
+
class _Recognize(_BaseSpeechRestTransport._BaseRecognize, SpeechRestStub):
|
| 533 |
+
def __hash__(self):
|
| 534 |
+
return hash("SpeechRestTransport.Recognize")
|
| 535 |
+
|
| 536 |
+
@staticmethod
|
| 537 |
+
def _get_response(
|
| 538 |
+
host,
|
| 539 |
+
metadata,
|
| 540 |
+
query_params,
|
| 541 |
+
session,
|
| 542 |
+
timeout,
|
| 543 |
+
transcoded_request,
|
| 544 |
+
body=None,
|
| 545 |
+
):
|
| 546 |
+
uri = transcoded_request["uri"]
|
| 547 |
+
method = transcoded_request["method"]
|
| 548 |
+
headers = dict(metadata)
|
| 549 |
+
headers["Content-Type"] = "application/json"
|
| 550 |
+
response = getattr(session, method)(
|
| 551 |
+
"{host}{uri}".format(host=host, uri=uri),
|
| 552 |
+
timeout=timeout,
|
| 553 |
+
headers=headers,
|
| 554 |
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
| 555 |
+
data=body,
|
| 556 |
+
)
|
| 557 |
+
return response
|
| 558 |
+
|
| 559 |
+
def __call__(
|
| 560 |
+
self,
|
| 561 |
+
request: cloud_speech.RecognizeRequest,
|
| 562 |
+
*,
|
| 563 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 564 |
+
timeout: Optional[float] = None,
|
| 565 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 566 |
+
) -> cloud_speech.RecognizeResponse:
|
| 567 |
+
r"""Call the recognize method over HTTP.
|
| 568 |
+
|
| 569 |
+
Args:
|
| 570 |
+
request (~.cloud_speech.RecognizeRequest):
|
| 571 |
+
The request object. The top-level message sent by the client for the
|
| 572 |
+
``Recognize`` method.
|
| 573 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 574 |
+
should be retried.
|
| 575 |
+
timeout (float): The timeout for this request.
|
| 576 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 577 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 578 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 579 |
+
be of type `bytes`.
|
| 580 |
+
|
| 581 |
+
Returns:
|
| 582 |
+
~.cloud_speech.RecognizeResponse:
|
| 583 |
+
The only message returned to the client by the
|
| 584 |
+
``Recognize`` method. It contains the result as zero or
|
| 585 |
+
more sequential ``SpeechRecognitionResult`` messages.
|
| 586 |
+
|
| 587 |
+
"""
|
| 588 |
+
|
| 589 |
+
http_options = _BaseSpeechRestTransport._BaseRecognize._get_http_options()
|
| 590 |
+
|
| 591 |
+
request, metadata = self._interceptor.pre_recognize(request, metadata)
|
| 592 |
+
transcoded_request = (
|
| 593 |
+
_BaseSpeechRestTransport._BaseRecognize._get_transcoded_request(
|
| 594 |
+
http_options, request
|
| 595 |
+
)
|
| 596 |
+
)
|
| 597 |
+
|
| 598 |
+
body = _BaseSpeechRestTransport._BaseRecognize._get_request_body_json(
|
| 599 |
+
transcoded_request
|
| 600 |
+
)
|
| 601 |
+
|
| 602 |
+
# Jsonify the query params
|
| 603 |
+
query_params = (
|
| 604 |
+
_BaseSpeechRestTransport._BaseRecognize._get_query_params_json(
|
| 605 |
+
transcoded_request
|
| 606 |
+
)
|
| 607 |
+
)
|
| 608 |
+
|
| 609 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 610 |
+
logging.DEBUG
|
| 611 |
+
): # pragma: NO COVER
|
| 612 |
+
request_url = "{host}{uri}".format(
|
| 613 |
+
host=self._host, uri=transcoded_request["uri"]
|
| 614 |
+
)
|
| 615 |
+
method = transcoded_request["method"]
|
| 616 |
+
try:
|
| 617 |
+
request_payload = type(request).to_json(request)
|
| 618 |
+
except:
|
| 619 |
+
request_payload = None
|
| 620 |
+
http_request = {
|
| 621 |
+
"payload": request_payload,
|
| 622 |
+
"requestMethod": method,
|
| 623 |
+
"requestUrl": request_url,
|
| 624 |
+
"headers": dict(metadata),
|
| 625 |
+
}
|
| 626 |
+
_LOGGER.debug(
|
| 627 |
+
f"Sending request for google.cloud.speech_v1p1beta1.SpeechClient.Recognize",
|
| 628 |
+
extra={
|
| 629 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 630 |
+
"rpcName": "Recognize",
|
| 631 |
+
"httpRequest": http_request,
|
| 632 |
+
"metadata": http_request["headers"],
|
| 633 |
+
},
|
| 634 |
+
)
|
| 635 |
+
|
| 636 |
+
# Send the request
|
| 637 |
+
response = SpeechRestTransport._Recognize._get_response(
|
| 638 |
+
self._host,
|
| 639 |
+
metadata,
|
| 640 |
+
query_params,
|
| 641 |
+
self._session,
|
| 642 |
+
timeout,
|
| 643 |
+
transcoded_request,
|
| 644 |
+
body,
|
| 645 |
+
)
|
| 646 |
+
|
| 647 |
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
| 648 |
+
# subclass.
|
| 649 |
+
if response.status_code >= 400:
|
| 650 |
+
raise core_exceptions.from_http_response(response)
|
| 651 |
+
|
| 652 |
+
# Return the response
|
| 653 |
+
resp = cloud_speech.RecognizeResponse()
|
| 654 |
+
pb_resp = cloud_speech.RecognizeResponse.pb(resp)
|
| 655 |
+
|
| 656 |
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
| 657 |
+
|
| 658 |
+
resp = self._interceptor.post_recognize(resp)
|
| 659 |
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
| 660 |
+
resp, _ = self._interceptor.post_recognize_with_metadata(
|
| 661 |
+
resp, response_metadata
|
| 662 |
+
)
|
| 663 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 664 |
+
logging.DEBUG
|
| 665 |
+
): # pragma: NO COVER
|
| 666 |
+
try:
|
| 667 |
+
response_payload = cloud_speech.RecognizeResponse.to_json(response)
|
| 668 |
+
except:
|
| 669 |
+
response_payload = None
|
| 670 |
+
http_response = {
|
| 671 |
+
"payload": response_payload,
|
| 672 |
+
"headers": dict(response.headers),
|
| 673 |
+
"status": response.status_code,
|
| 674 |
+
}
|
| 675 |
+
_LOGGER.debug(
|
| 676 |
+
"Received response for google.cloud.speech_v1p1beta1.SpeechClient.recognize",
|
| 677 |
+
extra={
|
| 678 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 679 |
+
"rpcName": "Recognize",
|
| 680 |
+
"metadata": http_response["headers"],
|
| 681 |
+
"httpResponse": http_response,
|
| 682 |
+
},
|
| 683 |
+
)
|
| 684 |
+
return resp
|
| 685 |
+
|
| 686 |
+
class _StreamingRecognize(
|
| 687 |
+
_BaseSpeechRestTransport._BaseStreamingRecognize, SpeechRestStub
|
| 688 |
+
):
|
| 689 |
+
def __hash__(self):
|
| 690 |
+
return hash("SpeechRestTransport.StreamingRecognize")
|
| 691 |
+
|
| 692 |
+
def __call__(
|
| 693 |
+
self,
|
| 694 |
+
request: cloud_speech.StreamingRecognizeRequest,
|
| 695 |
+
*,
|
| 696 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 697 |
+
timeout: Optional[float] = None,
|
| 698 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 699 |
+
) -> rest_streaming.ResponseIterator:
|
| 700 |
+
raise NotImplementedError(
|
| 701 |
+
"Method StreamingRecognize is not available over REST transport"
|
| 702 |
+
)
|
| 703 |
+
|
| 704 |
+
@property
|
| 705 |
+
def long_running_recognize(
|
| 706 |
+
self,
|
| 707 |
+
) -> Callable[[cloud_speech.LongRunningRecognizeRequest], operations_pb2.Operation]:
|
| 708 |
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
| 709 |
+
# In C++ this would require a dynamic_cast
|
| 710 |
+
return self._LongRunningRecognize(self._session, self._host, self._interceptor) # type: ignore
|
| 711 |
+
|
| 712 |
+
@property
|
| 713 |
+
def recognize(
|
| 714 |
+
self,
|
| 715 |
+
) -> Callable[[cloud_speech.RecognizeRequest], cloud_speech.RecognizeResponse]:
|
| 716 |
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
| 717 |
+
# In C++ this would require a dynamic_cast
|
| 718 |
+
return self._Recognize(self._session, self._host, self._interceptor) # type: ignore
|
| 719 |
+
|
| 720 |
+
@property
|
| 721 |
+
def streaming_recognize(
|
| 722 |
+
self,
|
| 723 |
+
) -> Callable[
|
| 724 |
+
[cloud_speech.StreamingRecognizeRequest],
|
| 725 |
+
cloud_speech.StreamingRecognizeResponse,
|
| 726 |
+
]:
|
| 727 |
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
| 728 |
+
# In C++ this would require a dynamic_cast
|
| 729 |
+
return self._StreamingRecognize(self._session, self._host, self._interceptor) # type: ignore
|
| 730 |
+
|
| 731 |
+
@property
|
| 732 |
+
def get_operation(self):
|
| 733 |
+
return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore
|
| 734 |
+
|
| 735 |
+
class _GetOperation(_BaseSpeechRestTransport._BaseGetOperation, SpeechRestStub):
|
| 736 |
+
def __hash__(self):
|
| 737 |
+
return hash("SpeechRestTransport.GetOperation")
|
| 738 |
+
|
| 739 |
+
@staticmethod
|
| 740 |
+
def _get_response(
|
| 741 |
+
host,
|
| 742 |
+
metadata,
|
| 743 |
+
query_params,
|
| 744 |
+
session,
|
| 745 |
+
timeout,
|
| 746 |
+
transcoded_request,
|
| 747 |
+
body=None,
|
| 748 |
+
):
|
| 749 |
+
uri = transcoded_request["uri"]
|
| 750 |
+
method = transcoded_request["method"]
|
| 751 |
+
headers = dict(metadata)
|
| 752 |
+
headers["Content-Type"] = "application/json"
|
| 753 |
+
response = getattr(session, method)(
|
| 754 |
+
"{host}{uri}".format(host=host, uri=uri),
|
| 755 |
+
timeout=timeout,
|
| 756 |
+
headers=headers,
|
| 757 |
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
| 758 |
+
)
|
| 759 |
+
return response
|
| 760 |
+
|
| 761 |
+
def __call__(
|
| 762 |
+
self,
|
| 763 |
+
request: operations_pb2.GetOperationRequest,
|
| 764 |
+
*,
|
| 765 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 766 |
+
timeout: Optional[float] = None,
|
| 767 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 768 |
+
) -> operations_pb2.Operation:
|
| 769 |
+
r"""Call the get operation method over HTTP.
|
| 770 |
+
|
| 771 |
+
Args:
|
| 772 |
+
request (operations_pb2.GetOperationRequest):
|
| 773 |
+
The request object for GetOperation method.
|
| 774 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 775 |
+
should be retried.
|
| 776 |
+
timeout (float): The timeout for this request.
|
| 777 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 778 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 779 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 780 |
+
be of type `bytes`.
|
| 781 |
+
|
| 782 |
+
Returns:
|
| 783 |
+
operations_pb2.Operation: Response from GetOperation method.
|
| 784 |
+
"""
|
| 785 |
+
|
| 786 |
+
http_options = (
|
| 787 |
+
_BaseSpeechRestTransport._BaseGetOperation._get_http_options()
|
| 788 |
+
)
|
| 789 |
+
|
| 790 |
+
request, metadata = self._interceptor.pre_get_operation(request, metadata)
|
| 791 |
+
transcoded_request = (
|
| 792 |
+
_BaseSpeechRestTransport._BaseGetOperation._get_transcoded_request(
|
| 793 |
+
http_options, request
|
| 794 |
+
)
|
| 795 |
+
)
|
| 796 |
+
|
| 797 |
+
# Jsonify the query params
|
| 798 |
+
query_params = (
|
| 799 |
+
_BaseSpeechRestTransport._BaseGetOperation._get_query_params_json(
|
| 800 |
+
transcoded_request
|
| 801 |
+
)
|
| 802 |
+
)
|
| 803 |
+
|
| 804 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 805 |
+
logging.DEBUG
|
| 806 |
+
): # pragma: NO COVER
|
| 807 |
+
request_url = "{host}{uri}".format(
|
| 808 |
+
host=self._host, uri=transcoded_request["uri"]
|
| 809 |
+
)
|
| 810 |
+
method = transcoded_request["method"]
|
| 811 |
+
try:
|
| 812 |
+
request_payload = json_format.MessageToJson(request)
|
| 813 |
+
except:
|
| 814 |
+
request_payload = None
|
| 815 |
+
http_request = {
|
| 816 |
+
"payload": request_payload,
|
| 817 |
+
"requestMethod": method,
|
| 818 |
+
"requestUrl": request_url,
|
| 819 |
+
"headers": dict(metadata),
|
| 820 |
+
}
|
| 821 |
+
_LOGGER.debug(
|
| 822 |
+
f"Sending request for google.cloud.speech_v1p1beta1.SpeechClient.GetOperation",
|
| 823 |
+
extra={
|
| 824 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 825 |
+
"rpcName": "GetOperation",
|
| 826 |
+
"httpRequest": http_request,
|
| 827 |
+
"metadata": http_request["headers"],
|
| 828 |
+
},
|
| 829 |
+
)
|
| 830 |
+
|
| 831 |
+
# Send the request
|
| 832 |
+
response = SpeechRestTransport._GetOperation._get_response(
|
| 833 |
+
self._host,
|
| 834 |
+
metadata,
|
| 835 |
+
query_params,
|
| 836 |
+
self._session,
|
| 837 |
+
timeout,
|
| 838 |
+
transcoded_request,
|
| 839 |
+
)
|
| 840 |
+
|
| 841 |
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
| 842 |
+
# subclass.
|
| 843 |
+
if response.status_code >= 400:
|
| 844 |
+
raise core_exceptions.from_http_response(response)
|
| 845 |
+
|
| 846 |
+
content = response.content.decode("utf-8")
|
| 847 |
+
resp = operations_pb2.Operation()
|
| 848 |
+
resp = json_format.Parse(content, resp)
|
| 849 |
+
resp = self._interceptor.post_get_operation(resp)
|
| 850 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 851 |
+
logging.DEBUG
|
| 852 |
+
): # pragma: NO COVER
|
| 853 |
+
try:
|
| 854 |
+
response_payload = json_format.MessageToJson(resp)
|
| 855 |
+
except:
|
| 856 |
+
response_payload = None
|
| 857 |
+
http_response = {
|
| 858 |
+
"payload": response_payload,
|
| 859 |
+
"headers": dict(response.headers),
|
| 860 |
+
"status": response.status_code,
|
| 861 |
+
}
|
| 862 |
+
_LOGGER.debug(
|
| 863 |
+
"Received response for google.cloud.speech_v1p1beta1.SpeechAsyncClient.GetOperation",
|
| 864 |
+
extra={
|
| 865 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 866 |
+
"rpcName": "GetOperation",
|
| 867 |
+
"httpResponse": http_response,
|
| 868 |
+
"metadata": http_response["headers"],
|
| 869 |
+
},
|
| 870 |
+
)
|
| 871 |
+
return resp
|
| 872 |
+
|
| 873 |
+
@property
|
| 874 |
+
def list_operations(self):
|
| 875 |
+
return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore
|
| 876 |
+
|
| 877 |
+
class _ListOperations(_BaseSpeechRestTransport._BaseListOperations, SpeechRestStub):
|
| 878 |
+
def __hash__(self):
|
| 879 |
+
return hash("SpeechRestTransport.ListOperations")
|
| 880 |
+
|
| 881 |
+
@staticmethod
|
| 882 |
+
def _get_response(
|
| 883 |
+
host,
|
| 884 |
+
metadata,
|
| 885 |
+
query_params,
|
| 886 |
+
session,
|
| 887 |
+
timeout,
|
| 888 |
+
transcoded_request,
|
| 889 |
+
body=None,
|
| 890 |
+
):
|
| 891 |
+
uri = transcoded_request["uri"]
|
| 892 |
+
method = transcoded_request["method"]
|
| 893 |
+
headers = dict(metadata)
|
| 894 |
+
headers["Content-Type"] = "application/json"
|
| 895 |
+
response = getattr(session, method)(
|
| 896 |
+
"{host}{uri}".format(host=host, uri=uri),
|
| 897 |
+
timeout=timeout,
|
| 898 |
+
headers=headers,
|
| 899 |
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
| 900 |
+
)
|
| 901 |
+
return response
|
| 902 |
+
|
| 903 |
+
def __call__(
|
| 904 |
+
self,
|
| 905 |
+
request: operations_pb2.ListOperationsRequest,
|
| 906 |
+
*,
|
| 907 |
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
| 908 |
+
timeout: Optional[float] = None,
|
| 909 |
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
| 910 |
+
) -> operations_pb2.ListOperationsResponse:
|
| 911 |
+
r"""Call the list operations method over HTTP.
|
| 912 |
+
|
| 913 |
+
Args:
|
| 914 |
+
request (operations_pb2.ListOperationsRequest):
|
| 915 |
+
The request object for ListOperations method.
|
| 916 |
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
| 917 |
+
should be retried.
|
| 918 |
+
timeout (float): The timeout for this request.
|
| 919 |
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
| 920 |
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
| 921 |
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
| 922 |
+
be of type `bytes`.
|
| 923 |
+
|
| 924 |
+
Returns:
|
| 925 |
+
operations_pb2.ListOperationsResponse: Response from ListOperations method.
|
| 926 |
+
"""
|
| 927 |
+
|
| 928 |
+
http_options = (
|
| 929 |
+
_BaseSpeechRestTransport._BaseListOperations._get_http_options()
|
| 930 |
+
)
|
| 931 |
+
|
| 932 |
+
request, metadata = self._interceptor.pre_list_operations(request, metadata)
|
| 933 |
+
transcoded_request = (
|
| 934 |
+
_BaseSpeechRestTransport._BaseListOperations._get_transcoded_request(
|
| 935 |
+
http_options, request
|
| 936 |
+
)
|
| 937 |
+
)
|
| 938 |
+
|
| 939 |
+
# Jsonify the query params
|
| 940 |
+
query_params = (
|
| 941 |
+
_BaseSpeechRestTransport._BaseListOperations._get_query_params_json(
|
| 942 |
+
transcoded_request
|
| 943 |
+
)
|
| 944 |
+
)
|
| 945 |
+
|
| 946 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 947 |
+
logging.DEBUG
|
| 948 |
+
): # pragma: NO COVER
|
| 949 |
+
request_url = "{host}{uri}".format(
|
| 950 |
+
host=self._host, uri=transcoded_request["uri"]
|
| 951 |
+
)
|
| 952 |
+
method = transcoded_request["method"]
|
| 953 |
+
try:
|
| 954 |
+
request_payload = json_format.MessageToJson(request)
|
| 955 |
+
except:
|
| 956 |
+
request_payload = None
|
| 957 |
+
http_request = {
|
| 958 |
+
"payload": request_payload,
|
| 959 |
+
"requestMethod": method,
|
| 960 |
+
"requestUrl": request_url,
|
| 961 |
+
"headers": dict(metadata),
|
| 962 |
+
}
|
| 963 |
+
_LOGGER.debug(
|
| 964 |
+
f"Sending request for google.cloud.speech_v1p1beta1.SpeechClient.ListOperations",
|
| 965 |
+
extra={
|
| 966 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 967 |
+
"rpcName": "ListOperations",
|
| 968 |
+
"httpRequest": http_request,
|
| 969 |
+
"metadata": http_request["headers"],
|
| 970 |
+
},
|
| 971 |
+
)
|
| 972 |
+
|
| 973 |
+
# Send the request
|
| 974 |
+
response = SpeechRestTransport._ListOperations._get_response(
|
| 975 |
+
self._host,
|
| 976 |
+
metadata,
|
| 977 |
+
query_params,
|
| 978 |
+
self._session,
|
| 979 |
+
timeout,
|
| 980 |
+
transcoded_request,
|
| 981 |
+
)
|
| 982 |
+
|
| 983 |
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
| 984 |
+
# subclass.
|
| 985 |
+
if response.status_code >= 400:
|
| 986 |
+
raise core_exceptions.from_http_response(response)
|
| 987 |
+
|
| 988 |
+
content = response.content.decode("utf-8")
|
| 989 |
+
resp = operations_pb2.ListOperationsResponse()
|
| 990 |
+
resp = json_format.Parse(content, resp)
|
| 991 |
+
resp = self._interceptor.post_list_operations(resp)
|
| 992 |
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
| 993 |
+
logging.DEBUG
|
| 994 |
+
): # pragma: NO COVER
|
| 995 |
+
try:
|
| 996 |
+
response_payload = json_format.MessageToJson(resp)
|
| 997 |
+
except:
|
| 998 |
+
response_payload = None
|
| 999 |
+
http_response = {
|
| 1000 |
+
"payload": response_payload,
|
| 1001 |
+
"headers": dict(response.headers),
|
| 1002 |
+
"status": response.status_code,
|
| 1003 |
+
}
|
| 1004 |
+
_LOGGER.debug(
|
| 1005 |
+
"Received response for google.cloud.speech_v1p1beta1.SpeechAsyncClient.ListOperations",
|
| 1006 |
+
extra={
|
| 1007 |
+
"serviceName": "google.cloud.speech.v1p1beta1.Speech",
|
| 1008 |
+
"rpcName": "ListOperations",
|
| 1009 |
+
"httpResponse": http_response,
|
| 1010 |
+
"metadata": http_response["headers"],
|
| 1011 |
+
},
|
| 1012 |
+
)
|
| 1013 |
+
return resp
|
| 1014 |
+
|
| 1015 |
+
@property
|
| 1016 |
+
def kind(self) -> str:
|
| 1017 |
+
return "rest"
|
| 1018 |
+
|
| 1019 |
+
def close(self):
|
| 1020 |
+
self._session.close()
|
| 1021 |
+
|
| 1022 |
+
|
| 1023 |
+
__all__ = ("SpeechRestTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/services/speech/transports/rest_base.py
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import json # type: ignore
|
| 17 |
+
import re
|
| 18 |
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
| 19 |
+
|
| 20 |
+
from google.api_core import gapic_v1, path_template
|
| 21 |
+
from google.longrunning import operations_pb2 # type: ignore
|
| 22 |
+
from google.protobuf import json_format
|
| 23 |
+
|
| 24 |
+
from google.cloud.speech_v1p1beta1.types import cloud_speech
|
| 25 |
+
|
| 26 |
+
from .base import DEFAULT_CLIENT_INFO, SpeechTransport
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class _BaseSpeechRestTransport(SpeechTransport):
|
| 30 |
+
"""Base REST backend transport for Speech.
|
| 31 |
+
|
| 32 |
+
Note: This class is not meant to be used directly. Use its sync and
|
| 33 |
+
async sub-classes instead.
|
| 34 |
+
|
| 35 |
+
This class defines the same methods as the primary client, so the
|
| 36 |
+
primary client can load the underlying transport implementation
|
| 37 |
+
and call it.
|
| 38 |
+
|
| 39 |
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
def __init__(
|
| 43 |
+
self,
|
| 44 |
+
*,
|
| 45 |
+
host: str = "speech.googleapis.com",
|
| 46 |
+
credentials: Optional[Any] = None,
|
| 47 |
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
| 48 |
+
always_use_jwt_access: Optional[bool] = False,
|
| 49 |
+
url_scheme: str = "https",
|
| 50 |
+
api_audience: Optional[str] = None,
|
| 51 |
+
) -> None:
|
| 52 |
+
"""Instantiate the transport.
|
| 53 |
+
Args:
|
| 54 |
+
host (Optional[str]):
|
| 55 |
+
The hostname to connect to (default: 'speech.googleapis.com').
|
| 56 |
+
credentials (Optional[Any]): The
|
| 57 |
+
authorization credentials to attach to requests. These
|
| 58 |
+
credentials identify the application to the service; if none
|
| 59 |
+
are specified, the client will attempt to ascertain the
|
| 60 |
+
credentials from the environment.
|
| 61 |
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
| 62 |
+
The client info used to send a user-agent string along with
|
| 63 |
+
API requests. If ``None``, then default info will be used.
|
| 64 |
+
Generally, you only need to set this if you are developing
|
| 65 |
+
your own client library.
|
| 66 |
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
| 67 |
+
be used for service account credentials.
|
| 68 |
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
| 69 |
+
"https", but for testing or local servers,
|
| 70 |
+
"http" can be specified.
|
| 71 |
+
"""
|
| 72 |
+
# Run the base constructor
|
| 73 |
+
maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
|
| 74 |
+
if maybe_url_match is None:
|
| 75 |
+
raise ValueError(
|
| 76 |
+
f"Unexpected hostname structure: {host}"
|
| 77 |
+
) # pragma: NO COVER
|
| 78 |
+
|
| 79 |
+
url_match_items = maybe_url_match.groupdict()
|
| 80 |
+
|
| 81 |
+
host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host
|
| 82 |
+
|
| 83 |
+
super().__init__(
|
| 84 |
+
host=host,
|
| 85 |
+
credentials=credentials,
|
| 86 |
+
client_info=client_info,
|
| 87 |
+
always_use_jwt_access=always_use_jwt_access,
|
| 88 |
+
api_audience=api_audience,
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
class _BaseLongRunningRecognize:
|
| 92 |
+
def __hash__(self): # pragma: NO COVER
|
| 93 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 94 |
+
|
| 95 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 96 |
+
|
| 97 |
+
@classmethod
|
| 98 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 99 |
+
return {
|
| 100 |
+
k: v
|
| 101 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 102 |
+
if k not in message_dict
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
@staticmethod
|
| 106 |
+
def _get_http_options():
|
| 107 |
+
http_options: List[Dict[str, str]] = [
|
| 108 |
+
{
|
| 109 |
+
"method": "post",
|
| 110 |
+
"uri": "/v1p1beta1/speech:longrunningrecognize",
|
| 111 |
+
"body": "*",
|
| 112 |
+
},
|
| 113 |
+
]
|
| 114 |
+
return http_options
|
| 115 |
+
|
| 116 |
+
@staticmethod
|
| 117 |
+
def _get_transcoded_request(http_options, request):
|
| 118 |
+
pb_request = cloud_speech.LongRunningRecognizeRequest.pb(request)
|
| 119 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 120 |
+
return transcoded_request
|
| 121 |
+
|
| 122 |
+
@staticmethod
|
| 123 |
+
def _get_request_body_json(transcoded_request):
|
| 124 |
+
# Jsonify the request body
|
| 125 |
+
|
| 126 |
+
body = json_format.MessageToJson(
|
| 127 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 128 |
+
)
|
| 129 |
+
return body
|
| 130 |
+
|
| 131 |
+
@staticmethod
|
| 132 |
+
def _get_query_params_json(transcoded_request):
|
| 133 |
+
query_params = json.loads(
|
| 134 |
+
json_format.MessageToJson(
|
| 135 |
+
transcoded_request["query_params"],
|
| 136 |
+
use_integers_for_enums=True,
|
| 137 |
+
)
|
| 138 |
+
)
|
| 139 |
+
query_params.update(
|
| 140 |
+
_BaseSpeechRestTransport._BaseLongRunningRecognize._get_unset_required_fields(
|
| 141 |
+
query_params
|
| 142 |
+
)
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 146 |
+
return query_params
|
| 147 |
+
|
| 148 |
+
class _BaseRecognize:
|
| 149 |
+
def __hash__(self): # pragma: NO COVER
|
| 150 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 151 |
+
|
| 152 |
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
| 153 |
+
|
| 154 |
+
@classmethod
|
| 155 |
+
def _get_unset_required_fields(cls, message_dict):
|
| 156 |
+
return {
|
| 157 |
+
k: v
|
| 158 |
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
| 159 |
+
if k not in message_dict
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
@staticmethod
|
| 163 |
+
def _get_http_options():
|
| 164 |
+
http_options: List[Dict[str, str]] = [
|
| 165 |
+
{
|
| 166 |
+
"method": "post",
|
| 167 |
+
"uri": "/v1p1beta1/speech:recognize",
|
| 168 |
+
"body": "*",
|
| 169 |
+
},
|
| 170 |
+
]
|
| 171 |
+
return http_options
|
| 172 |
+
|
| 173 |
+
@staticmethod
|
| 174 |
+
def _get_transcoded_request(http_options, request):
|
| 175 |
+
pb_request = cloud_speech.RecognizeRequest.pb(request)
|
| 176 |
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
| 177 |
+
return transcoded_request
|
| 178 |
+
|
| 179 |
+
@staticmethod
|
| 180 |
+
def _get_request_body_json(transcoded_request):
|
| 181 |
+
# Jsonify the request body
|
| 182 |
+
|
| 183 |
+
body = json_format.MessageToJson(
|
| 184 |
+
transcoded_request["body"], use_integers_for_enums=True
|
| 185 |
+
)
|
| 186 |
+
return body
|
| 187 |
+
|
| 188 |
+
@staticmethod
|
| 189 |
+
def _get_query_params_json(transcoded_request):
|
| 190 |
+
query_params = json.loads(
|
| 191 |
+
json_format.MessageToJson(
|
| 192 |
+
transcoded_request["query_params"],
|
| 193 |
+
use_integers_for_enums=True,
|
| 194 |
+
)
|
| 195 |
+
)
|
| 196 |
+
query_params.update(
|
| 197 |
+
_BaseSpeechRestTransport._BaseRecognize._get_unset_required_fields(
|
| 198 |
+
query_params
|
| 199 |
+
)
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
query_params["$alt"] = "json;enum-encoding=int"
|
| 203 |
+
return query_params
|
| 204 |
+
|
| 205 |
+
class _BaseStreamingRecognize:
|
| 206 |
+
def __hash__(self): # pragma: NO COVER
|
| 207 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 208 |
+
|
| 209 |
+
class _BaseGetOperation:
|
| 210 |
+
def __hash__(self): # pragma: NO COVER
|
| 211 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 212 |
+
|
| 213 |
+
@staticmethod
|
| 214 |
+
def _get_http_options():
|
| 215 |
+
http_options: List[Dict[str, str]] = [
|
| 216 |
+
{
|
| 217 |
+
"method": "get",
|
| 218 |
+
"uri": "/v1p1beta1/operations/{name=**}",
|
| 219 |
+
},
|
| 220 |
+
]
|
| 221 |
+
return http_options
|
| 222 |
+
|
| 223 |
+
@staticmethod
|
| 224 |
+
def _get_transcoded_request(http_options, request):
|
| 225 |
+
request_kwargs = json_format.MessageToDict(request)
|
| 226 |
+
transcoded_request = path_template.transcode(http_options, **request_kwargs)
|
| 227 |
+
return transcoded_request
|
| 228 |
+
|
| 229 |
+
@staticmethod
|
| 230 |
+
def _get_query_params_json(transcoded_request):
|
| 231 |
+
query_params = json.loads(json.dumps(transcoded_request["query_params"]))
|
| 232 |
+
return query_params
|
| 233 |
+
|
| 234 |
+
class _BaseListOperations:
|
| 235 |
+
def __hash__(self): # pragma: NO COVER
|
| 236 |
+
return NotImplementedError("__hash__ must be implemented.")
|
| 237 |
+
|
| 238 |
+
@staticmethod
|
| 239 |
+
def _get_http_options():
|
| 240 |
+
http_options: List[Dict[str, str]] = [
|
| 241 |
+
{
|
| 242 |
+
"method": "get",
|
| 243 |
+
"uri": "/v1p1beta1/operations",
|
| 244 |
+
},
|
| 245 |
+
]
|
| 246 |
+
return http_options
|
| 247 |
+
|
| 248 |
+
@staticmethod
|
| 249 |
+
def _get_transcoded_request(http_options, request):
|
| 250 |
+
request_kwargs = json_format.MessageToDict(request)
|
| 251 |
+
transcoded_request = path_template.transcode(http_options, **request_kwargs)
|
| 252 |
+
return transcoded_request
|
| 253 |
+
|
| 254 |
+
@staticmethod
|
| 255 |
+
def _get_query_params_json(transcoded_request):
|
| 256 |
+
query_params = json.loads(json.dumps(transcoded_request["query_params"]))
|
| 257 |
+
return query_params
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
__all__ = ("_BaseSpeechRestTransport",)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/types/__init__.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from .cloud_speech import (
|
| 17 |
+
LongRunningRecognizeMetadata,
|
| 18 |
+
LongRunningRecognizeRequest,
|
| 19 |
+
LongRunningRecognizeResponse,
|
| 20 |
+
RecognitionAudio,
|
| 21 |
+
RecognitionConfig,
|
| 22 |
+
RecognitionMetadata,
|
| 23 |
+
RecognizeRequest,
|
| 24 |
+
RecognizeResponse,
|
| 25 |
+
SpeakerDiarizationConfig,
|
| 26 |
+
SpeechAdaptationInfo,
|
| 27 |
+
SpeechContext,
|
| 28 |
+
SpeechRecognitionAlternative,
|
| 29 |
+
SpeechRecognitionResult,
|
| 30 |
+
StreamingRecognitionConfig,
|
| 31 |
+
StreamingRecognitionResult,
|
| 32 |
+
StreamingRecognizeRequest,
|
| 33 |
+
StreamingRecognizeResponse,
|
| 34 |
+
TranscriptOutputConfig,
|
| 35 |
+
WordInfo,
|
| 36 |
+
)
|
| 37 |
+
from .cloud_speech_adaptation import (
|
| 38 |
+
CreateCustomClassRequest,
|
| 39 |
+
CreatePhraseSetRequest,
|
| 40 |
+
DeleteCustomClassRequest,
|
| 41 |
+
DeletePhraseSetRequest,
|
| 42 |
+
GetCustomClassRequest,
|
| 43 |
+
GetPhraseSetRequest,
|
| 44 |
+
ListCustomClassesRequest,
|
| 45 |
+
ListCustomClassesResponse,
|
| 46 |
+
ListPhraseSetRequest,
|
| 47 |
+
ListPhraseSetResponse,
|
| 48 |
+
UpdateCustomClassRequest,
|
| 49 |
+
UpdatePhraseSetRequest,
|
| 50 |
+
)
|
| 51 |
+
from .resource import (
|
| 52 |
+
CustomClass,
|
| 53 |
+
PhraseSet,
|
| 54 |
+
SpeechAdaptation,
|
| 55 |
+
TranscriptNormalization,
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
__all__ = (
|
| 59 |
+
"LongRunningRecognizeMetadata",
|
| 60 |
+
"LongRunningRecognizeRequest",
|
| 61 |
+
"LongRunningRecognizeResponse",
|
| 62 |
+
"RecognitionAudio",
|
| 63 |
+
"RecognitionConfig",
|
| 64 |
+
"RecognitionMetadata",
|
| 65 |
+
"RecognizeRequest",
|
| 66 |
+
"RecognizeResponse",
|
| 67 |
+
"SpeakerDiarizationConfig",
|
| 68 |
+
"SpeechAdaptationInfo",
|
| 69 |
+
"SpeechContext",
|
| 70 |
+
"SpeechRecognitionAlternative",
|
| 71 |
+
"SpeechRecognitionResult",
|
| 72 |
+
"StreamingRecognitionConfig",
|
| 73 |
+
"StreamingRecognitionResult",
|
| 74 |
+
"StreamingRecognizeRequest",
|
| 75 |
+
"StreamingRecognizeResponse",
|
| 76 |
+
"TranscriptOutputConfig",
|
| 77 |
+
"WordInfo",
|
| 78 |
+
"CreateCustomClassRequest",
|
| 79 |
+
"CreatePhraseSetRequest",
|
| 80 |
+
"DeleteCustomClassRequest",
|
| 81 |
+
"DeletePhraseSetRequest",
|
| 82 |
+
"GetCustomClassRequest",
|
| 83 |
+
"GetPhraseSetRequest",
|
| 84 |
+
"ListCustomClassesRequest",
|
| 85 |
+
"ListCustomClassesResponse",
|
| 86 |
+
"ListPhraseSetRequest",
|
| 87 |
+
"ListPhraseSetResponse",
|
| 88 |
+
"UpdateCustomClassRequest",
|
| 89 |
+
"UpdatePhraseSetRequest",
|
| 90 |
+
"CustomClass",
|
| 91 |
+
"PhraseSet",
|
| 92 |
+
"SpeechAdaptation",
|
| 93 |
+
"TranscriptNormalization",
|
| 94 |
+
)
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/types/cloud_speech.py
ADDED
|
@@ -0,0 +1,1609 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
from typing import MutableMapping, MutableSequence
|
| 19 |
+
|
| 20 |
+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
|
| 21 |
+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
|
| 22 |
+
import google.protobuf.wrappers_pb2 as wrappers_pb2 # type: ignore
|
| 23 |
+
import google.rpc.status_pb2 as status_pb2 # type: ignore
|
| 24 |
+
import proto # type: ignore
|
| 25 |
+
|
| 26 |
+
from google.cloud.speech_v1p1beta1.types import resource
|
| 27 |
+
|
| 28 |
+
__protobuf__ = proto.module(
|
| 29 |
+
package="google.cloud.speech.v1p1beta1",
|
| 30 |
+
manifest={
|
| 31 |
+
"RecognizeRequest",
|
| 32 |
+
"LongRunningRecognizeRequest",
|
| 33 |
+
"TranscriptOutputConfig",
|
| 34 |
+
"StreamingRecognizeRequest",
|
| 35 |
+
"StreamingRecognitionConfig",
|
| 36 |
+
"RecognitionConfig",
|
| 37 |
+
"SpeakerDiarizationConfig",
|
| 38 |
+
"RecognitionMetadata",
|
| 39 |
+
"SpeechContext",
|
| 40 |
+
"RecognitionAudio",
|
| 41 |
+
"RecognizeResponse",
|
| 42 |
+
"LongRunningRecognizeResponse",
|
| 43 |
+
"LongRunningRecognizeMetadata",
|
| 44 |
+
"StreamingRecognizeResponse",
|
| 45 |
+
"StreamingRecognitionResult",
|
| 46 |
+
"SpeechRecognitionResult",
|
| 47 |
+
"SpeechRecognitionAlternative",
|
| 48 |
+
"WordInfo",
|
| 49 |
+
"SpeechAdaptationInfo",
|
| 50 |
+
},
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class RecognizeRequest(proto.Message):
|
| 55 |
+
r"""The top-level message sent by the client for the ``Recognize``
|
| 56 |
+
method.
|
| 57 |
+
|
| 58 |
+
Attributes:
|
| 59 |
+
config (google.cloud.speech_v1p1beta1.types.RecognitionConfig):
|
| 60 |
+
Required. Provides information to the
|
| 61 |
+
recognizer that specifies how to process the
|
| 62 |
+
request.
|
| 63 |
+
audio (google.cloud.speech_v1p1beta1.types.RecognitionAudio):
|
| 64 |
+
Required. The audio data to be recognized.
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
config: "RecognitionConfig" = proto.Field(
|
| 68 |
+
proto.MESSAGE,
|
| 69 |
+
number=1,
|
| 70 |
+
message="RecognitionConfig",
|
| 71 |
+
)
|
| 72 |
+
audio: "RecognitionAudio" = proto.Field(
|
| 73 |
+
proto.MESSAGE,
|
| 74 |
+
number=2,
|
| 75 |
+
message="RecognitionAudio",
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class LongRunningRecognizeRequest(proto.Message):
|
| 80 |
+
r"""The top-level message sent by the client for the
|
| 81 |
+
``LongRunningRecognize`` method.
|
| 82 |
+
|
| 83 |
+
Attributes:
|
| 84 |
+
config (google.cloud.speech_v1p1beta1.types.RecognitionConfig):
|
| 85 |
+
Required. Provides information to the
|
| 86 |
+
recognizer that specifies how to process the
|
| 87 |
+
request.
|
| 88 |
+
audio (google.cloud.speech_v1p1beta1.types.RecognitionAudio):
|
| 89 |
+
Required. The audio data to be recognized.
|
| 90 |
+
output_config (google.cloud.speech_v1p1beta1.types.TranscriptOutputConfig):
|
| 91 |
+
Optional. Specifies an optional destination
|
| 92 |
+
for the recognition results.
|
| 93 |
+
"""
|
| 94 |
+
|
| 95 |
+
config: "RecognitionConfig" = proto.Field(
|
| 96 |
+
proto.MESSAGE,
|
| 97 |
+
number=1,
|
| 98 |
+
message="RecognitionConfig",
|
| 99 |
+
)
|
| 100 |
+
audio: "RecognitionAudio" = proto.Field(
|
| 101 |
+
proto.MESSAGE,
|
| 102 |
+
number=2,
|
| 103 |
+
message="RecognitionAudio",
|
| 104 |
+
)
|
| 105 |
+
output_config: "TranscriptOutputConfig" = proto.Field(
|
| 106 |
+
proto.MESSAGE,
|
| 107 |
+
number=4,
|
| 108 |
+
message="TranscriptOutputConfig",
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class TranscriptOutputConfig(proto.Message):
|
| 113 |
+
r"""Specifies an optional destination for the recognition
|
| 114 |
+
results.
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
| 118 |
+
|
| 119 |
+
Attributes:
|
| 120 |
+
gcs_uri (str):
|
| 121 |
+
Specifies a Cloud Storage URI for the recognition results.
|
| 122 |
+
Must be specified in the format:
|
| 123 |
+
``gs://bucket_name/object_name``, and the bucket must
|
| 124 |
+
already exist.
|
| 125 |
+
|
| 126 |
+
This field is a member of `oneof`_ ``output_type``.
|
| 127 |
+
"""
|
| 128 |
+
|
| 129 |
+
gcs_uri: str = proto.Field(
|
| 130 |
+
proto.STRING,
|
| 131 |
+
number=1,
|
| 132 |
+
oneof="output_type",
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
class StreamingRecognizeRequest(proto.Message):
|
| 137 |
+
r"""The top-level message sent by the client for the
|
| 138 |
+
``StreamingRecognize`` method. Multiple
|
| 139 |
+
``StreamingRecognizeRequest`` messages are sent. The first message
|
| 140 |
+
must contain a ``streaming_config`` message and must not contain
|
| 141 |
+
``audio_content``. All subsequent messages must contain
|
| 142 |
+
``audio_content`` and must not contain a ``streaming_config``
|
| 143 |
+
message.
|
| 144 |
+
|
| 145 |
+
This message has `oneof`_ fields (mutually exclusive fields).
|
| 146 |
+
For each oneof, at most one member field can be set at the same time.
|
| 147 |
+
Setting any member of the oneof automatically clears all other
|
| 148 |
+
members.
|
| 149 |
+
|
| 150 |
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
| 151 |
+
|
| 152 |
+
Attributes:
|
| 153 |
+
streaming_config (google.cloud.speech_v1p1beta1.types.StreamingRecognitionConfig):
|
| 154 |
+
Provides information to the recognizer that specifies how to
|
| 155 |
+
process the request. The first ``StreamingRecognizeRequest``
|
| 156 |
+
message must contain a ``streaming_config`` message.
|
| 157 |
+
|
| 158 |
+
This field is a member of `oneof`_ ``streaming_request``.
|
| 159 |
+
audio_content (bytes):
|
| 160 |
+
The audio data to be recognized. Sequential chunks of audio
|
| 161 |
+
data are sent in sequential ``StreamingRecognizeRequest``
|
| 162 |
+
messages. The first ``StreamingRecognizeRequest`` message
|
| 163 |
+
must not contain ``audio_content`` data and all subsequent
|
| 164 |
+
``StreamingRecognizeRequest`` messages must contain
|
| 165 |
+
``audio_content`` data. The audio bytes must be encoded as
|
| 166 |
+
specified in ``RecognitionConfig``. Note: as with all bytes
|
| 167 |
+
fields, proto buffers use a pure binary representation (not
|
| 168 |
+
base64). See `content
|
| 169 |
+
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
|
| 170 |
+
|
| 171 |
+
This field is a member of `oneof`_ ``streaming_request``.
|
| 172 |
+
"""
|
| 173 |
+
|
| 174 |
+
streaming_config: "StreamingRecognitionConfig" = proto.Field(
|
| 175 |
+
proto.MESSAGE,
|
| 176 |
+
number=1,
|
| 177 |
+
oneof="streaming_request",
|
| 178 |
+
message="StreamingRecognitionConfig",
|
| 179 |
+
)
|
| 180 |
+
audio_content: bytes = proto.Field(
|
| 181 |
+
proto.BYTES,
|
| 182 |
+
number=2,
|
| 183 |
+
oneof="streaming_request",
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
class StreamingRecognitionConfig(proto.Message):
|
| 188 |
+
r"""Provides information to the recognizer that specifies how to
|
| 189 |
+
process the request.
|
| 190 |
+
|
| 191 |
+
Attributes:
|
| 192 |
+
config (google.cloud.speech_v1p1beta1.types.RecognitionConfig):
|
| 193 |
+
Required. Provides information to the
|
| 194 |
+
recognizer that specifies how to process the
|
| 195 |
+
request.
|
| 196 |
+
single_utterance (bool):
|
| 197 |
+
If ``false`` or omitted, the recognizer will perform
|
| 198 |
+
continuous recognition (continuing to wait for and process
|
| 199 |
+
audio even if the user pauses speaking) until the client
|
| 200 |
+
closes the input stream (gRPC API) or until the maximum time
|
| 201 |
+
limit has been reached. May return multiple
|
| 202 |
+
``StreamingRecognitionResult``\ s with the ``is_final`` flag
|
| 203 |
+
set to ``true``.
|
| 204 |
+
|
| 205 |
+
If ``true``, the recognizer will detect a single spoken
|
| 206 |
+
utterance. When it detects that the user has paused or
|
| 207 |
+
stopped speaking, it will return an
|
| 208 |
+
``END_OF_SINGLE_UTTERANCE`` event and cease recognition. It
|
| 209 |
+
will return no more than one ``StreamingRecognitionResult``
|
| 210 |
+
with the ``is_final`` flag set to ``true``.
|
| 211 |
+
|
| 212 |
+
The ``single_utterance`` field can only be used with
|
| 213 |
+
specified models, otherwise an error is thrown. The
|
| 214 |
+
``model`` field in
|
| 215 |
+
[RecognitionConfig][google.cloud.speech.v1p1beta1.RecognitionConfig]
|
| 216 |
+
must be set to:
|
| 217 |
+
|
| 218 |
+
- ``command_and_search``
|
| 219 |
+
- ``phone_call`` AND additional field
|
| 220 |
+
``useEnhanced``\ =\ ``true``
|
| 221 |
+
- The ``model`` field is left undefined. In this case the
|
| 222 |
+
API auto-selects a model based on any other parameters
|
| 223 |
+
that you set in ``RecognitionConfig``.
|
| 224 |
+
interim_results (bool):
|
| 225 |
+
If ``true``, interim results (tentative hypotheses) may be
|
| 226 |
+
returned as they become available (these interim results are
|
| 227 |
+
indicated with the ``is_final=false`` flag). If ``false`` or
|
| 228 |
+
omitted, only ``is_final=true`` result(s) are returned.
|
| 229 |
+
enable_voice_activity_events (bool):
|
| 230 |
+
If ``true``, responses with voice activity speech events
|
| 231 |
+
will be returned as they are detected.
|
| 232 |
+
voice_activity_timeout (google.cloud.speech_v1p1beta1.types.StreamingRecognitionConfig.VoiceActivityTimeout):
|
| 233 |
+
If set, the server will automatically close the stream after
|
| 234 |
+
the specified duration has elapsed after the last
|
| 235 |
+
VOICE_ACTIVITY speech event has been sent. The field
|
| 236 |
+
``voice_activity_events`` must also be set to true.
|
| 237 |
+
"""
|
| 238 |
+
|
| 239 |
+
class VoiceActivityTimeout(proto.Message):
|
| 240 |
+
r"""Events that a timeout can be set on for voice activity.
|
| 241 |
+
|
| 242 |
+
Attributes:
|
| 243 |
+
speech_start_timeout (google.protobuf.duration_pb2.Duration):
|
| 244 |
+
Duration to timeout the stream if no speech
|
| 245 |
+
begins.
|
| 246 |
+
speech_end_timeout (google.protobuf.duration_pb2.Duration):
|
| 247 |
+
Duration to timeout the stream after speech
|
| 248 |
+
ends.
|
| 249 |
+
"""
|
| 250 |
+
|
| 251 |
+
speech_start_timeout: duration_pb2.Duration = proto.Field(
|
| 252 |
+
proto.MESSAGE,
|
| 253 |
+
number=1,
|
| 254 |
+
message=duration_pb2.Duration,
|
| 255 |
+
)
|
| 256 |
+
speech_end_timeout: duration_pb2.Duration = proto.Field(
|
| 257 |
+
proto.MESSAGE,
|
| 258 |
+
number=2,
|
| 259 |
+
message=duration_pb2.Duration,
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
+
config: "RecognitionConfig" = proto.Field(
|
| 263 |
+
proto.MESSAGE,
|
| 264 |
+
number=1,
|
| 265 |
+
message="RecognitionConfig",
|
| 266 |
+
)
|
| 267 |
+
single_utterance: bool = proto.Field(
|
| 268 |
+
proto.BOOL,
|
| 269 |
+
number=2,
|
| 270 |
+
)
|
| 271 |
+
interim_results: bool = proto.Field(
|
| 272 |
+
proto.BOOL,
|
| 273 |
+
number=3,
|
| 274 |
+
)
|
| 275 |
+
enable_voice_activity_events: bool = proto.Field(
|
| 276 |
+
proto.BOOL,
|
| 277 |
+
number=5,
|
| 278 |
+
)
|
| 279 |
+
voice_activity_timeout: VoiceActivityTimeout = proto.Field(
|
| 280 |
+
proto.MESSAGE,
|
| 281 |
+
number=6,
|
| 282 |
+
message=VoiceActivityTimeout,
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
class RecognitionConfig(proto.Message):
|
| 287 |
+
r"""Provides information to the recognizer that specifies how to
|
| 288 |
+
process the request.
|
| 289 |
+
|
| 290 |
+
Attributes:
|
| 291 |
+
encoding (google.cloud.speech_v1p1beta1.types.RecognitionConfig.AudioEncoding):
|
| 292 |
+
Encoding of audio data sent in all ``RecognitionAudio``
|
| 293 |
+
messages. This field is optional for ``FLAC`` and ``WAV``
|
| 294 |
+
audio files and required for all other audio formats. For
|
| 295 |
+
details, see
|
| 296 |
+
[AudioEncoding][google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding].
|
| 297 |
+
sample_rate_hertz (int):
|
| 298 |
+
Sample rate in Hertz of the audio data sent in all
|
| 299 |
+
``RecognitionAudio`` messages. Valid values are: 8000-48000.
|
| 300 |
+
16000 is optimal. For best results, set the sampling rate of
|
| 301 |
+
the audio source to 16000 Hz. If that's not possible, use
|
| 302 |
+
the native sample rate of the audio source (instead of
|
| 303 |
+
re-sampling). This field is optional for FLAC and WAV audio
|
| 304 |
+
files, but is required for all other audio formats. For
|
| 305 |
+
details, see
|
| 306 |
+
[AudioEncoding][google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding].
|
| 307 |
+
audio_channel_count (int):
|
| 308 |
+
The number of channels in the input audio data. ONLY set
|
| 309 |
+
this for MULTI-CHANNEL recognition. Valid values for
|
| 310 |
+
LINEAR16, OGG_OPUS and FLAC are ``1``-``8``. Valid value for
|
| 311 |
+
MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only ``1``.
|
| 312 |
+
If ``0`` or omitted, defaults to one channel (mono). Note:
|
| 313 |
+
We only recognize the first channel by default. To perform
|
| 314 |
+
independent recognition on each channel set
|
| 315 |
+
``enable_separate_recognition_per_channel`` to 'true'.
|
| 316 |
+
enable_separate_recognition_per_channel (bool):
|
| 317 |
+
This needs to be set to ``true`` explicitly and
|
| 318 |
+
``audio_channel_count`` > 1 to get each channel recognized
|
| 319 |
+
separately. The recognition result will contain a
|
| 320 |
+
``channel_tag`` field to state which channel that result
|
| 321 |
+
belongs to. If this is not true, we will only recognize the
|
| 322 |
+
first channel. The request is billed cumulatively for all
|
| 323 |
+
channels recognized: ``audio_channel_count`` multiplied by
|
| 324 |
+
the length of the audio.
|
| 325 |
+
language_code (str):
|
| 326 |
+
Required. The language of the supplied audio as a
|
| 327 |
+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
|
| 328 |
+
language tag. Example: "en-US". See `Language
|
| 329 |
+
Support <https://cloud.google.com/speech-to-text/docs/languages>`__
|
| 330 |
+
for a list of the currently supported language codes.
|
| 331 |
+
alternative_language_codes (MutableSequence[str]):
|
| 332 |
+
A list of up to 3 additional
|
| 333 |
+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
|
| 334 |
+
language tags, listing possible alternative languages of the
|
| 335 |
+
supplied audio. See `Language
|
| 336 |
+
Support <https://cloud.google.com/speech-to-text/docs/languages>`__
|
| 337 |
+
for a list of the currently supported language codes. If
|
| 338 |
+
alternative languages are listed, recognition result will
|
| 339 |
+
contain recognition in the most likely language detected
|
| 340 |
+
including the main language_code. The recognition result
|
| 341 |
+
will include the language tag of the language detected in
|
| 342 |
+
the audio. Note: This feature is only supported for Voice
|
| 343 |
+
Command and Voice Search use cases and performance may vary
|
| 344 |
+
for other use cases (e.g., phone call transcription).
|
| 345 |
+
max_alternatives (int):
|
| 346 |
+
Maximum number of recognition hypotheses to be returned.
|
| 347 |
+
Specifically, the maximum number of
|
| 348 |
+
``SpeechRecognitionAlternative`` messages within each
|
| 349 |
+
``SpeechRecognitionResult``. The server may return fewer
|
| 350 |
+
than ``max_alternatives``. Valid values are ``0``-``30``. A
|
| 351 |
+
value of ``0`` or ``1`` will return a maximum of one. If
|
| 352 |
+
omitted, will return a maximum of one.
|
| 353 |
+
profanity_filter (bool):
|
| 354 |
+
If set to ``true``, the server will attempt to filter out
|
| 355 |
+
profanities, replacing all but the initial character in each
|
| 356 |
+
filtered word with asterisks, e.g. "f**\*". If set to
|
| 357 |
+
``false`` or omitted, profanities won't be filtered out.
|
| 358 |
+
adaptation (google.cloud.speech_v1p1beta1.types.SpeechAdaptation):
|
| 359 |
+
Speech adaptation configuration improves the accuracy of
|
| 360 |
+
speech recognition. For more information, see the `speech
|
| 361 |
+
adaptation <https://cloud.google.com/speech-to-text/docs/adaptation>`__
|
| 362 |
+
documentation. When speech adaptation is set it supersedes
|
| 363 |
+
the ``speech_contexts`` field.
|
| 364 |
+
transcript_normalization (google.cloud.speech_v1p1beta1.types.TranscriptNormalization):
|
| 365 |
+
Optional. Use transcription normalization to
|
| 366 |
+
automatically replace parts of the transcript
|
| 367 |
+
with phrases of your choosing. For
|
| 368 |
+
StreamingRecognize, this normalization only
|
| 369 |
+
applies to stable partial transcripts (stability
|
| 370 |
+
> 0.8) and final transcripts.
|
| 371 |
+
speech_contexts (MutableSequence[google.cloud.speech_v1p1beta1.types.SpeechContext]):
|
| 372 |
+
Array of
|
| 373 |
+
[SpeechContext][google.cloud.speech.v1p1beta1.SpeechContext].
|
| 374 |
+
A means to provide context to assist the speech recognition.
|
| 375 |
+
For more information, see `speech
|
| 376 |
+
adaptation <https://cloud.google.com/speech-to-text/docs/adaptation>`__.
|
| 377 |
+
enable_word_time_offsets (bool):
|
| 378 |
+
If ``true``, the top result includes a list of words and the
|
| 379 |
+
start and end time offsets (timestamps) for those words. If
|
| 380 |
+
``false``, no word-level time offset information is
|
| 381 |
+
returned. The default is ``false``.
|
| 382 |
+
enable_word_confidence (bool):
|
| 383 |
+
If ``true``, the top result includes a list of words and the
|
| 384 |
+
confidence for those words. If ``false``, no word-level
|
| 385 |
+
confidence information is returned. The default is
|
| 386 |
+
``false``.
|
| 387 |
+
enable_automatic_punctuation (bool):
|
| 388 |
+
If 'true', adds punctuation to recognition
|
| 389 |
+
result hypotheses. This feature is only
|
| 390 |
+
available in select languages. Setting this for
|
| 391 |
+
requests in other languages has no effect at
|
| 392 |
+
all. The default 'false' value does not add
|
| 393 |
+
punctuation to result hypotheses.
|
| 394 |
+
enable_spoken_punctuation (google.protobuf.wrappers_pb2.BoolValue):
|
| 395 |
+
The spoken punctuation behavior for the call If not set,
|
| 396 |
+
uses default behavior based on model of choice e.g.
|
| 397 |
+
command_and_search will enable spoken punctuation by default
|
| 398 |
+
If 'true', replaces spoken punctuation with the
|
| 399 |
+
corresponding symbols in the request. For example, "how are
|
| 400 |
+
you question mark" becomes "how are you?". See
|
| 401 |
+
https://cloud.google.com/speech-to-text/docs/spoken-punctuation
|
| 402 |
+
for support. If 'false', spoken punctuation is not replaced.
|
| 403 |
+
enable_spoken_emojis (google.protobuf.wrappers_pb2.BoolValue):
|
| 404 |
+
The spoken emoji behavior for the call
|
| 405 |
+
If not set, uses default behavior based on model
|
| 406 |
+
of choice If 'true', adds spoken emoji
|
| 407 |
+
formatting for the request. This will replace
|
| 408 |
+
spoken emojis with the corresponding Unicode
|
| 409 |
+
symbols in the final transcript. If 'false',
|
| 410 |
+
spoken emojis are not replaced.
|
| 411 |
+
enable_speaker_diarization (bool):
|
| 412 |
+
If 'true', enables speaker detection for each recognized
|
| 413 |
+
word in the top alternative of the recognition result using
|
| 414 |
+
a speaker_label provided in the WordInfo. Note: Use
|
| 415 |
+
diarization_config instead.
|
| 416 |
+
diarization_speaker_count (int):
|
| 417 |
+
If set, specifies the estimated number of speakers in the
|
| 418 |
+
conversation. Defaults to '2'. Ignored unless
|
| 419 |
+
enable_speaker_diarization is set to true. Note: Use
|
| 420 |
+
diarization_config instead.
|
| 421 |
+
diarization_config (google.cloud.speech_v1p1beta1.types.SpeakerDiarizationConfig):
|
| 422 |
+
Config to enable speaker diarization and set
|
| 423 |
+
additional parameters to make diarization better
|
| 424 |
+
suited for your application. Note: When this is
|
| 425 |
+
enabled, we send all the words from the
|
| 426 |
+
beginning of the audio for the top alternative
|
| 427 |
+
in every consecutive STREAMING responses. This
|
| 428 |
+
is done in order to improve our speaker tags as
|
| 429 |
+
our models learn to identify the speakers in the
|
| 430 |
+
conversation over time. For non-streaming
|
| 431 |
+
requests, the diarization results will be
|
| 432 |
+
provided only in the top alternative of the
|
| 433 |
+
FINAL SpeechRecognitionResult.
|
| 434 |
+
metadata (google.cloud.speech_v1p1beta1.types.RecognitionMetadata):
|
| 435 |
+
Metadata regarding this request.
|
| 436 |
+
model (str):
|
| 437 |
+
Which model to select for the given request. Select the
|
| 438 |
+
model best suited to your domain to get best results. If a
|
| 439 |
+
model is not explicitly specified, then we auto-select a
|
| 440 |
+
model based on the parameters in the RecognitionConfig.
|
| 441 |
+
|
| 442 |
+
.. raw:: html
|
| 443 |
+
|
| 444 |
+
<table>
|
| 445 |
+
<tr>
|
| 446 |
+
<td><b>Model</b></td>
|
| 447 |
+
<td><b>Description</b></td>
|
| 448 |
+
</tr>
|
| 449 |
+
<tr>
|
| 450 |
+
<td><code>latest_long</code></td>
|
| 451 |
+
<td>Best for long form content like media or conversation.</td>
|
| 452 |
+
</tr>
|
| 453 |
+
<tr>
|
| 454 |
+
<td><code>latest_short</code></td>
|
| 455 |
+
<td>Best for short form content like commands or single shot directed
|
| 456 |
+
speech.</td>
|
| 457 |
+
</tr>
|
| 458 |
+
<tr>
|
| 459 |
+
<td><code>command_and_search</code></td>
|
| 460 |
+
<td>Best for short queries such as voice commands or voice search.</td>
|
| 461 |
+
</tr>
|
| 462 |
+
<tr>
|
| 463 |
+
<td><code>phone_call</code></td>
|
| 464 |
+
<td>Best for audio that originated from a phone call (typically
|
| 465 |
+
recorded at an 8khz sampling rate).</td>
|
| 466 |
+
</tr>
|
| 467 |
+
<tr>
|
| 468 |
+
<td><code>video</code></td>
|
| 469 |
+
<td>Best for audio that originated from video or includes multiple
|
| 470 |
+
speakers. Ideally the audio is recorded at a 16khz or greater
|
| 471 |
+
sampling rate. This is a premium model that costs more than the
|
| 472 |
+
standard rate.</td>
|
| 473 |
+
</tr>
|
| 474 |
+
<tr>
|
| 475 |
+
<td><code>default</code></td>
|
| 476 |
+
<td>Best for audio that is not one of the specific audio models.
|
| 477 |
+
For example, long-form audio. Ideally the audio is high-fidelity,
|
| 478 |
+
recorded at a 16khz or greater sampling rate.</td>
|
| 479 |
+
</tr>
|
| 480 |
+
<tr>
|
| 481 |
+
<td><code>medical_conversation</code></td>
|
| 482 |
+
<td>Best for audio that originated from a conversation between a
|
| 483 |
+
medical provider and patient.</td>
|
| 484 |
+
</tr>
|
| 485 |
+
<tr>
|
| 486 |
+
<td><code>medical_dictation</code></td>
|
| 487 |
+
<td>Best for audio that originated from dictation notes by a medical
|
| 488 |
+
provider.</td>
|
| 489 |
+
</tr>
|
| 490 |
+
</table>
|
| 491 |
+
use_enhanced (bool):
|
| 492 |
+
Set to true to use an enhanced model for speech recognition.
|
| 493 |
+
If ``use_enhanced`` is set to true and the ``model`` field
|
| 494 |
+
is not set, then an appropriate enhanced model is chosen if
|
| 495 |
+
an enhanced model exists for the audio.
|
| 496 |
+
|
| 497 |
+
If ``use_enhanced`` is true and an enhanced version of the
|
| 498 |
+
specified model does not exist, then the speech is
|
| 499 |
+
recognized using the standard version of the specified
|
| 500 |
+
model.
|
| 501 |
+
"""
|
| 502 |
+
|
| 503 |
+
class AudioEncoding(proto.Enum):
|
| 504 |
+
r"""The encoding of the audio data sent in the request.
|
| 505 |
+
|
| 506 |
+
All encodings support only 1 channel (mono) audio, unless the
|
| 507 |
+
``audio_channel_count`` and
|
| 508 |
+
``enable_separate_recognition_per_channel`` fields are set.
|
| 509 |
+
|
| 510 |
+
For best results, the audio source should be captured and
|
| 511 |
+
transmitted using a lossless encoding (``FLAC`` or ``LINEAR16``).
|
| 512 |
+
The accuracy of the speech recognition can be reduced if lossy
|
| 513 |
+
codecs are used to capture or transmit audio, particularly if
|
| 514 |
+
background noise is present. Lossy codecs include ``MULAW``,
|
| 515 |
+
``AMR``, ``AMR_WB``, ``OGG_OPUS``, ``SPEEX_WITH_HEADER_BYTE``,
|
| 516 |
+
``MP3``, and ``WEBM_OPUS``.
|
| 517 |
+
|
| 518 |
+
The ``FLAC`` and ``WAV`` audio file formats include a header that
|
| 519 |
+
describes the included audio content. You can request recognition
|
| 520 |
+
for ``WAV`` files that contain either ``LINEAR16`` or ``MULAW``
|
| 521 |
+
encoded audio. If you send ``FLAC`` or ``WAV`` audio file format in
|
| 522 |
+
your request, you do not need to specify an ``AudioEncoding``; the
|
| 523 |
+
audio encoding format is determined from the file header. If you
|
| 524 |
+
specify an ``AudioEncoding`` when you send send ``FLAC`` or ``WAV``
|
| 525 |
+
audio, the encoding configuration must match the encoding described
|
| 526 |
+
in the audio header; otherwise the request returns an
|
| 527 |
+
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]
|
| 528 |
+
error code.
|
| 529 |
+
|
| 530 |
+
Values:
|
| 531 |
+
ENCODING_UNSPECIFIED (0):
|
| 532 |
+
Not specified.
|
| 533 |
+
LINEAR16 (1):
|
| 534 |
+
Uncompressed 16-bit signed little-endian
|
| 535 |
+
samples (Linear PCM).
|
| 536 |
+
FLAC (2):
|
| 537 |
+
``FLAC`` (Free Lossless Audio Codec) is the recommended
|
| 538 |
+
encoding because it is lossless--therefore recognition is
|
| 539 |
+
not compromised--and requires only about half the bandwidth
|
| 540 |
+
of ``LINEAR16``. ``FLAC`` stream encoding supports 16-bit
|
| 541 |
+
and 24-bit samples, however, not all fields in
|
| 542 |
+
``STREAMINFO`` are supported.
|
| 543 |
+
MULAW (3):
|
| 544 |
+
8-bit samples that compand 14-bit audio
|
| 545 |
+
samples using G.711 PCMU/mu-law.
|
| 546 |
+
AMR (4):
|
| 547 |
+
Adaptive Multi-Rate Narrowband codec. ``sample_rate_hertz``
|
| 548 |
+
must be 8000.
|
| 549 |
+
AMR_WB (5):
|
| 550 |
+
Adaptive Multi-Rate Wideband codec. ``sample_rate_hertz``
|
| 551 |
+
must be 16000.
|
| 552 |
+
OGG_OPUS (6):
|
| 553 |
+
Opus encoded audio frames in Ogg container
|
| 554 |
+
(`OggOpus <https://wiki.xiph.org/OggOpus>`__).
|
| 555 |
+
``sample_rate_hertz`` must be one of 8000, 12000, 16000,
|
| 556 |
+
24000, or 48000.
|
| 557 |
+
SPEEX_WITH_HEADER_BYTE (7):
|
| 558 |
+
Although the use of lossy encodings is not recommended, if a
|
| 559 |
+
very low bitrate encoding is required, ``OGG_OPUS`` is
|
| 560 |
+
highly preferred over Speex encoding. The
|
| 561 |
+
`Speex <https://speex.org/>`__ encoding supported by Cloud
|
| 562 |
+
Speech API has a header byte in each block, as in MIME type
|
| 563 |
+
``audio/x-speex-with-header-byte``. It is a variant of the
|
| 564 |
+
RTP Speex encoding defined in `RFC
|
| 565 |
+
5574 <https://tools.ietf.org/html/rfc5574>`__. The stream is
|
| 566 |
+
a sequence of blocks, one block per RTP packet. Each block
|
| 567 |
+
starts with a byte containing the length of the block, in
|
| 568 |
+
bytes, followed by one or more frames of Speex data, padded
|
| 569 |
+
to an integral number of bytes (octets) as specified in RFC
|
| 570 |
+
5574. In other words, each RTP header is replaced with a
|
| 571 |
+
single byte containing the block length. Only Speex wideband
|
| 572 |
+
is supported. ``sample_rate_hertz`` must be 16000.
|
| 573 |
+
MP3 (8):
|
| 574 |
+
MP3 audio. MP3 encoding is a Beta feature and only available
|
| 575 |
+
in v1p1beta1. Support all standard MP3 bitrates (which range
|
| 576 |
+
from 32-320 kbps). When using this encoding,
|
| 577 |
+
``sample_rate_hertz`` has to match the sample rate of the
|
| 578 |
+
file being used.
|
| 579 |
+
WEBM_OPUS (9):
|
| 580 |
+
Opus encoded audio frames in WebM container
|
| 581 |
+
(`WebM <https://www.webmproject.org/docs/container/>`__).
|
| 582 |
+
``sample_rate_hertz`` must be one of 8000, 12000, 16000,
|
| 583 |
+
24000, or 48000.
|
| 584 |
+
ALAW (10):
|
| 585 |
+
8-bit samples that compand 13-bit audio
|
| 586 |
+
samples using G.711 PCMU/a-law.
|
| 587 |
+
"""
|
| 588 |
+
|
| 589 |
+
ENCODING_UNSPECIFIED = 0
|
| 590 |
+
LINEAR16 = 1
|
| 591 |
+
FLAC = 2
|
| 592 |
+
MULAW = 3
|
| 593 |
+
AMR = 4
|
| 594 |
+
AMR_WB = 5
|
| 595 |
+
OGG_OPUS = 6
|
| 596 |
+
SPEEX_WITH_HEADER_BYTE = 7
|
| 597 |
+
MP3 = 8
|
| 598 |
+
WEBM_OPUS = 9
|
| 599 |
+
ALAW = 10
|
| 600 |
+
|
| 601 |
+
encoding: AudioEncoding = proto.Field(
|
| 602 |
+
proto.ENUM,
|
| 603 |
+
number=1,
|
| 604 |
+
enum=AudioEncoding,
|
| 605 |
+
)
|
| 606 |
+
sample_rate_hertz: int = proto.Field(
|
| 607 |
+
proto.INT32,
|
| 608 |
+
number=2,
|
| 609 |
+
)
|
| 610 |
+
audio_channel_count: int = proto.Field(
|
| 611 |
+
proto.INT32,
|
| 612 |
+
number=7,
|
| 613 |
+
)
|
| 614 |
+
enable_separate_recognition_per_channel: bool = proto.Field(
|
| 615 |
+
proto.BOOL,
|
| 616 |
+
number=12,
|
| 617 |
+
)
|
| 618 |
+
language_code: str = proto.Field(
|
| 619 |
+
proto.STRING,
|
| 620 |
+
number=3,
|
| 621 |
+
)
|
| 622 |
+
alternative_language_codes: MutableSequence[str] = proto.RepeatedField(
|
| 623 |
+
proto.STRING,
|
| 624 |
+
number=18,
|
| 625 |
+
)
|
| 626 |
+
max_alternatives: int = proto.Field(
|
| 627 |
+
proto.INT32,
|
| 628 |
+
number=4,
|
| 629 |
+
)
|
| 630 |
+
profanity_filter: bool = proto.Field(
|
| 631 |
+
proto.BOOL,
|
| 632 |
+
number=5,
|
| 633 |
+
)
|
| 634 |
+
adaptation: resource.SpeechAdaptation = proto.Field(
|
| 635 |
+
proto.MESSAGE,
|
| 636 |
+
number=20,
|
| 637 |
+
message=resource.SpeechAdaptation,
|
| 638 |
+
)
|
| 639 |
+
transcript_normalization: resource.TranscriptNormalization = proto.Field(
|
| 640 |
+
proto.MESSAGE,
|
| 641 |
+
number=24,
|
| 642 |
+
message=resource.TranscriptNormalization,
|
| 643 |
+
)
|
| 644 |
+
speech_contexts: MutableSequence["SpeechContext"] = proto.RepeatedField(
|
| 645 |
+
proto.MESSAGE,
|
| 646 |
+
number=6,
|
| 647 |
+
message="SpeechContext",
|
| 648 |
+
)
|
| 649 |
+
enable_word_time_offsets: bool = proto.Field(
|
| 650 |
+
proto.BOOL,
|
| 651 |
+
number=8,
|
| 652 |
+
)
|
| 653 |
+
enable_word_confidence: bool = proto.Field(
|
| 654 |
+
proto.BOOL,
|
| 655 |
+
number=15,
|
| 656 |
+
)
|
| 657 |
+
enable_automatic_punctuation: bool = proto.Field(
|
| 658 |
+
proto.BOOL,
|
| 659 |
+
number=11,
|
| 660 |
+
)
|
| 661 |
+
enable_spoken_punctuation: wrappers_pb2.BoolValue = proto.Field(
|
| 662 |
+
proto.MESSAGE,
|
| 663 |
+
number=22,
|
| 664 |
+
message=wrappers_pb2.BoolValue,
|
| 665 |
+
)
|
| 666 |
+
enable_spoken_emojis: wrappers_pb2.BoolValue = proto.Field(
|
| 667 |
+
proto.MESSAGE,
|
| 668 |
+
number=23,
|
| 669 |
+
message=wrappers_pb2.BoolValue,
|
| 670 |
+
)
|
| 671 |
+
enable_speaker_diarization: bool = proto.Field(
|
| 672 |
+
proto.BOOL,
|
| 673 |
+
number=16,
|
| 674 |
+
)
|
| 675 |
+
diarization_speaker_count: int = proto.Field(
|
| 676 |
+
proto.INT32,
|
| 677 |
+
number=17,
|
| 678 |
+
)
|
| 679 |
+
diarization_config: "SpeakerDiarizationConfig" = proto.Field(
|
| 680 |
+
proto.MESSAGE,
|
| 681 |
+
number=19,
|
| 682 |
+
message="SpeakerDiarizationConfig",
|
| 683 |
+
)
|
| 684 |
+
metadata: "RecognitionMetadata" = proto.Field(
|
| 685 |
+
proto.MESSAGE,
|
| 686 |
+
number=9,
|
| 687 |
+
message="RecognitionMetadata",
|
| 688 |
+
)
|
| 689 |
+
model: str = proto.Field(
|
| 690 |
+
proto.STRING,
|
| 691 |
+
number=13,
|
| 692 |
+
)
|
| 693 |
+
use_enhanced: bool = proto.Field(
|
| 694 |
+
proto.BOOL,
|
| 695 |
+
number=14,
|
| 696 |
+
)
|
| 697 |
+
|
| 698 |
+
|
| 699 |
+
class SpeakerDiarizationConfig(proto.Message):
|
| 700 |
+
r"""Config to enable speaker diarization.
|
| 701 |
+
|
| 702 |
+
Attributes:
|
| 703 |
+
enable_speaker_diarization (bool):
|
| 704 |
+
If 'true', enables speaker detection for each recognized
|
| 705 |
+
word in the top alternative of the recognition result using
|
| 706 |
+
a speaker_label provided in the WordInfo.
|
| 707 |
+
min_speaker_count (int):
|
| 708 |
+
Minimum number of speakers in the
|
| 709 |
+
conversation. This range gives you more
|
| 710 |
+
flexibility by allowing the system to
|
| 711 |
+
automatically determine the correct number of
|
| 712 |
+
speakers. If not set, the default value is 2.
|
| 713 |
+
max_speaker_count (int):
|
| 714 |
+
Maximum number of speakers in the
|
| 715 |
+
conversation. This range gives you more
|
| 716 |
+
flexibility by allowing the system to
|
| 717 |
+
automatically determine the correct number of
|
| 718 |
+
speakers. If not set, the default value is 6.
|
| 719 |
+
speaker_tag (int):
|
| 720 |
+
Output only. Unused.
|
| 721 |
+
"""
|
| 722 |
+
|
| 723 |
+
enable_speaker_diarization: bool = proto.Field(
|
| 724 |
+
proto.BOOL,
|
| 725 |
+
number=1,
|
| 726 |
+
)
|
| 727 |
+
min_speaker_count: int = proto.Field(
|
| 728 |
+
proto.INT32,
|
| 729 |
+
number=2,
|
| 730 |
+
)
|
| 731 |
+
max_speaker_count: int = proto.Field(
|
| 732 |
+
proto.INT32,
|
| 733 |
+
number=3,
|
| 734 |
+
)
|
| 735 |
+
speaker_tag: int = proto.Field(
|
| 736 |
+
proto.INT32,
|
| 737 |
+
number=5,
|
| 738 |
+
)
|
| 739 |
+
|
| 740 |
+
|
| 741 |
+
class RecognitionMetadata(proto.Message):
|
| 742 |
+
r"""Description of audio data to be recognized.
|
| 743 |
+
|
| 744 |
+
Attributes:
|
| 745 |
+
interaction_type (google.cloud.speech_v1p1beta1.types.RecognitionMetadata.InteractionType):
|
| 746 |
+
The use case most closely describing the
|
| 747 |
+
audio content to be recognized.
|
| 748 |
+
industry_naics_code_of_audio (int):
|
| 749 |
+
The industry vertical to which this speech
|
| 750 |
+
recognition request most closely applies. This
|
| 751 |
+
is most indicative of the topics contained in
|
| 752 |
+
the audio. Use the 6-digit NAICS code to
|
| 753 |
+
identify the industry vertical - see
|
| 754 |
+
https://www.naics.com/search/.
|
| 755 |
+
microphone_distance (google.cloud.speech_v1p1beta1.types.RecognitionMetadata.MicrophoneDistance):
|
| 756 |
+
The audio type that most closely describes
|
| 757 |
+
the audio being recognized.
|
| 758 |
+
original_media_type (google.cloud.speech_v1p1beta1.types.RecognitionMetadata.OriginalMediaType):
|
| 759 |
+
The original media the speech was recorded
|
| 760 |
+
on.
|
| 761 |
+
recording_device_type (google.cloud.speech_v1p1beta1.types.RecognitionMetadata.RecordingDeviceType):
|
| 762 |
+
The type of device the speech was recorded
|
| 763 |
+
with.
|
| 764 |
+
recording_device_name (str):
|
| 765 |
+
The device used to make the recording.
|
| 766 |
+
Examples 'Nexus 5X' or 'Polycom SoundStation IP
|
| 767 |
+
6000' or 'POTS' or 'VoIP' or 'Cardioid
|
| 768 |
+
Microphone'.
|
| 769 |
+
original_mime_type (str):
|
| 770 |
+
Mime type of the original audio file. For example
|
| 771 |
+
``audio/m4a``, ``audio/x-alaw-basic``, ``audio/mp3``,
|
| 772 |
+
``audio/3gpp``. A list of possible audio mime types is
|
| 773 |
+
maintained at
|
| 774 |
+
http://www.iana.org/assignments/media-types/media-types.xhtml#audio
|
| 775 |
+
obfuscated_id (int):
|
| 776 |
+
Obfuscated (privacy-protected) ID of the
|
| 777 |
+
user, to identify number of unique users using
|
| 778 |
+
the service.
|
| 779 |
+
audio_topic (str):
|
| 780 |
+
Description of the content. Eg. "Recordings
|
| 781 |
+
of federal supreme court hearings from 2012".
|
| 782 |
+
"""
|
| 783 |
+
|
| 784 |
+
class InteractionType(proto.Enum):
|
| 785 |
+
r"""Use case categories that the audio recognition request can be
|
| 786 |
+
described by.
|
| 787 |
+
|
| 788 |
+
Values:
|
| 789 |
+
INTERACTION_TYPE_UNSPECIFIED (0):
|
| 790 |
+
Use case is either unknown or is something
|
| 791 |
+
other than one of the other values below.
|
| 792 |
+
DISCUSSION (1):
|
| 793 |
+
Multiple people in a conversation or discussion. For example
|
| 794 |
+
in a meeting with two or more people actively participating.
|
| 795 |
+
Typically all the primary people speaking would be in the
|
| 796 |
+
same room (if not, see PHONE_CALL)
|
| 797 |
+
PRESENTATION (2):
|
| 798 |
+
One or more persons lecturing or presenting
|
| 799 |
+
to others, mostly uninterrupted.
|
| 800 |
+
PHONE_CALL (3):
|
| 801 |
+
A phone-call or video-conference in which two
|
| 802 |
+
or more people, who are not in the same room,
|
| 803 |
+
are actively participating.
|
| 804 |
+
VOICEMAIL (4):
|
| 805 |
+
A recorded message intended for another
|
| 806 |
+
person to listen to.
|
| 807 |
+
PROFESSIONALLY_PRODUCED (5):
|
| 808 |
+
Professionally produced audio (eg. TV Show,
|
| 809 |
+
Podcast).
|
| 810 |
+
VOICE_SEARCH (6):
|
| 811 |
+
Transcribe spoken questions and queries into
|
| 812 |
+
text.
|
| 813 |
+
VOICE_COMMAND (7):
|
| 814 |
+
Transcribe voice commands, such as for
|
| 815 |
+
controlling a device.
|
| 816 |
+
DICTATION (8):
|
| 817 |
+
Transcribe speech to text to create a written
|
| 818 |
+
document, such as a text-message, email or
|
| 819 |
+
report.
|
| 820 |
+
"""
|
| 821 |
+
|
| 822 |
+
INTERACTION_TYPE_UNSPECIFIED = 0
|
| 823 |
+
DISCUSSION = 1
|
| 824 |
+
PRESENTATION = 2
|
| 825 |
+
PHONE_CALL = 3
|
| 826 |
+
VOICEMAIL = 4
|
| 827 |
+
PROFESSIONALLY_PRODUCED = 5
|
| 828 |
+
VOICE_SEARCH = 6
|
| 829 |
+
VOICE_COMMAND = 7
|
| 830 |
+
DICTATION = 8
|
| 831 |
+
|
| 832 |
+
class MicrophoneDistance(proto.Enum):
|
| 833 |
+
r"""Enumerates the types of capture settings describing an audio
|
| 834 |
+
file.
|
| 835 |
+
|
| 836 |
+
Values:
|
| 837 |
+
MICROPHONE_DISTANCE_UNSPECIFIED (0):
|
| 838 |
+
Audio type is not known.
|
| 839 |
+
NEARFIELD (1):
|
| 840 |
+
The audio was captured from a closely placed
|
| 841 |
+
microphone. Eg. phone, dictaphone, or handheld
|
| 842 |
+
microphone. Generally if there speaker is within
|
| 843 |
+
1 meter of the microphone.
|
| 844 |
+
MIDFIELD (2):
|
| 845 |
+
The speaker if within 3 meters of the
|
| 846 |
+
microphone.
|
| 847 |
+
FARFIELD (3):
|
| 848 |
+
The speaker is more than 3 meters away from
|
| 849 |
+
the microphone.
|
| 850 |
+
"""
|
| 851 |
+
|
| 852 |
+
MICROPHONE_DISTANCE_UNSPECIFIED = 0
|
| 853 |
+
NEARFIELD = 1
|
| 854 |
+
MIDFIELD = 2
|
| 855 |
+
FARFIELD = 3
|
| 856 |
+
|
| 857 |
+
class OriginalMediaType(proto.Enum):
|
| 858 |
+
r"""The original media the speech was recorded on.
|
| 859 |
+
|
| 860 |
+
Values:
|
| 861 |
+
ORIGINAL_MEDIA_TYPE_UNSPECIFIED (0):
|
| 862 |
+
Unknown original media type.
|
| 863 |
+
AUDIO (1):
|
| 864 |
+
The speech data is an audio recording.
|
| 865 |
+
VIDEO (2):
|
| 866 |
+
The speech data originally recorded on a
|
| 867 |
+
video.
|
| 868 |
+
"""
|
| 869 |
+
|
| 870 |
+
ORIGINAL_MEDIA_TYPE_UNSPECIFIED = 0
|
| 871 |
+
AUDIO = 1
|
| 872 |
+
VIDEO = 2
|
| 873 |
+
|
| 874 |
+
class RecordingDeviceType(proto.Enum):
|
| 875 |
+
r"""The type of device the speech was recorded with.
|
| 876 |
+
|
| 877 |
+
Values:
|
| 878 |
+
RECORDING_DEVICE_TYPE_UNSPECIFIED (0):
|
| 879 |
+
The recording device is unknown.
|
| 880 |
+
SMARTPHONE (1):
|
| 881 |
+
Speech was recorded on a smartphone.
|
| 882 |
+
PC (2):
|
| 883 |
+
Speech was recorded using a personal computer
|
| 884 |
+
or tablet.
|
| 885 |
+
PHONE_LINE (3):
|
| 886 |
+
Speech was recorded over a phone line.
|
| 887 |
+
VEHICLE (4):
|
| 888 |
+
Speech was recorded in a vehicle.
|
| 889 |
+
OTHER_OUTDOOR_DEVICE (5):
|
| 890 |
+
Speech was recorded outdoors.
|
| 891 |
+
OTHER_INDOOR_DEVICE (6):
|
| 892 |
+
Speech was recorded indoors.
|
| 893 |
+
"""
|
| 894 |
+
|
| 895 |
+
RECORDING_DEVICE_TYPE_UNSPECIFIED = 0
|
| 896 |
+
SMARTPHONE = 1
|
| 897 |
+
PC = 2
|
| 898 |
+
PHONE_LINE = 3
|
| 899 |
+
VEHICLE = 4
|
| 900 |
+
OTHER_OUTDOOR_DEVICE = 5
|
| 901 |
+
OTHER_INDOOR_DEVICE = 6
|
| 902 |
+
|
| 903 |
+
interaction_type: InteractionType = proto.Field(
|
| 904 |
+
proto.ENUM,
|
| 905 |
+
number=1,
|
| 906 |
+
enum=InteractionType,
|
| 907 |
+
)
|
| 908 |
+
industry_naics_code_of_audio: int = proto.Field(
|
| 909 |
+
proto.UINT32,
|
| 910 |
+
number=3,
|
| 911 |
+
)
|
| 912 |
+
microphone_distance: MicrophoneDistance = proto.Field(
|
| 913 |
+
proto.ENUM,
|
| 914 |
+
number=4,
|
| 915 |
+
enum=MicrophoneDistance,
|
| 916 |
+
)
|
| 917 |
+
original_media_type: OriginalMediaType = proto.Field(
|
| 918 |
+
proto.ENUM,
|
| 919 |
+
number=5,
|
| 920 |
+
enum=OriginalMediaType,
|
| 921 |
+
)
|
| 922 |
+
recording_device_type: RecordingDeviceType = proto.Field(
|
| 923 |
+
proto.ENUM,
|
| 924 |
+
number=6,
|
| 925 |
+
enum=RecordingDeviceType,
|
| 926 |
+
)
|
| 927 |
+
recording_device_name: str = proto.Field(
|
| 928 |
+
proto.STRING,
|
| 929 |
+
number=7,
|
| 930 |
+
)
|
| 931 |
+
original_mime_type: str = proto.Field(
|
| 932 |
+
proto.STRING,
|
| 933 |
+
number=8,
|
| 934 |
+
)
|
| 935 |
+
obfuscated_id: int = proto.Field(
|
| 936 |
+
proto.INT64,
|
| 937 |
+
number=9,
|
| 938 |
+
)
|
| 939 |
+
audio_topic: str = proto.Field(
|
| 940 |
+
proto.STRING,
|
| 941 |
+
number=10,
|
| 942 |
+
)
|
| 943 |
+
|
| 944 |
+
|
| 945 |
+
class SpeechContext(proto.Message):
|
| 946 |
+
r"""Provides "hints" to the speech recognizer to favor specific
|
| 947 |
+
words and phrases in the results.
|
| 948 |
+
|
| 949 |
+
Attributes:
|
| 950 |
+
phrases (MutableSequence[str]):
|
| 951 |
+
A list of strings containing words and phrases "hints" so
|
| 952 |
+
that the speech recognition is more likely to recognize
|
| 953 |
+
them. This can be used to improve the accuracy for specific
|
| 954 |
+
words and phrases, for example, if specific commands are
|
| 955 |
+
typically spoken by the user. This can also be used to add
|
| 956 |
+
additional words to the vocabulary of the recognizer. See
|
| 957 |
+
`usage
|
| 958 |
+
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
|
| 959 |
+
|
| 960 |
+
List items can also be set to classes for groups of words
|
| 961 |
+
that represent common concepts that occur in natural
|
| 962 |
+
language. For example, rather than providing phrase hints
|
| 963 |
+
for every month of the year, using the $MONTH class improves
|
| 964 |
+
the likelihood of correctly transcribing audio that includes
|
| 965 |
+
months.
|
| 966 |
+
boost (float):
|
| 967 |
+
Hint Boost. Positive value will increase the probability
|
| 968 |
+
that a specific phrase will be recognized over other similar
|
| 969 |
+
sounding phrases. The higher the boost, the higher the
|
| 970 |
+
chance of false positive recognition as well. Negative boost
|
| 971 |
+
values would correspond to anti-biasing. Anti-biasing is not
|
| 972 |
+
enabled, so negative boost will simply be ignored. Though
|
| 973 |
+
``boost`` can accept a wide range of positive values, most
|
| 974 |
+
use cases are best served with values between 0 and 20. We
|
| 975 |
+
recommend using a binary search approach to finding the
|
| 976 |
+
optimal value for your use case.
|
| 977 |
+
"""
|
| 978 |
+
|
| 979 |
+
phrases: MutableSequence[str] = proto.RepeatedField(
|
| 980 |
+
proto.STRING,
|
| 981 |
+
number=1,
|
| 982 |
+
)
|
| 983 |
+
boost: float = proto.Field(
|
| 984 |
+
proto.FLOAT,
|
| 985 |
+
number=4,
|
| 986 |
+
)
|
| 987 |
+
|
| 988 |
+
|
| 989 |
+
class RecognitionAudio(proto.Message):
|
| 990 |
+
r"""Contains audio data in the encoding specified in the
|
| 991 |
+
``RecognitionConfig``. Either ``content`` or ``uri`` must be
|
| 992 |
+
supplied. Supplying both or neither returns
|
| 993 |
+
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].
|
| 994 |
+
See `content
|
| 995 |
+
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
|
| 996 |
+
|
| 997 |
+
This message has `oneof`_ fields (mutually exclusive fields).
|
| 998 |
+
For each oneof, at most one member field can be set at the same time.
|
| 999 |
+
Setting any member of the oneof automatically clears all other
|
| 1000 |
+
members.
|
| 1001 |
+
|
| 1002 |
+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
|
| 1003 |
+
|
| 1004 |
+
Attributes:
|
| 1005 |
+
content (bytes):
|
| 1006 |
+
The audio data bytes encoded as specified in
|
| 1007 |
+
``RecognitionConfig``. Note: as with all bytes fields, proto
|
| 1008 |
+
buffers use a pure binary representation, whereas JSON
|
| 1009 |
+
representations use base64.
|
| 1010 |
+
|
| 1011 |
+
This field is a member of `oneof`_ ``audio_source``.
|
| 1012 |
+
uri (str):
|
| 1013 |
+
URI that points to a file that contains audio data bytes as
|
| 1014 |
+
specified in ``RecognitionConfig``. The file must not be
|
| 1015 |
+
compressed (for example, gzip). Currently, only Google Cloud
|
| 1016 |
+
Storage URIs are supported, which must be specified in the
|
| 1017 |
+
following format: ``gs://bucket_name/object_name`` (other
|
| 1018 |
+
URI formats return
|
| 1019 |
+
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]).
|
| 1020 |
+
For more information, see `Request
|
| 1021 |
+
URIs <https://cloud.google.com/storage/docs/reference-uris>`__.
|
| 1022 |
+
|
| 1023 |
+
This field is a member of `oneof`_ ``audio_source``.
|
| 1024 |
+
"""
|
| 1025 |
+
|
| 1026 |
+
content: bytes = proto.Field(
|
| 1027 |
+
proto.BYTES,
|
| 1028 |
+
number=1,
|
| 1029 |
+
oneof="audio_source",
|
| 1030 |
+
)
|
| 1031 |
+
uri: str = proto.Field(
|
| 1032 |
+
proto.STRING,
|
| 1033 |
+
number=2,
|
| 1034 |
+
oneof="audio_source",
|
| 1035 |
+
)
|
| 1036 |
+
|
| 1037 |
+
|
| 1038 |
+
class RecognizeResponse(proto.Message):
|
| 1039 |
+
r"""The only message returned to the client by the ``Recognize`` method.
|
| 1040 |
+
It contains the result as zero or more sequential
|
| 1041 |
+
``SpeechRecognitionResult`` messages.
|
| 1042 |
+
|
| 1043 |
+
Attributes:
|
| 1044 |
+
results (MutableSequence[google.cloud.speech_v1p1beta1.types.SpeechRecognitionResult]):
|
| 1045 |
+
Sequential list of transcription results
|
| 1046 |
+
corresponding to sequential portions of audio.
|
| 1047 |
+
total_billed_time (google.protobuf.duration_pb2.Duration):
|
| 1048 |
+
When available, billed audio seconds for the
|
| 1049 |
+
corresponding request.
|
| 1050 |
+
speech_adaptation_info (google.cloud.speech_v1p1beta1.types.SpeechAdaptationInfo):
|
| 1051 |
+
Provides information on adaptation behavior
|
| 1052 |
+
in response
|
| 1053 |
+
request_id (int):
|
| 1054 |
+
The ID associated with the request. This is a
|
| 1055 |
+
unique ID specific only to the given request.
|
| 1056 |
+
using_legacy_models (bool):
|
| 1057 |
+
Whether request used legacy asr models (was
|
| 1058 |
+
not automatically migrated to use conformer
|
| 1059 |
+
models).
|
| 1060 |
+
"""
|
| 1061 |
+
|
| 1062 |
+
results: MutableSequence["SpeechRecognitionResult"] = proto.RepeatedField(
|
| 1063 |
+
proto.MESSAGE,
|
| 1064 |
+
number=2,
|
| 1065 |
+
message="SpeechRecognitionResult",
|
| 1066 |
+
)
|
| 1067 |
+
total_billed_time: duration_pb2.Duration = proto.Field(
|
| 1068 |
+
proto.MESSAGE,
|
| 1069 |
+
number=3,
|
| 1070 |
+
message=duration_pb2.Duration,
|
| 1071 |
+
)
|
| 1072 |
+
speech_adaptation_info: "SpeechAdaptationInfo" = proto.Field(
|
| 1073 |
+
proto.MESSAGE,
|
| 1074 |
+
number=7,
|
| 1075 |
+
message="SpeechAdaptationInfo",
|
| 1076 |
+
)
|
| 1077 |
+
request_id: int = proto.Field(
|
| 1078 |
+
proto.INT64,
|
| 1079 |
+
number=8,
|
| 1080 |
+
)
|
| 1081 |
+
using_legacy_models: bool = proto.Field(
|
| 1082 |
+
proto.BOOL,
|
| 1083 |
+
number=9,
|
| 1084 |
+
)
|
| 1085 |
+
|
| 1086 |
+
|
| 1087 |
+
class LongRunningRecognizeResponse(proto.Message):
|
| 1088 |
+
r"""The only message returned to the client by the
|
| 1089 |
+
``LongRunningRecognize`` method. It contains the result as zero or
|
| 1090 |
+
more sequential ``SpeechRecognitionResult`` messages. It is included
|
| 1091 |
+
in the ``result.response`` field of the ``Operation`` returned by
|
| 1092 |
+
the ``GetOperation`` call of the ``google::longrunning::Operations``
|
| 1093 |
+
service.
|
| 1094 |
+
|
| 1095 |
+
Attributes:
|
| 1096 |
+
results (MutableSequence[google.cloud.speech_v1p1beta1.types.SpeechRecognitionResult]):
|
| 1097 |
+
Sequential list of transcription results
|
| 1098 |
+
corresponding to sequential portions of audio.
|
| 1099 |
+
total_billed_time (google.protobuf.duration_pb2.Duration):
|
| 1100 |
+
When available, billed audio seconds for the
|
| 1101 |
+
corresponding request.
|
| 1102 |
+
output_config (google.cloud.speech_v1p1beta1.types.TranscriptOutputConfig):
|
| 1103 |
+
Original output config if present in the
|
| 1104 |
+
request.
|
| 1105 |
+
output_error (google.rpc.status_pb2.Status):
|
| 1106 |
+
If the transcript output fails this field
|
| 1107 |
+
contains the relevant error.
|
| 1108 |
+
speech_adaptation_info (google.cloud.speech_v1p1beta1.types.SpeechAdaptationInfo):
|
| 1109 |
+
Provides information on speech adaptation
|
| 1110 |
+
behavior in response
|
| 1111 |
+
request_id (int):
|
| 1112 |
+
The ID associated with the request. This is a
|
| 1113 |
+
unique ID specific only to the given request.
|
| 1114 |
+
"""
|
| 1115 |
+
|
| 1116 |
+
results: MutableSequence["SpeechRecognitionResult"] = proto.RepeatedField(
|
| 1117 |
+
proto.MESSAGE,
|
| 1118 |
+
number=2,
|
| 1119 |
+
message="SpeechRecognitionResult",
|
| 1120 |
+
)
|
| 1121 |
+
total_billed_time: duration_pb2.Duration = proto.Field(
|
| 1122 |
+
proto.MESSAGE,
|
| 1123 |
+
number=3,
|
| 1124 |
+
message=duration_pb2.Duration,
|
| 1125 |
+
)
|
| 1126 |
+
output_config: "TranscriptOutputConfig" = proto.Field(
|
| 1127 |
+
proto.MESSAGE,
|
| 1128 |
+
number=6,
|
| 1129 |
+
message="TranscriptOutputConfig",
|
| 1130 |
+
)
|
| 1131 |
+
output_error: status_pb2.Status = proto.Field(
|
| 1132 |
+
proto.MESSAGE,
|
| 1133 |
+
number=7,
|
| 1134 |
+
message=status_pb2.Status,
|
| 1135 |
+
)
|
| 1136 |
+
speech_adaptation_info: "SpeechAdaptationInfo" = proto.Field(
|
| 1137 |
+
proto.MESSAGE,
|
| 1138 |
+
number=8,
|
| 1139 |
+
message="SpeechAdaptationInfo",
|
| 1140 |
+
)
|
| 1141 |
+
request_id: int = proto.Field(
|
| 1142 |
+
proto.INT64,
|
| 1143 |
+
number=9,
|
| 1144 |
+
)
|
| 1145 |
+
|
| 1146 |
+
|
| 1147 |
+
class LongRunningRecognizeMetadata(proto.Message):
|
| 1148 |
+
r"""Describes the progress of a long-running ``LongRunningRecognize``
|
| 1149 |
+
call. It is included in the ``metadata`` field of the ``Operation``
|
| 1150 |
+
returned by the ``GetOperation`` call of the
|
| 1151 |
+
``google::longrunning::Operations`` service.
|
| 1152 |
+
|
| 1153 |
+
Attributes:
|
| 1154 |
+
progress_percent (int):
|
| 1155 |
+
Approximate percentage of audio processed
|
| 1156 |
+
thus far. Guaranteed to be 100 when the audio is
|
| 1157 |
+
fully processed and the results are available.
|
| 1158 |
+
start_time (google.protobuf.timestamp_pb2.Timestamp):
|
| 1159 |
+
Time when the request was received.
|
| 1160 |
+
last_update_time (google.protobuf.timestamp_pb2.Timestamp):
|
| 1161 |
+
Time of the most recent processing update.
|
| 1162 |
+
uri (str):
|
| 1163 |
+
Output only. The URI of the audio file being
|
| 1164 |
+
transcribed. Empty if the audio was sent as byte
|
| 1165 |
+
content.
|
| 1166 |
+
output_config (google.cloud.speech_v1p1beta1.types.TranscriptOutputConfig):
|
| 1167 |
+
Output only. A copy of the
|
| 1168 |
+
TranscriptOutputConfig if it was set in the
|
| 1169 |
+
request.
|
| 1170 |
+
"""
|
| 1171 |
+
|
| 1172 |
+
progress_percent: int = proto.Field(
|
| 1173 |
+
proto.INT32,
|
| 1174 |
+
number=1,
|
| 1175 |
+
)
|
| 1176 |
+
start_time: timestamp_pb2.Timestamp = proto.Field(
|
| 1177 |
+
proto.MESSAGE,
|
| 1178 |
+
number=2,
|
| 1179 |
+
message=timestamp_pb2.Timestamp,
|
| 1180 |
+
)
|
| 1181 |
+
last_update_time: timestamp_pb2.Timestamp = proto.Field(
|
| 1182 |
+
proto.MESSAGE,
|
| 1183 |
+
number=3,
|
| 1184 |
+
message=timestamp_pb2.Timestamp,
|
| 1185 |
+
)
|
| 1186 |
+
uri: str = proto.Field(
|
| 1187 |
+
proto.STRING,
|
| 1188 |
+
number=4,
|
| 1189 |
+
)
|
| 1190 |
+
output_config: "TranscriptOutputConfig" = proto.Field(
|
| 1191 |
+
proto.MESSAGE,
|
| 1192 |
+
number=5,
|
| 1193 |
+
message="TranscriptOutputConfig",
|
| 1194 |
+
)
|
| 1195 |
+
|
| 1196 |
+
|
| 1197 |
+
class StreamingRecognizeResponse(proto.Message):
|
| 1198 |
+
r"""``StreamingRecognizeResponse`` is the only message returned to the
|
| 1199 |
+
client by ``StreamingRecognize``. A series of zero or more
|
| 1200 |
+
``StreamingRecognizeResponse`` messages are streamed back to the
|
| 1201 |
+
client. If there is no recognizable audio, and ``single_utterance``
|
| 1202 |
+
is set to false, then no messages are streamed back to the client.
|
| 1203 |
+
|
| 1204 |
+
Here's an example of a series of ``StreamingRecognizeResponse``\ s
|
| 1205 |
+
that might be returned while processing audio:
|
| 1206 |
+
|
| 1207 |
+
1. results { alternatives { transcript: "tube" } stability: 0.01 }
|
| 1208 |
+
|
| 1209 |
+
2. results { alternatives { transcript: "to be a" } stability: 0.01
|
| 1210 |
+
}
|
| 1211 |
+
|
| 1212 |
+
3. results { alternatives { transcript: "to be" } stability: 0.9 }
|
| 1213 |
+
results { alternatives { transcript: " or not to be" } stability:
|
| 1214 |
+
0.01 }
|
| 1215 |
+
|
| 1216 |
+
4. results { alternatives { transcript: "to be or not to be"
|
| 1217 |
+
confidence: 0.92 } alternatives { transcript: "to bee or not to
|
| 1218 |
+
bee" } is_final: true }
|
| 1219 |
+
|
| 1220 |
+
5. results { alternatives { transcript: " that's" } stability: 0.01
|
| 1221 |
+
}
|
| 1222 |
+
|
| 1223 |
+
6. results { alternatives { transcript: " that is" } stability: 0.9
|
| 1224 |
+
} results { alternatives { transcript: " the question" }
|
| 1225 |
+
stability: 0.01 }
|
| 1226 |
+
|
| 1227 |
+
7. results { alternatives { transcript: " that is the question"
|
| 1228 |
+
confidence: 0.98 } alternatives { transcript: " that was the
|
| 1229 |
+
question" } is_final: true }
|
| 1230 |
+
|
| 1231 |
+
Notes:
|
| 1232 |
+
|
| 1233 |
+
- Only two of the above responses #4 and #7 contain final results;
|
| 1234 |
+
they are indicated by ``is_final: true``. Concatenating these
|
| 1235 |
+
together generates the full transcript: "to be or not to be that
|
| 1236 |
+
is the question".
|
| 1237 |
+
|
| 1238 |
+
- The others contain interim ``results``. #3 and #6 contain two
|
| 1239 |
+
interim ``results``: the first portion has a high stability and is
|
| 1240 |
+
less likely to change; the second portion has a low stability and
|
| 1241 |
+
is very likely to change. A UI designer might choose to show only
|
| 1242 |
+
high stability ``results``.
|
| 1243 |
+
|
| 1244 |
+
- The specific ``stability`` and ``confidence`` values shown above
|
| 1245 |
+
are only for illustrative purposes. Actual values may vary.
|
| 1246 |
+
|
| 1247 |
+
- In each response, only one of these fields will be set: ``error``,
|
| 1248 |
+
``speech_event_type``, or one or more (repeated) ``results``.
|
| 1249 |
+
|
| 1250 |
+
Attributes:
|
| 1251 |
+
error (google.rpc.status_pb2.Status):
|
| 1252 |
+
If set, returns a [google.rpc.Status][google.rpc.Status]
|
| 1253 |
+
message that specifies the error for the operation.
|
| 1254 |
+
results (MutableSequence[google.cloud.speech_v1p1beta1.types.StreamingRecognitionResult]):
|
| 1255 |
+
This repeated list contains zero or more results that
|
| 1256 |
+
correspond to consecutive portions of the audio currently
|
| 1257 |
+
being processed. It contains zero or one ``is_final=true``
|
| 1258 |
+
result (the newly settled portion), followed by zero or more
|
| 1259 |
+
``is_final=false`` results (the interim results).
|
| 1260 |
+
speech_event_type (google.cloud.speech_v1p1beta1.types.StreamingRecognizeResponse.SpeechEventType):
|
| 1261 |
+
Indicates the type of speech event.
|
| 1262 |
+
speech_event_time (google.protobuf.duration_pb2.Duration):
|
| 1263 |
+
Time offset between the beginning of the
|
| 1264 |
+
audio and event emission.
|
| 1265 |
+
total_billed_time (google.protobuf.duration_pb2.Duration):
|
| 1266 |
+
When available, billed audio seconds for the
|
| 1267 |
+
stream. Set only if this is the last response in
|
| 1268 |
+
the stream.
|
| 1269 |
+
speech_adaptation_info (google.cloud.speech_v1p1beta1.types.SpeechAdaptationInfo):
|
| 1270 |
+
Provides information on adaptation behavior
|
| 1271 |
+
in response
|
| 1272 |
+
request_id (int):
|
| 1273 |
+
The ID associated with the request. This is a
|
| 1274 |
+
unique ID specific only to the given request.
|
| 1275 |
+
"""
|
| 1276 |
+
|
| 1277 |
+
class SpeechEventType(proto.Enum):
|
| 1278 |
+
r"""Indicates the type of speech event.
|
| 1279 |
+
|
| 1280 |
+
Values:
|
| 1281 |
+
SPEECH_EVENT_UNSPECIFIED (0):
|
| 1282 |
+
No speech event specified.
|
| 1283 |
+
END_OF_SINGLE_UTTERANCE (1):
|
| 1284 |
+
This event indicates that the server has detected the end of
|
| 1285 |
+
the user's speech utterance and expects no additional
|
| 1286 |
+
speech. Therefore, the server will not process additional
|
| 1287 |
+
audio (although it may subsequently return additional
|
| 1288 |
+
results). The client should stop sending additional audio
|
| 1289 |
+
data, half-close the gRPC connection, and wait for any
|
| 1290 |
+
additional results until the server closes the gRPC
|
| 1291 |
+
connection. This event is only sent if ``single_utterance``
|
| 1292 |
+
was set to ``true``, and is not used otherwise.
|
| 1293 |
+
SPEECH_ACTIVITY_BEGIN (2):
|
| 1294 |
+
This event indicates that the server has detected the
|
| 1295 |
+
beginning of human voice activity in the stream. This event
|
| 1296 |
+
can be returned multiple times if speech starts and stops
|
| 1297 |
+
repeatedly throughout the stream. This event is only sent if
|
| 1298 |
+
``voice_activity_events`` is set to true.
|
| 1299 |
+
SPEECH_ACTIVITY_END (3):
|
| 1300 |
+
This event indicates that the server has detected the end of
|
| 1301 |
+
human voice activity in the stream. This event can be
|
| 1302 |
+
returned multiple times if speech starts and stops
|
| 1303 |
+
repeatedly throughout the stream. This event is only sent if
|
| 1304 |
+
``voice_activity_events`` is set to true.
|
| 1305 |
+
SPEECH_ACTIVITY_TIMEOUT (4):
|
| 1306 |
+
This event indicates that the user-set
|
| 1307 |
+
timeout for speech activity begin or end has
|
| 1308 |
+
exceeded. Upon receiving this event, the client
|
| 1309 |
+
is expected to send a half close. Further audio
|
| 1310 |
+
will not be processed.
|
| 1311 |
+
"""
|
| 1312 |
+
|
| 1313 |
+
SPEECH_EVENT_UNSPECIFIED = 0
|
| 1314 |
+
END_OF_SINGLE_UTTERANCE = 1
|
| 1315 |
+
SPEECH_ACTIVITY_BEGIN = 2
|
| 1316 |
+
SPEECH_ACTIVITY_END = 3
|
| 1317 |
+
SPEECH_ACTIVITY_TIMEOUT = 4
|
| 1318 |
+
|
| 1319 |
+
error: status_pb2.Status = proto.Field(
|
| 1320 |
+
proto.MESSAGE,
|
| 1321 |
+
number=1,
|
| 1322 |
+
message=status_pb2.Status,
|
| 1323 |
+
)
|
| 1324 |
+
results: MutableSequence["StreamingRecognitionResult"] = proto.RepeatedField(
|
| 1325 |
+
proto.MESSAGE,
|
| 1326 |
+
number=2,
|
| 1327 |
+
message="StreamingRecognitionResult",
|
| 1328 |
+
)
|
| 1329 |
+
speech_event_type: SpeechEventType = proto.Field(
|
| 1330 |
+
proto.ENUM,
|
| 1331 |
+
number=4,
|
| 1332 |
+
enum=SpeechEventType,
|
| 1333 |
+
)
|
| 1334 |
+
speech_event_time: duration_pb2.Duration = proto.Field(
|
| 1335 |
+
proto.MESSAGE,
|
| 1336 |
+
number=8,
|
| 1337 |
+
message=duration_pb2.Duration,
|
| 1338 |
+
)
|
| 1339 |
+
total_billed_time: duration_pb2.Duration = proto.Field(
|
| 1340 |
+
proto.MESSAGE,
|
| 1341 |
+
number=5,
|
| 1342 |
+
message=duration_pb2.Duration,
|
| 1343 |
+
)
|
| 1344 |
+
speech_adaptation_info: "SpeechAdaptationInfo" = proto.Field(
|
| 1345 |
+
proto.MESSAGE,
|
| 1346 |
+
number=9,
|
| 1347 |
+
message="SpeechAdaptationInfo",
|
| 1348 |
+
)
|
| 1349 |
+
request_id: int = proto.Field(
|
| 1350 |
+
proto.INT64,
|
| 1351 |
+
number=10,
|
| 1352 |
+
)
|
| 1353 |
+
|
| 1354 |
+
|
| 1355 |
+
class StreamingRecognitionResult(proto.Message):
|
| 1356 |
+
r"""A streaming speech recognition result corresponding to a
|
| 1357 |
+
portion of the audio that is currently being processed.
|
| 1358 |
+
|
| 1359 |
+
Attributes:
|
| 1360 |
+
alternatives (MutableSequence[google.cloud.speech_v1p1beta1.types.SpeechRecognitionAlternative]):
|
| 1361 |
+
May contain one or more recognition hypotheses (up to the
|
| 1362 |
+
maximum specified in ``max_alternatives``). These
|
| 1363 |
+
alternatives are ordered in terms of accuracy, with the top
|
| 1364 |
+
(first) alternative being the most probable, as ranked by
|
| 1365 |
+
the recognizer.
|
| 1366 |
+
is_final (bool):
|
| 1367 |
+
If ``false``, this ``StreamingRecognitionResult`` represents
|
| 1368 |
+
an interim result that may change. If ``true``, this is the
|
| 1369 |
+
final time the speech service will return this particular
|
| 1370 |
+
``StreamingRecognitionResult``, the recognizer will not
|
| 1371 |
+
return any further hypotheses for this portion of the
|
| 1372 |
+
transcript and corresponding audio.
|
| 1373 |
+
stability (float):
|
| 1374 |
+
An estimate of the likelihood that the recognizer will not
|
| 1375 |
+
change its guess about this interim result. Values range
|
| 1376 |
+
from 0.0 (completely unstable) to 1.0 (completely stable).
|
| 1377 |
+
This field is only provided for interim results
|
| 1378 |
+
(``is_final=false``). The default of 0.0 is a sentinel value
|
| 1379 |
+
indicating ``stability`` was not set.
|
| 1380 |
+
result_end_time (google.protobuf.duration_pb2.Duration):
|
| 1381 |
+
Time offset of the end of this result
|
| 1382 |
+
relative to the beginning of the audio.
|
| 1383 |
+
channel_tag (int):
|
| 1384 |
+
For multi-channel audio, this is the channel number
|
| 1385 |
+
corresponding to the recognized result for the audio from
|
| 1386 |
+
that channel. For audio_channel_count = N, its output values
|
| 1387 |
+
can range from '1' to 'N'.
|
| 1388 |
+
language_code (str):
|
| 1389 |
+
Output only. The
|
| 1390 |
+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
|
| 1391 |
+
language tag of the language in this result. This language
|
| 1392 |
+
code was detected to have the most likelihood of being
|
| 1393 |
+
spoken in the audio.
|
| 1394 |
+
"""
|
| 1395 |
+
|
| 1396 |
+
alternatives: MutableSequence["SpeechRecognitionAlternative"] = proto.RepeatedField(
|
| 1397 |
+
proto.MESSAGE,
|
| 1398 |
+
number=1,
|
| 1399 |
+
message="SpeechRecognitionAlternative",
|
| 1400 |
+
)
|
| 1401 |
+
is_final: bool = proto.Field(
|
| 1402 |
+
proto.BOOL,
|
| 1403 |
+
number=2,
|
| 1404 |
+
)
|
| 1405 |
+
stability: float = proto.Field(
|
| 1406 |
+
proto.FLOAT,
|
| 1407 |
+
number=3,
|
| 1408 |
+
)
|
| 1409 |
+
result_end_time: duration_pb2.Duration = proto.Field(
|
| 1410 |
+
proto.MESSAGE,
|
| 1411 |
+
number=4,
|
| 1412 |
+
message=duration_pb2.Duration,
|
| 1413 |
+
)
|
| 1414 |
+
channel_tag: int = proto.Field(
|
| 1415 |
+
proto.INT32,
|
| 1416 |
+
number=5,
|
| 1417 |
+
)
|
| 1418 |
+
language_code: str = proto.Field(
|
| 1419 |
+
proto.STRING,
|
| 1420 |
+
number=6,
|
| 1421 |
+
)
|
| 1422 |
+
|
| 1423 |
+
|
| 1424 |
+
class SpeechRecognitionResult(proto.Message):
|
| 1425 |
+
r"""A speech recognition result corresponding to a portion of the
|
| 1426 |
+
audio.
|
| 1427 |
+
|
| 1428 |
+
Attributes:
|
| 1429 |
+
alternatives (MutableSequence[google.cloud.speech_v1p1beta1.types.SpeechRecognitionAlternative]):
|
| 1430 |
+
May contain one or more recognition hypotheses (up to the
|
| 1431 |
+
maximum specified in ``max_alternatives``). These
|
| 1432 |
+
alternatives are ordered in terms of accuracy, with the top
|
| 1433 |
+
(first) alternative being the most probable, as ranked by
|
| 1434 |
+
the recognizer.
|
| 1435 |
+
channel_tag (int):
|
| 1436 |
+
For multi-channel audio, this is the channel number
|
| 1437 |
+
corresponding to the recognized result for the audio from
|
| 1438 |
+
that channel. For audio_channel_count = N, its output values
|
| 1439 |
+
can range from '1' to 'N'.
|
| 1440 |
+
result_end_time (google.protobuf.duration_pb2.Duration):
|
| 1441 |
+
Time offset of the end of this result
|
| 1442 |
+
relative to the beginning of the audio.
|
| 1443 |
+
language_code (str):
|
| 1444 |
+
Output only. The
|
| 1445 |
+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
|
| 1446 |
+
language tag of the language in this result. This language
|
| 1447 |
+
code was detected to have the most likelihood of being
|
| 1448 |
+
spoken in the audio.
|
| 1449 |
+
"""
|
| 1450 |
+
|
| 1451 |
+
alternatives: MutableSequence["SpeechRecognitionAlternative"] = proto.RepeatedField(
|
| 1452 |
+
proto.MESSAGE,
|
| 1453 |
+
number=1,
|
| 1454 |
+
message="SpeechRecognitionAlternative",
|
| 1455 |
+
)
|
| 1456 |
+
channel_tag: int = proto.Field(
|
| 1457 |
+
proto.INT32,
|
| 1458 |
+
number=2,
|
| 1459 |
+
)
|
| 1460 |
+
result_end_time: duration_pb2.Duration = proto.Field(
|
| 1461 |
+
proto.MESSAGE,
|
| 1462 |
+
number=4,
|
| 1463 |
+
message=duration_pb2.Duration,
|
| 1464 |
+
)
|
| 1465 |
+
language_code: str = proto.Field(
|
| 1466 |
+
proto.STRING,
|
| 1467 |
+
number=5,
|
| 1468 |
+
)
|
| 1469 |
+
|
| 1470 |
+
|
| 1471 |
+
class SpeechRecognitionAlternative(proto.Message):
|
| 1472 |
+
r"""Alternative hypotheses (a.k.a. n-best list).
|
| 1473 |
+
|
| 1474 |
+
Attributes:
|
| 1475 |
+
transcript (str):
|
| 1476 |
+
Transcript text representing the words that
|
| 1477 |
+
the user spoke. In languages that use spaces to
|
| 1478 |
+
separate words, the transcript might have a
|
| 1479 |
+
leading space if it isn't the first result. You
|
| 1480 |
+
can concatenate each result to obtain the full
|
| 1481 |
+
transcript without using a separator.
|
| 1482 |
+
confidence (float):
|
| 1483 |
+
The confidence estimate between 0.0 and 1.0. A higher number
|
| 1484 |
+
indicates an estimated greater likelihood that the
|
| 1485 |
+
recognized words are correct. This field is set only for the
|
| 1486 |
+
top alternative of a non-streaming result or, of a streaming
|
| 1487 |
+
result where ``is_final=true``. This field is not guaranteed
|
| 1488 |
+
to be accurate and users should not rely on it to be always
|
| 1489 |
+
provided. The default of 0.0 is a sentinel value indicating
|
| 1490 |
+
``confidence`` was not set.
|
| 1491 |
+
words (MutableSequence[google.cloud.speech_v1p1beta1.types.WordInfo]):
|
| 1492 |
+
A list of word-specific information for each recognized
|
| 1493 |
+
word. Note: When ``enable_speaker_diarization`` is true, you
|
| 1494 |
+
will see all the words from the beginning of the audio.
|
| 1495 |
+
"""
|
| 1496 |
+
|
| 1497 |
+
transcript: str = proto.Field(
|
| 1498 |
+
proto.STRING,
|
| 1499 |
+
number=1,
|
| 1500 |
+
)
|
| 1501 |
+
confidence: float = proto.Field(
|
| 1502 |
+
proto.FLOAT,
|
| 1503 |
+
number=2,
|
| 1504 |
+
)
|
| 1505 |
+
words: MutableSequence["WordInfo"] = proto.RepeatedField(
|
| 1506 |
+
proto.MESSAGE,
|
| 1507 |
+
number=3,
|
| 1508 |
+
message="WordInfo",
|
| 1509 |
+
)
|
| 1510 |
+
|
| 1511 |
+
|
| 1512 |
+
class WordInfo(proto.Message):
|
| 1513 |
+
r"""Word-specific information for recognized words.
|
| 1514 |
+
|
| 1515 |
+
Attributes:
|
| 1516 |
+
start_time (google.protobuf.duration_pb2.Duration):
|
| 1517 |
+
Time offset relative to the beginning of the audio, and
|
| 1518 |
+
corresponding to the start of the spoken word. This field is
|
| 1519 |
+
only set if ``enable_word_time_offsets=true`` and only in
|
| 1520 |
+
the top hypothesis. This is an experimental feature and the
|
| 1521 |
+
accuracy of the time offset can vary.
|
| 1522 |
+
end_time (google.protobuf.duration_pb2.Duration):
|
| 1523 |
+
Time offset relative to the beginning of the audio, and
|
| 1524 |
+
corresponding to the end of the spoken word. This field is
|
| 1525 |
+
only set if ``enable_word_time_offsets=true`` and only in
|
| 1526 |
+
the top hypothesis. This is an experimental feature and the
|
| 1527 |
+
accuracy of the time offset can vary.
|
| 1528 |
+
word (str):
|
| 1529 |
+
The word corresponding to this set of
|
| 1530 |
+
information.
|
| 1531 |
+
confidence (float):
|
| 1532 |
+
The confidence estimate between 0.0 and 1.0. A higher number
|
| 1533 |
+
indicates an estimated greater likelihood that the
|
| 1534 |
+
recognized words are correct. This field is set only for the
|
| 1535 |
+
top alternative of a non-streaming result or, of a streaming
|
| 1536 |
+
result where ``is_final=true``. This field is not guaranteed
|
| 1537 |
+
to be accurate and users should not rely on it to be always
|
| 1538 |
+
provided. The default of 0.0 is a sentinel value indicating
|
| 1539 |
+
``confidence`` was not set.
|
| 1540 |
+
speaker_tag (int):
|
| 1541 |
+
Output only. A distinct integer value is assigned for every
|
| 1542 |
+
speaker within the audio. This field specifies which one of
|
| 1543 |
+
those speakers was detected to have spoken this word. Value
|
| 1544 |
+
ranges from '1' to diarization_speaker_count. speaker_tag is
|
| 1545 |
+
set if enable_speaker_diarization = 'true' and only for the
|
| 1546 |
+
top alternative. Note: Use speaker_label instead.
|
| 1547 |
+
speaker_label (str):
|
| 1548 |
+
Output only. A label value assigned for every unique speaker
|
| 1549 |
+
within the audio. This field specifies which speaker was
|
| 1550 |
+
detected to have spoken this word. For some models, like
|
| 1551 |
+
medical_conversation this can be actual speaker role, for
|
| 1552 |
+
example "patient" or "provider", but generally this would be
|
| 1553 |
+
a number identifying a speaker. This field is only set if
|
| 1554 |
+
enable_speaker_diarization = 'true' and only for the top
|
| 1555 |
+
alternative.
|
| 1556 |
+
"""
|
| 1557 |
+
|
| 1558 |
+
start_time: duration_pb2.Duration = proto.Field(
|
| 1559 |
+
proto.MESSAGE,
|
| 1560 |
+
number=1,
|
| 1561 |
+
message=duration_pb2.Duration,
|
| 1562 |
+
)
|
| 1563 |
+
end_time: duration_pb2.Duration = proto.Field(
|
| 1564 |
+
proto.MESSAGE,
|
| 1565 |
+
number=2,
|
| 1566 |
+
message=duration_pb2.Duration,
|
| 1567 |
+
)
|
| 1568 |
+
word: str = proto.Field(
|
| 1569 |
+
proto.STRING,
|
| 1570 |
+
number=3,
|
| 1571 |
+
)
|
| 1572 |
+
confidence: float = proto.Field(
|
| 1573 |
+
proto.FLOAT,
|
| 1574 |
+
number=4,
|
| 1575 |
+
)
|
| 1576 |
+
speaker_tag: int = proto.Field(
|
| 1577 |
+
proto.INT32,
|
| 1578 |
+
number=5,
|
| 1579 |
+
)
|
| 1580 |
+
speaker_label: str = proto.Field(
|
| 1581 |
+
proto.STRING,
|
| 1582 |
+
number=6,
|
| 1583 |
+
)
|
| 1584 |
+
|
| 1585 |
+
|
| 1586 |
+
class SpeechAdaptationInfo(proto.Message):
|
| 1587 |
+
r"""Information on speech adaptation use in results
|
| 1588 |
+
|
| 1589 |
+
Attributes:
|
| 1590 |
+
adaptation_timeout (bool):
|
| 1591 |
+
Whether there was a timeout when applying
|
| 1592 |
+
speech adaptation. If true, adaptation had no
|
| 1593 |
+
effect in the response transcript.
|
| 1594 |
+
timeout_message (str):
|
| 1595 |
+
If set, returns a message specifying which
|
| 1596 |
+
part of the speech adaptation request timed out.
|
| 1597 |
+
"""
|
| 1598 |
+
|
| 1599 |
+
adaptation_timeout: bool = proto.Field(
|
| 1600 |
+
proto.BOOL,
|
| 1601 |
+
number=1,
|
| 1602 |
+
)
|
| 1603 |
+
timeout_message: str = proto.Field(
|
| 1604 |
+
proto.STRING,
|
| 1605 |
+
number=4,
|
| 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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
from typing import MutableMapping, MutableSequence
|
| 19 |
+
|
| 20 |
+
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
|
| 21 |
+
import proto # type: ignore
|
| 22 |
+
|
| 23 |
+
from google.cloud.speech_v1p1beta1.types import resource
|
| 24 |
+
|
| 25 |
+
__protobuf__ = proto.module(
|
| 26 |
+
package="google.cloud.speech.v1p1beta1",
|
| 27 |
+
manifest={
|
| 28 |
+
"CreatePhraseSetRequest",
|
| 29 |
+
"UpdatePhraseSetRequest",
|
| 30 |
+
"GetPhraseSetRequest",
|
| 31 |
+
"ListPhraseSetRequest",
|
| 32 |
+
"ListPhraseSetResponse",
|
| 33 |
+
"DeletePhraseSetRequest",
|
| 34 |
+
"CreateCustomClassRequest",
|
| 35 |
+
"UpdateCustomClassRequest",
|
| 36 |
+
"GetCustomClassRequest",
|
| 37 |
+
"ListCustomClassesRequest",
|
| 38 |
+
"ListCustomClassesResponse",
|
| 39 |
+
"DeleteCustomClassRequest",
|
| 40 |
+
},
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class CreatePhraseSetRequest(proto.Message):
|
| 45 |
+
r"""Message sent by the client for the ``CreatePhraseSet`` method.
|
| 46 |
+
|
| 47 |
+
Attributes:
|
| 48 |
+
parent (str):
|
| 49 |
+
Required. The parent resource where this phrase set will be
|
| 50 |
+
created. Format:
|
| 51 |
+
|
| 52 |
+
``projects/{project}/locations/{location}``
|
| 53 |
+
|
| 54 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 55 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 56 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 57 |
+
location. To specify a region, use a `regional
|
| 58 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 59 |
+
with matching ``us`` or ``eu`` location value.
|
| 60 |
+
phrase_set_id (str):
|
| 61 |
+
Required. The ID to use for the phrase set,
|
| 62 |
+
which will become the final component of the
|
| 63 |
+
phrase set's resource name.
|
| 64 |
+
|
| 65 |
+
This value should restrict to letters, numbers,
|
| 66 |
+
and hyphens, with the first character a letter,
|
| 67 |
+
the last a letter or a number, and be 4-63
|
| 68 |
+
characters.
|
| 69 |
+
phrase_set (google.cloud.speech_v1p1beta1.types.PhraseSet):
|
| 70 |
+
Required. The phrase set to create.
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
parent: str = proto.Field(
|
| 74 |
+
proto.STRING,
|
| 75 |
+
number=1,
|
| 76 |
+
)
|
| 77 |
+
phrase_set_id: str = proto.Field(
|
| 78 |
+
proto.STRING,
|
| 79 |
+
number=2,
|
| 80 |
+
)
|
| 81 |
+
phrase_set: resource.PhraseSet = proto.Field(
|
| 82 |
+
proto.MESSAGE,
|
| 83 |
+
number=3,
|
| 84 |
+
message=resource.PhraseSet,
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class UpdatePhraseSetRequest(proto.Message):
|
| 89 |
+
r"""Message sent by the client for the ``UpdatePhraseSet`` method.
|
| 90 |
+
|
| 91 |
+
Attributes:
|
| 92 |
+
phrase_set (google.cloud.speech_v1p1beta1.types.PhraseSet):
|
| 93 |
+
Required. The phrase set to update.
|
| 94 |
+
|
| 95 |
+
The phrase set's ``name`` field is used to identify the set
|
| 96 |
+
to be updated. Format:
|
| 97 |
+
|
| 98 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 99 |
+
|
| 100 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 101 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 102 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 103 |
+
location. To specify a region, use a `regional
|
| 104 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 105 |
+
with matching ``us`` or ``eu`` location value.
|
| 106 |
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
| 107 |
+
The list of fields to be updated.
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
phrase_set: resource.PhraseSet = proto.Field(
|
| 111 |
+
proto.MESSAGE,
|
| 112 |
+
number=1,
|
| 113 |
+
message=resource.PhraseSet,
|
| 114 |
+
)
|
| 115 |
+
update_mask: field_mask_pb2.FieldMask = proto.Field(
|
| 116 |
+
proto.MESSAGE,
|
| 117 |
+
number=2,
|
| 118 |
+
message=field_mask_pb2.FieldMask,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class GetPhraseSetRequest(proto.Message):
|
| 123 |
+
r"""Message sent by the client for the ``GetPhraseSet`` method.
|
| 124 |
+
|
| 125 |
+
Attributes:
|
| 126 |
+
name (str):
|
| 127 |
+
Required. The name of the phrase set to retrieve. Format:
|
| 128 |
+
|
| 129 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 130 |
+
|
| 131 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 132 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 133 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 134 |
+
location. To specify a region, use a `regional
|
| 135 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 136 |
+
with matching ``us`` or ``eu`` location value.
|
| 137 |
+
"""
|
| 138 |
+
|
| 139 |
+
name: str = proto.Field(
|
| 140 |
+
proto.STRING,
|
| 141 |
+
number=1,
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
class ListPhraseSetRequest(proto.Message):
|
| 146 |
+
r"""Message sent by the client for the ``ListPhraseSet`` method.
|
| 147 |
+
|
| 148 |
+
Attributes:
|
| 149 |
+
parent (str):
|
| 150 |
+
Required. The parent, which owns this collection of phrase
|
| 151 |
+
set. Format:
|
| 152 |
+
|
| 153 |
+
``projects/{project}/locations/{location}``
|
| 154 |
+
|
| 155 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 156 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 157 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 158 |
+
location. To specify a region, use a `regional
|
| 159 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 160 |
+
with matching ``us`` or ``eu`` location value.
|
| 161 |
+
page_size (int):
|
| 162 |
+
The maximum number of phrase sets to return.
|
| 163 |
+
The service may return fewer than this value. If
|
| 164 |
+
unspecified, at most 50 phrase sets will be
|
| 165 |
+
returned. The maximum value is 1000; values
|
| 166 |
+
above 1000 will be coerced to 1000.
|
| 167 |
+
page_token (str):
|
| 168 |
+
A page token, received from a previous ``ListPhraseSet``
|
| 169 |
+
call. Provide this to retrieve the subsequent page.
|
| 170 |
+
|
| 171 |
+
When paginating, all other parameters provided to
|
| 172 |
+
``ListPhraseSet`` must match the call that provided the page
|
| 173 |
+
token.
|
| 174 |
+
"""
|
| 175 |
+
|
| 176 |
+
parent: str = proto.Field(
|
| 177 |
+
proto.STRING,
|
| 178 |
+
number=1,
|
| 179 |
+
)
|
| 180 |
+
page_size: int = proto.Field(
|
| 181 |
+
proto.INT32,
|
| 182 |
+
number=2,
|
| 183 |
+
)
|
| 184 |
+
page_token: str = proto.Field(
|
| 185 |
+
proto.STRING,
|
| 186 |
+
number=3,
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
class ListPhraseSetResponse(proto.Message):
|
| 191 |
+
r"""Message returned to the client by the ``ListPhraseSet`` method.
|
| 192 |
+
|
| 193 |
+
Attributes:
|
| 194 |
+
phrase_sets (MutableSequence[google.cloud.speech_v1p1beta1.types.PhraseSet]):
|
| 195 |
+
The phrase set.
|
| 196 |
+
next_page_token (str):
|
| 197 |
+
A token, which can be sent as ``page_token`` to retrieve the
|
| 198 |
+
next page. If this field is omitted, there are no subsequent
|
| 199 |
+
pages.
|
| 200 |
+
"""
|
| 201 |
+
|
| 202 |
+
@property
|
| 203 |
+
def raw_page(self):
|
| 204 |
+
return self
|
| 205 |
+
|
| 206 |
+
phrase_sets: MutableSequence[resource.PhraseSet] = proto.RepeatedField(
|
| 207 |
+
proto.MESSAGE,
|
| 208 |
+
number=1,
|
| 209 |
+
message=resource.PhraseSet,
|
| 210 |
+
)
|
| 211 |
+
next_page_token: str = proto.Field(
|
| 212 |
+
proto.STRING,
|
| 213 |
+
number=2,
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
class DeletePhraseSetRequest(proto.Message):
|
| 218 |
+
r"""Message sent by the client for the ``DeletePhraseSet`` method.
|
| 219 |
+
|
| 220 |
+
Attributes:
|
| 221 |
+
name (str):
|
| 222 |
+
Required. The name of the phrase set to delete. Format:
|
| 223 |
+
|
| 224 |
+
``projects/{project}/locations/{location}/phraseSets/{phrase_set}``
|
| 225 |
+
"""
|
| 226 |
+
|
| 227 |
+
name: str = proto.Field(
|
| 228 |
+
proto.STRING,
|
| 229 |
+
number=1,
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
class CreateCustomClassRequest(proto.Message):
|
| 234 |
+
r"""Message sent by the client for the ``CreateCustomClass`` method.
|
| 235 |
+
|
| 236 |
+
Attributes:
|
| 237 |
+
parent (str):
|
| 238 |
+
Required. The parent resource where this custom class will
|
| 239 |
+
be created. Format:
|
| 240 |
+
|
| 241 |
+
``projects/{project}/locations/{location}/customClasses``
|
| 242 |
+
|
| 243 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 244 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 245 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 246 |
+
location. To specify a region, use a `regional
|
| 247 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 248 |
+
with matching ``us`` or ``eu`` location value.
|
| 249 |
+
custom_class_id (str):
|
| 250 |
+
Required. The ID to use for the custom class,
|
| 251 |
+
which will become the final component of the
|
| 252 |
+
custom class' resource name.
|
| 253 |
+
|
| 254 |
+
This value should restrict to letters, numbers,
|
| 255 |
+
and hyphens, with the first character a letter,
|
| 256 |
+
the last a letter or a number, and be 4-63
|
| 257 |
+
characters.
|
| 258 |
+
custom_class (google.cloud.speech_v1p1beta1.types.CustomClass):
|
| 259 |
+
Required. The custom class to create.
|
| 260 |
+
"""
|
| 261 |
+
|
| 262 |
+
parent: str = proto.Field(
|
| 263 |
+
proto.STRING,
|
| 264 |
+
number=1,
|
| 265 |
+
)
|
| 266 |
+
custom_class_id: str = proto.Field(
|
| 267 |
+
proto.STRING,
|
| 268 |
+
number=2,
|
| 269 |
+
)
|
| 270 |
+
custom_class: resource.CustomClass = proto.Field(
|
| 271 |
+
proto.MESSAGE,
|
| 272 |
+
number=3,
|
| 273 |
+
message=resource.CustomClass,
|
| 274 |
+
)
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
class UpdateCustomClassRequest(proto.Message):
|
| 278 |
+
r"""Message sent by the client for the ``UpdateCustomClass`` method.
|
| 279 |
+
|
| 280 |
+
Attributes:
|
| 281 |
+
custom_class (google.cloud.speech_v1p1beta1.types.CustomClass):
|
| 282 |
+
Required. The custom class to update.
|
| 283 |
+
|
| 284 |
+
The custom class's ``name`` field is used to identify the
|
| 285 |
+
custom class to be updated. Format:
|
| 286 |
+
|
| 287 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 288 |
+
|
| 289 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 290 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 291 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 292 |
+
location. To specify a region, use a `regional
|
| 293 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 294 |
+
with matching ``us`` or ``eu`` location value.
|
| 295 |
+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
|
| 296 |
+
The list of fields to be updated.
|
| 297 |
+
"""
|
| 298 |
+
|
| 299 |
+
custom_class: resource.CustomClass = proto.Field(
|
| 300 |
+
proto.MESSAGE,
|
| 301 |
+
number=1,
|
| 302 |
+
message=resource.CustomClass,
|
| 303 |
+
)
|
| 304 |
+
update_mask: field_mask_pb2.FieldMask = proto.Field(
|
| 305 |
+
proto.MESSAGE,
|
| 306 |
+
number=2,
|
| 307 |
+
message=field_mask_pb2.FieldMask,
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
class GetCustomClassRequest(proto.Message):
|
| 312 |
+
r"""Message sent by the client for the ``GetCustomClass`` method.
|
| 313 |
+
|
| 314 |
+
Attributes:
|
| 315 |
+
name (str):
|
| 316 |
+
Required. The name of the custom class to retrieve. Format:
|
| 317 |
+
|
| 318 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 319 |
+
"""
|
| 320 |
+
|
| 321 |
+
name: str = proto.Field(
|
| 322 |
+
proto.STRING,
|
| 323 |
+
number=1,
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
class ListCustomClassesRequest(proto.Message):
|
| 328 |
+
r"""Message sent by the client for the ``ListCustomClasses`` method.
|
| 329 |
+
|
| 330 |
+
Attributes:
|
| 331 |
+
parent (str):
|
| 332 |
+
Required. The parent, which owns this collection of custom
|
| 333 |
+
classes. Format:
|
| 334 |
+
|
| 335 |
+
``projects/{project}/locations/{location}/customClasses``
|
| 336 |
+
|
| 337 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 338 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 339 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 340 |
+
location. To specify a region, use a `regional
|
| 341 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 342 |
+
with matching ``us`` or ``eu`` location value.
|
| 343 |
+
page_size (int):
|
| 344 |
+
The maximum number of custom classes to
|
| 345 |
+
return. The service may return fewer than this
|
| 346 |
+
value. If unspecified, at most 50 custom classes
|
| 347 |
+
will be returned. The maximum value is 1000;
|
| 348 |
+
values above 1000 will be coerced to 1000.
|
| 349 |
+
page_token (str):
|
| 350 |
+
A page token, received from a previous ``ListCustomClass``
|
| 351 |
+
call. Provide this to retrieve the subsequent page.
|
| 352 |
+
|
| 353 |
+
When paginating, all other parameters provided to
|
| 354 |
+
``ListCustomClass`` must match the call that provided the
|
| 355 |
+
page token.
|
| 356 |
+
"""
|
| 357 |
+
|
| 358 |
+
parent: str = proto.Field(
|
| 359 |
+
proto.STRING,
|
| 360 |
+
number=1,
|
| 361 |
+
)
|
| 362 |
+
page_size: int = proto.Field(
|
| 363 |
+
proto.INT32,
|
| 364 |
+
number=2,
|
| 365 |
+
)
|
| 366 |
+
page_token: str = proto.Field(
|
| 367 |
+
proto.STRING,
|
| 368 |
+
number=3,
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
class ListCustomClassesResponse(proto.Message):
|
| 373 |
+
r"""Message returned to the client by the ``ListCustomClasses`` method.
|
| 374 |
+
|
| 375 |
+
Attributes:
|
| 376 |
+
custom_classes (MutableSequence[google.cloud.speech_v1p1beta1.types.CustomClass]):
|
| 377 |
+
The custom classes.
|
| 378 |
+
next_page_token (str):
|
| 379 |
+
A token, which can be sent as ``page_token`` to retrieve the
|
| 380 |
+
next page. If this field is omitted, there are no subsequent
|
| 381 |
+
pages.
|
| 382 |
+
"""
|
| 383 |
+
|
| 384 |
+
@property
|
| 385 |
+
def raw_page(self):
|
| 386 |
+
return self
|
| 387 |
+
|
| 388 |
+
custom_classes: MutableSequence[resource.CustomClass] = proto.RepeatedField(
|
| 389 |
+
proto.MESSAGE,
|
| 390 |
+
number=1,
|
| 391 |
+
message=resource.CustomClass,
|
| 392 |
+
)
|
| 393 |
+
next_page_token: str = proto.Field(
|
| 394 |
+
proto.STRING,
|
| 395 |
+
number=2,
|
| 396 |
+
)
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
class DeleteCustomClassRequest(proto.Message):
|
| 400 |
+
r"""Message sent by the client for the ``DeleteCustomClass`` method.
|
| 401 |
+
|
| 402 |
+
Attributes:
|
| 403 |
+
name (str):
|
| 404 |
+
Required. The name of the custom class to delete. Format:
|
| 405 |
+
|
| 406 |
+
``projects/{project}/locations/{location}/customClasses/{custom_class}``
|
| 407 |
+
|
| 408 |
+
Speech-to-Text supports three locations: ``global``, ``us``
|
| 409 |
+
(US North America), and ``eu`` (Europe). If you are calling
|
| 410 |
+
the ``speech.googleapis.com`` endpoint, use the ``global``
|
| 411 |
+
location. To specify a region, use a `regional
|
| 412 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 413 |
+
with matching ``us`` or ``eu`` location value.
|
| 414 |
+
"""
|
| 415 |
+
|
| 416 |
+
name: str = proto.Field(
|
| 417 |
+
proto.STRING,
|
| 418 |
+
number=1,
|
| 419 |
+
)
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
__all__ = tuple(sorted(__protobuf__.manifest))
|
loan-advisor-agent/.venv/Lib/site-packages/google/cloud/speech_v1p1beta1/types/resource.py
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
from typing import MutableMapping, MutableSequence
|
| 19 |
+
|
| 20 |
+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
|
| 21 |
+
import proto # type: ignore
|
| 22 |
+
|
| 23 |
+
__protobuf__ = proto.module(
|
| 24 |
+
package="google.cloud.speech.v1p1beta1",
|
| 25 |
+
manifest={
|
| 26 |
+
"CustomClass",
|
| 27 |
+
"PhraseSet",
|
| 28 |
+
"SpeechAdaptation",
|
| 29 |
+
"TranscriptNormalization",
|
| 30 |
+
},
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class CustomClass(proto.Message):
|
| 35 |
+
r"""A set of words or phrases that represents a common concept
|
| 36 |
+
likely to appear in your audio, for example a list of passenger
|
| 37 |
+
ship names. CustomClass items can be substituted into
|
| 38 |
+
placeholders that you set in PhraseSet phrases.
|
| 39 |
+
|
| 40 |
+
Attributes:
|
| 41 |
+
name (str):
|
| 42 |
+
The resource name of the custom class.
|
| 43 |
+
custom_class_id (str):
|
| 44 |
+
If this custom class is a resource, the custom_class_id is
|
| 45 |
+
the resource id of the CustomClass. Case sensitive.
|
| 46 |
+
items (MutableSequence[google.cloud.speech_v1p1beta1.types.CustomClass.ClassItem]):
|
| 47 |
+
A collection of class items.
|
| 48 |
+
kms_key_name (str):
|
| 49 |
+
Output only. The `KMS key
|
| 50 |
+
name <https://cloud.google.com/kms/docs/resource-hierarchy#keys>`__
|
| 51 |
+
with which the content of the ClassItem is encrypted. The
|
| 52 |
+
expected format is
|
| 53 |
+
``projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}``.
|
| 54 |
+
kms_key_version_name (str):
|
| 55 |
+
Output only. The `KMS key version
|
| 56 |
+
name <https://cloud.google.com/kms/docs/resource-hierarchy#key_versions>`__
|
| 57 |
+
with which content of the ClassItem is encrypted. The
|
| 58 |
+
expected format is
|
| 59 |
+
``projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}``.
|
| 60 |
+
uid (str):
|
| 61 |
+
Output only. System-assigned unique
|
| 62 |
+
identifier for the CustomClass. This field is
|
| 63 |
+
not used.
|
| 64 |
+
display_name (str):
|
| 65 |
+
Output only. User-settable, human-readable
|
| 66 |
+
name for the CustomClass. Must be 63 characters
|
| 67 |
+
or less. This field is not used.
|
| 68 |
+
state (google.cloud.speech_v1p1beta1.types.CustomClass.State):
|
| 69 |
+
Output only. The CustomClass lifecycle state.
|
| 70 |
+
This field is not used.
|
| 71 |
+
delete_time (google.protobuf.timestamp_pb2.Timestamp):
|
| 72 |
+
Output only. The time at which this resource
|
| 73 |
+
was requested for deletion. This field is not
|
| 74 |
+
used.
|
| 75 |
+
expire_time (google.protobuf.timestamp_pb2.Timestamp):
|
| 76 |
+
Output only. The time at which this resource
|
| 77 |
+
will be purged. This field is not used.
|
| 78 |
+
annotations (MutableMapping[str, str]):
|
| 79 |
+
Output only. Allows users to store small
|
| 80 |
+
amounts of arbitrary data. Both the key and the
|
| 81 |
+
value must be 63 characters or less each. At
|
| 82 |
+
most 100 annotations.
|
| 83 |
+
This field is not used.
|
| 84 |
+
etag (str):
|
| 85 |
+
Output only. This checksum is computed by the
|
| 86 |
+
server based on the value of other fields. This
|
| 87 |
+
may be sent on update, undelete, and delete
|
| 88 |
+
requests to ensure the client has an up-to-date
|
| 89 |
+
value before proceeding. This field is not used.
|
| 90 |
+
reconciling (bool):
|
| 91 |
+
Output only. Whether or not this CustomClass
|
| 92 |
+
is in the process of being updated. This field
|
| 93 |
+
is not used.
|
| 94 |
+
"""
|
| 95 |
+
|
| 96 |
+
class State(proto.Enum):
|
| 97 |
+
r"""Set of states that define the lifecycle of a CustomClass.
|
| 98 |
+
|
| 99 |
+
Values:
|
| 100 |
+
STATE_UNSPECIFIED (0):
|
| 101 |
+
Unspecified state. This is only used/useful
|
| 102 |
+
for distinguishing unset values.
|
| 103 |
+
ACTIVE (2):
|
| 104 |
+
The normal and active state.
|
| 105 |
+
DELETED (4):
|
| 106 |
+
This CustomClass has been deleted.
|
| 107 |
+
"""
|
| 108 |
+
|
| 109 |
+
STATE_UNSPECIFIED = 0
|
| 110 |
+
ACTIVE = 2
|
| 111 |
+
DELETED = 4
|
| 112 |
+
|
| 113 |
+
class ClassItem(proto.Message):
|
| 114 |
+
r"""An item of the class.
|
| 115 |
+
|
| 116 |
+
Attributes:
|
| 117 |
+
value (str):
|
| 118 |
+
The class item's value.
|
| 119 |
+
"""
|
| 120 |
+
|
| 121 |
+
value: str = proto.Field(
|
| 122 |
+
proto.STRING,
|
| 123 |
+
number=1,
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
name: str = proto.Field(
|
| 127 |
+
proto.STRING,
|
| 128 |
+
number=1,
|
| 129 |
+
)
|
| 130 |
+
custom_class_id: str = proto.Field(
|
| 131 |
+
proto.STRING,
|
| 132 |
+
number=2,
|
| 133 |
+
)
|
| 134 |
+
items: MutableSequence[ClassItem] = proto.RepeatedField(
|
| 135 |
+
proto.MESSAGE,
|
| 136 |
+
number=3,
|
| 137 |
+
message=ClassItem,
|
| 138 |
+
)
|
| 139 |
+
kms_key_name: str = proto.Field(
|
| 140 |
+
proto.STRING,
|
| 141 |
+
number=6,
|
| 142 |
+
)
|
| 143 |
+
kms_key_version_name: str = proto.Field(
|
| 144 |
+
proto.STRING,
|
| 145 |
+
number=7,
|
| 146 |
+
)
|
| 147 |
+
uid: str = proto.Field(
|
| 148 |
+
proto.STRING,
|
| 149 |
+
number=8,
|
| 150 |
+
)
|
| 151 |
+
display_name: str = proto.Field(
|
| 152 |
+
proto.STRING,
|
| 153 |
+
number=9,
|
| 154 |
+
)
|
| 155 |
+
state: State = proto.Field(
|
| 156 |
+
proto.ENUM,
|
| 157 |
+
number=10,
|
| 158 |
+
enum=State,
|
| 159 |
+
)
|
| 160 |
+
delete_time: timestamp_pb2.Timestamp = proto.Field(
|
| 161 |
+
proto.MESSAGE,
|
| 162 |
+
number=11,
|
| 163 |
+
message=timestamp_pb2.Timestamp,
|
| 164 |
+
)
|
| 165 |
+
expire_time: timestamp_pb2.Timestamp = proto.Field(
|
| 166 |
+
proto.MESSAGE,
|
| 167 |
+
number=12,
|
| 168 |
+
message=timestamp_pb2.Timestamp,
|
| 169 |
+
)
|
| 170 |
+
annotations: MutableMapping[str, str] = proto.MapField(
|
| 171 |
+
proto.STRING,
|
| 172 |
+
proto.STRING,
|
| 173 |
+
number=13,
|
| 174 |
+
)
|
| 175 |
+
etag: str = proto.Field(
|
| 176 |
+
proto.STRING,
|
| 177 |
+
number=14,
|
| 178 |
+
)
|
| 179 |
+
reconciling: bool = proto.Field(
|
| 180 |
+
proto.BOOL,
|
| 181 |
+
number=15,
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
class PhraseSet(proto.Message):
|
| 186 |
+
r"""Provides "hints" to the speech recognizer to favor specific
|
| 187 |
+
words and phrases in the results.
|
| 188 |
+
|
| 189 |
+
Attributes:
|
| 190 |
+
name (str):
|
| 191 |
+
The resource name of the phrase set.
|
| 192 |
+
phrases (MutableSequence[google.cloud.speech_v1p1beta1.types.PhraseSet.Phrase]):
|
| 193 |
+
A list of word and phrases.
|
| 194 |
+
boost (float):
|
| 195 |
+
Hint Boost. Positive value will increase the probability
|
| 196 |
+
that a specific phrase will be recognized over other similar
|
| 197 |
+
sounding phrases. The higher the boost, the higher the
|
| 198 |
+
chance of false positive recognition as well. Negative boost
|
| 199 |
+
values would correspond to anti-biasing. Anti-biasing is not
|
| 200 |
+
enabled, so negative boost will simply be ignored. Though
|
| 201 |
+
``boost`` can accept a wide range of positive values, most
|
| 202 |
+
use cases are best served with values between 0 (exclusive)
|
| 203 |
+
and 20. We recommend using a binary search approach to
|
| 204 |
+
finding the optimal value for your use case as well as
|
| 205 |
+
adding phrases both with and without boost to your requests.
|
| 206 |
+
kms_key_name (str):
|
| 207 |
+
Output only. The `KMS key
|
| 208 |
+
name <https://cloud.google.com/kms/docs/resource-hierarchy#keys>`__
|
| 209 |
+
with which the content of the PhraseSet is encrypted. The
|
| 210 |
+
expected format is
|
| 211 |
+
``projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}``.
|
| 212 |
+
kms_key_version_name (str):
|
| 213 |
+
Output only. The `KMS key version
|
| 214 |
+
name <https://cloud.google.com/kms/docs/resource-hierarchy#key_versions>`__
|
| 215 |
+
with which content of the PhraseSet is encrypted. The
|
| 216 |
+
expected format is
|
| 217 |
+
``projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}``.
|
| 218 |
+
uid (str):
|
| 219 |
+
Output only. System-assigned unique
|
| 220 |
+
identifier for the PhraseSet. This field is not
|
| 221 |
+
used.
|
| 222 |
+
display_name (str):
|
| 223 |
+
Output only. User-settable, human-readable
|
| 224 |
+
name for the PhraseSet. Must be 63 characters or
|
| 225 |
+
less. This field is not used.
|
| 226 |
+
state (google.cloud.speech_v1p1beta1.types.PhraseSet.State):
|
| 227 |
+
Output only. The CustomClass lifecycle state.
|
| 228 |
+
This field is not used.
|
| 229 |
+
delete_time (google.protobuf.timestamp_pb2.Timestamp):
|
| 230 |
+
Output only. The time at which this resource
|
| 231 |
+
was requested for deletion. This field is not
|
| 232 |
+
used.
|
| 233 |
+
expire_time (google.protobuf.timestamp_pb2.Timestamp):
|
| 234 |
+
Output only. The time at which this resource
|
| 235 |
+
will be purged. This field is not used.
|
| 236 |
+
annotations (MutableMapping[str, str]):
|
| 237 |
+
Output only. Allows users to store small
|
| 238 |
+
amounts of arbitrary data. Both the key and the
|
| 239 |
+
value must be 63 characters or less each. At
|
| 240 |
+
most 100 annotations.
|
| 241 |
+
This field is not used.
|
| 242 |
+
etag (str):
|
| 243 |
+
Output only. This checksum is computed by the
|
| 244 |
+
server based on the value of other fields. This
|
| 245 |
+
may be sent on update, undelete, and delete
|
| 246 |
+
requests to ensure the client has an up-to-date
|
| 247 |
+
value before proceeding. This field is not used.
|
| 248 |
+
reconciling (bool):
|
| 249 |
+
Output only. Whether or not this PhraseSet is
|
| 250 |
+
in the process of being updated. This field is
|
| 251 |
+
not used.
|
| 252 |
+
"""
|
| 253 |
+
|
| 254 |
+
class State(proto.Enum):
|
| 255 |
+
r"""Set of states that define the lifecycle of a CustomClass.
|
| 256 |
+
|
| 257 |
+
Values:
|
| 258 |
+
STATE_UNSPECIFIED (0):
|
| 259 |
+
Unspecified state. This is only used/useful
|
| 260 |
+
for distinguishing unset values.
|
| 261 |
+
ACTIVE (2):
|
| 262 |
+
The normal and active state.
|
| 263 |
+
DELETED (4):
|
| 264 |
+
This CustomClass has been deleted.
|
| 265 |
+
"""
|
| 266 |
+
|
| 267 |
+
STATE_UNSPECIFIED = 0
|
| 268 |
+
ACTIVE = 2
|
| 269 |
+
DELETED = 4
|
| 270 |
+
|
| 271 |
+
class Phrase(proto.Message):
|
| 272 |
+
r"""A phrases containing words and phrase "hints" so that the speech
|
| 273 |
+
recognition is more likely to recognize them. This can be used to
|
| 274 |
+
improve the accuracy for specific words and phrases, for example, if
|
| 275 |
+
specific commands are typically spoken by the user. This can also be
|
| 276 |
+
used to add additional words to the vocabulary of the recognizer.
|
| 277 |
+
See `usage
|
| 278 |
+
limits <https://cloud.google.com/speech-to-text/quotas#content>`__.
|
| 279 |
+
|
| 280 |
+
List items can also include pre-built or custom classes containing
|
| 281 |
+
groups of words that represent common concepts that occur in natural
|
| 282 |
+
language. For example, rather than providing a phrase hint for every
|
| 283 |
+
month of the year (e.g. "i was born in january", "i was born in
|
| 284 |
+
febuary", ...), use the pre-built ``$MONTH`` class improves the
|
| 285 |
+
likelihood of correctly transcribing audio that includes months
|
| 286 |
+
(e.g. "i was born in $month"). To refer to pre-built classes, use
|
| 287 |
+
the class' symbol prepended with ``$`` e.g. ``$MONTH``. To refer to
|
| 288 |
+
custom classes that were defined inline in the request, set the
|
| 289 |
+
class's ``custom_class_id`` to a string unique to all class
|
| 290 |
+
resources and inline classes. Then use the class' id wrapped in
|
| 291 |
+
$\ ``{...}`` e.g. "${my-months}". To refer to custom classes
|
| 292 |
+
resources, use the class' id wrapped in ``${}`` (e.g.
|
| 293 |
+
``${my-months}``).
|
| 294 |
+
|
| 295 |
+
Speech-to-Text supports three locations: ``global``, ``us`` (US
|
| 296 |
+
North America), and ``eu`` (Europe). If you are calling the
|
| 297 |
+
``speech.googleapis.com`` endpoint, use the ``global`` location. To
|
| 298 |
+
specify a region, use a `regional
|
| 299 |
+
endpoint <https://cloud.google.com/speech-to-text/docs/endpoints>`__
|
| 300 |
+
with matching ``us`` or ``eu`` location value.
|
| 301 |
+
|
| 302 |
+
Attributes:
|
| 303 |
+
value (str):
|
| 304 |
+
The phrase itself.
|
| 305 |
+
boost (float):
|
| 306 |
+
Hint Boost. Overrides the boost set at the phrase set level.
|
| 307 |
+
Positive value will increase the probability that a specific
|
| 308 |
+
phrase will be recognized over other similar sounding
|
| 309 |
+
phrases. The higher the boost, the higher the chance of
|
| 310 |
+
false positive recognition as well. Negative boost will
|
| 311 |
+
simply be ignored. Though ``boost`` can accept a wide range
|
| 312 |
+
of positive values, most use cases are best served with
|
| 313 |
+
values between 0 and 20. We recommend using a binary search
|
| 314 |
+
approach to finding the optimal value for your use case as
|
| 315 |
+
well as adding phrases both with and without boost to your
|
| 316 |
+
requests.
|
| 317 |
+
"""
|
| 318 |
+
|
| 319 |
+
value: str = proto.Field(
|
| 320 |
+
proto.STRING,
|
| 321 |
+
number=1,
|
| 322 |
+
)
|
| 323 |
+
boost: float = proto.Field(
|
| 324 |
+
proto.FLOAT,
|
| 325 |
+
number=2,
|
| 326 |
+
)
|
| 327 |
+
|
| 328 |
+
name: str = proto.Field(
|
| 329 |
+
proto.STRING,
|
| 330 |
+
number=1,
|
| 331 |
+
)
|
| 332 |
+
phrases: MutableSequence[Phrase] = proto.RepeatedField(
|
| 333 |
+
proto.MESSAGE,
|
| 334 |
+
number=2,
|
| 335 |
+
message=Phrase,
|
| 336 |
+
)
|
| 337 |
+
boost: float = proto.Field(
|
| 338 |
+
proto.FLOAT,
|
| 339 |
+
number=4,
|
| 340 |
+
)
|
| 341 |
+
kms_key_name: str = proto.Field(
|
| 342 |
+
proto.STRING,
|
| 343 |
+
number=7,
|
| 344 |
+
)
|
| 345 |
+
kms_key_version_name: str = proto.Field(
|
| 346 |
+
proto.STRING,
|
| 347 |
+
number=8,
|
| 348 |
+
)
|
| 349 |
+
uid: str = proto.Field(
|
| 350 |
+
proto.STRING,
|
| 351 |
+
number=9,
|
| 352 |
+
)
|
| 353 |
+
display_name: str = proto.Field(
|
| 354 |
+
proto.STRING,
|
| 355 |
+
number=10,
|
| 356 |
+
)
|
| 357 |
+
state: State = proto.Field(
|
| 358 |
+
proto.ENUM,
|
| 359 |
+
number=11,
|
| 360 |
+
enum=State,
|
| 361 |
+
)
|
| 362 |
+
delete_time: timestamp_pb2.Timestamp = proto.Field(
|
| 363 |
+
proto.MESSAGE,
|
| 364 |
+
number=12,
|
| 365 |
+
message=timestamp_pb2.Timestamp,
|
| 366 |
+
)
|
| 367 |
+
expire_time: timestamp_pb2.Timestamp = proto.Field(
|
| 368 |
+
proto.MESSAGE,
|
| 369 |
+
number=13,
|
| 370 |
+
message=timestamp_pb2.Timestamp,
|
| 371 |
+
)
|
| 372 |
+
annotations: MutableMapping[str, str] = proto.MapField(
|
| 373 |
+
proto.STRING,
|
| 374 |
+
proto.STRING,
|
| 375 |
+
number=14,
|
| 376 |
+
)
|
| 377 |
+
etag: str = proto.Field(
|
| 378 |
+
proto.STRING,
|
| 379 |
+
number=15,
|
| 380 |
+
)
|
| 381 |
+
reconciling: bool = proto.Field(
|
| 382 |
+
proto.BOOL,
|
| 383 |
+
number=16,
|
| 384 |
+
)
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
class SpeechAdaptation(proto.Message):
|
| 388 |
+
r"""Speech adaptation configuration.
|
| 389 |
+
|
| 390 |
+
Attributes:
|
| 391 |
+
phrase_sets (MutableSequence[google.cloud.speech_v1p1beta1.types.PhraseSet]):
|
| 392 |
+
A collection of phrase sets. To specify the hints inline,
|
| 393 |
+
leave the phrase set's ``name`` blank and fill in the rest
|
| 394 |
+
of its fields. Any phrase set can use any custom class.
|
| 395 |
+
phrase_set_references (MutableSequence[str]):
|
| 396 |
+
A collection of phrase set resource names to
|
| 397 |
+
use.
|
| 398 |
+
custom_classes (MutableSequence[google.cloud.speech_v1p1beta1.types.CustomClass]):
|
| 399 |
+
A collection of custom classes. To specify the classes
|
| 400 |
+
inline, leave the class' ``name`` blank and fill in the rest
|
| 401 |
+
of its fields, giving it a unique ``custom_class_id``. Refer
|
| 402 |
+
to the inline defined class in phrase hints by its
|
| 403 |
+
``custom_class_id``.
|
| 404 |
+
abnf_grammar (google.cloud.speech_v1p1beta1.types.SpeechAdaptation.ABNFGrammar):
|
| 405 |
+
Augmented Backus-Naur form (ABNF) is a
|
| 406 |
+
standardized grammar notation comprised by a set
|
| 407 |
+
of derivation rules. See specifications:
|
| 408 |
+
https://www.w3.org/TR/speech-grammar
|
| 409 |
+
"""
|
| 410 |
+
|
| 411 |
+
class ABNFGrammar(proto.Message):
|
| 412 |
+
r"""
|
| 413 |
+
|
| 414 |
+
Attributes:
|
| 415 |
+
abnf_strings (MutableSequence[str]):
|
| 416 |
+
All declarations and rules of an ABNF grammar
|
| 417 |
+
broken up into multiple strings that will end up
|
| 418 |
+
concatenated.
|
| 419 |
+
"""
|
| 420 |
+
|
| 421 |
+
abnf_strings: MutableSequence[str] = proto.RepeatedField(
|
| 422 |
+
proto.STRING,
|
| 423 |
+
number=1,
|
| 424 |
+
)
|
| 425 |
+
|
| 426 |
+
phrase_sets: MutableSequence["PhraseSet"] = proto.RepeatedField(
|
| 427 |
+
proto.MESSAGE,
|
| 428 |
+
number=1,
|
| 429 |
+
message="PhraseSet",
|
| 430 |
+
)
|
| 431 |
+
phrase_set_references: MutableSequence[str] = proto.RepeatedField(
|
| 432 |
+
proto.STRING,
|
| 433 |
+
number=2,
|
| 434 |
+
)
|
| 435 |
+
custom_classes: MutableSequence["CustomClass"] = proto.RepeatedField(
|
| 436 |
+
proto.MESSAGE,
|
| 437 |
+
number=3,
|
| 438 |
+
message="CustomClass",
|
| 439 |
+
)
|
| 440 |
+
abnf_grammar: ABNFGrammar = proto.Field(
|
| 441 |
+
proto.MESSAGE,
|
| 442 |
+
number=4,
|
| 443 |
+
message=ABNFGrammar,
|
| 444 |
+
)
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
class TranscriptNormalization(proto.Message):
|
| 448 |
+
r"""Transcription normalization configuration. Use transcription
|
| 449 |
+
normalization to automatically replace parts of the transcript
|
| 450 |
+
with phrases of your choosing. For StreamingRecognize, this
|
| 451 |
+
normalization only applies to stable partial transcripts
|
| 452 |
+
(stability > 0.8) and final transcripts.
|
| 453 |
+
|
| 454 |
+
Attributes:
|
| 455 |
+
entries (MutableSequence[google.cloud.speech_v1p1beta1.types.TranscriptNormalization.Entry]):
|
| 456 |
+
A list of replacement entries. We will perform replacement
|
| 457 |
+
with one entry at a time. For example, the second entry in
|
| 458 |
+
["cat" => "dog", "mountain cat" => "mountain dog"] will
|
| 459 |
+
never be applied because we will always process the first
|
| 460 |
+
entry before it. At most 100 entries.
|
| 461 |
+
"""
|
| 462 |
+
|
| 463 |
+
class Entry(proto.Message):
|
| 464 |
+
r"""A single replacement configuration.
|
| 465 |
+
|
| 466 |
+
Attributes:
|
| 467 |
+
search (str):
|
| 468 |
+
What to replace. Max length is 100
|
| 469 |
+
characters.
|
| 470 |
+
replace (str):
|
| 471 |
+
What to replace with. Max length is 100
|
| 472 |
+
characters.
|
| 473 |
+
case_sensitive (bool):
|
| 474 |
+
Whether the search is case sensitive.
|
| 475 |
+
"""
|
| 476 |
+
|
| 477 |
+
search: str = proto.Field(
|
| 478 |
+
proto.STRING,
|
| 479 |
+
number=1,
|
| 480 |
+
)
|
| 481 |
+
replace: str = proto.Field(
|
| 482 |
+
proto.STRING,
|
| 483 |
+
number=2,
|
| 484 |
+
)
|
| 485 |
+
case_sensitive: bool = proto.Field(
|
| 486 |
+
proto.BOOL,
|
| 487 |
+
number=3,
|
| 488 |
+
)
|
| 489 |
+
|
| 490 |
+
entries: MutableSequence[Entry] = proto.RepeatedField(
|
| 491 |
+
proto.MESSAGE,
|
| 492 |
+
number=1,
|
| 493 |
+
message=Entry,
|
| 494 |
+
)
|
| 495 |
+
|
| 496 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2025 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
import sys
|
| 17 |
+
|
| 18 |
+
import google.api_core as api_core
|
| 19 |
+
|
| 20 |
+
from google.cloud.speech_v2 import gapic_version as package_version
|
| 21 |
+
|
| 22 |
+
__version__ = package_version.__version__
|
| 23 |
+
|
| 24 |
+
if sys.version_info >= (3, 8): # pragma: NO COVER
|
| 25 |
+
from importlib import metadata
|
| 26 |
+
else: # pragma: NO COVER
|
| 27 |
+
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
|
| 28 |
+
# this code path once we drop support for Python 3.7
|
| 29 |
+
import importlib_metadata as metadata
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
from .services.speech import SpeechAsyncClient, SpeechClient
|
| 33 |
+
from .types.cloud_speech import (
|
| 34 |
+
AutoDetectDecodingConfig,
|
| 35 |
+
BatchRecognizeFileMetadata,
|
| 36 |
+
BatchRecognizeFileResult,
|
| 37 |
+
BatchRecognizeMetadata,
|
| 38 |
+
BatchRecognizeRequest,
|
| 39 |
+
BatchRecognizeResponse,
|
| 40 |
+
BatchRecognizeResults,
|
| 41 |
+
BatchRecognizeTranscriptionMetadata,
|
| 42 |
+
CloudStorageResult,
|
| 43 |
+
Config,
|
| 44 |
+
CreateCustomClassRequest,
|
| 45 |
+
CreatePhraseSetRequest,
|
| 46 |
+
CreateRecognizerRequest,
|
| 47 |
+
CustomClass,
|
| 48 |
+
CustomPromptConfig,
|
| 49 |
+
DeleteCustomClassRequest,
|
| 50 |
+
DeletePhraseSetRequest,
|
| 51 |
+
DeleteRecognizerRequest,
|
| 52 |
+
DenoiserConfig,
|
| 53 |
+
ExplicitDecodingConfig,
|
| 54 |
+
GcsOutputConfig,
|
| 55 |
+
GetConfigRequest,
|
| 56 |
+
GetCustomClassRequest,
|
| 57 |
+
GetPhraseSetRequest,
|
| 58 |
+
GetRecognizerRequest,
|
| 59 |
+
InlineOutputConfig,
|
| 60 |
+
InlineResult,
|
| 61 |
+
ListCustomClassesRequest,
|
| 62 |
+
ListCustomClassesResponse,
|
| 63 |
+
ListPhraseSetsRequest,
|
| 64 |
+
ListPhraseSetsResponse,
|
| 65 |
+
ListRecognizersRequest,
|
| 66 |
+
ListRecognizersResponse,
|
| 67 |
+
NativeOutputFileFormatConfig,
|
| 68 |
+
OperationMetadata,
|
| 69 |
+
OutputFormatConfig,
|
| 70 |
+
PhraseSet,
|
| 71 |
+
RecognitionConfig,
|
| 72 |
+
RecognitionFeatures,
|
| 73 |
+
RecognitionOutputConfig,
|
| 74 |
+
RecognitionResponseMetadata,
|
| 75 |
+
Recognizer,
|
| 76 |
+
RecognizeRequest,
|
| 77 |
+
RecognizeResponse,
|
| 78 |
+
SpeakerDiarizationConfig,
|
| 79 |
+
SpeechAdaptation,
|
| 80 |
+
SpeechRecognitionAlternative,
|
| 81 |
+
SpeechRecognitionResult,
|
| 82 |
+
SrtOutputFileFormatConfig,
|
| 83 |
+
StreamingRecognitionConfig,
|
| 84 |
+
StreamingRecognitionFeatures,
|
| 85 |
+
StreamingRecognitionResult,
|
| 86 |
+
StreamingRecognizeRequest,
|
| 87 |
+
StreamingRecognizeResponse,
|
| 88 |
+
TranscriptNormalization,
|
| 89 |
+
TranslationConfig,
|
| 90 |
+
UndeleteCustomClassRequest,
|
| 91 |
+
UndeletePhraseSetRequest,
|
| 92 |
+
UndeleteRecognizerRequest,
|
| 93 |
+
UpdateConfigRequest,
|
| 94 |
+
UpdateCustomClassRequest,
|
| 95 |
+
UpdatePhraseSetRequest,
|
| 96 |
+
UpdateRecognizerRequest,
|
| 97 |
+
VttOutputFileFormatConfig,
|
| 98 |
+
WordInfo,
|
| 99 |
+
)
|
| 100 |
+
from .types.locations_metadata import (
|
| 101 |
+
AccessMetadata,
|
| 102 |
+
LanguageMetadata,
|
| 103 |
+
LocationsMetadata,
|
| 104 |
+
ModelFeature,
|
| 105 |
+
ModelFeatures,
|
| 106 |
+
ModelMetadata,
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
if hasattr(api_core, "check_python_version") and hasattr(
|
| 110 |
+
api_core, "check_dependency_versions"
|
| 111 |
+
): # pragma: NO COVER
|
| 112 |
+
api_core.check_python_version("google.cloud.speech_v2") # type: ignore
|
| 113 |
+
api_core.check_dependency_versions("google.cloud.speech_v2") # type: ignore
|
| 114 |
+
else: # pragma: NO COVER
|
| 115 |
+
# An older version of api_core is installed which does not define the
|
| 116 |
+
# functions above. We do equivalent checks manually.
|
| 117 |
+
try:
|
| 118 |
+
import sys
|
| 119 |
+
import warnings
|
| 120 |
+
|
| 121 |
+
_py_version_str = sys.version.split()[0]
|
| 122 |
+
_package_label = "google.cloud.speech_v2"
|
| 123 |
+
if sys.version_info < (3, 9):
|
| 124 |
+
warnings.warn(
|
| 125 |
+
"You are using a non-supported Python version "
|
| 126 |
+
+ f"({_py_version_str}). Google will not post any further "
|
| 127 |
+
+ f"updates to {_package_label} supporting this Python version. "
|
| 128 |
+
+ "Please upgrade to the latest Python version, or at "
|
| 129 |
+
+ f"least to Python 3.9, and then update {_package_label}.",
|
| 130 |
+
FutureWarning,
|
| 131 |
+
)
|
| 132 |
+
if sys.version_info[:2] == (3, 9):
|
| 133 |
+
warnings.warn(
|
| 134 |
+
f"You are using a Python version ({_py_version_str}) "
|
| 135 |
+
+ f"which Google will stop supporting in {_package_label} in "
|
| 136 |
+
+ "January 2026. Please "
|
| 137 |
+
+ "upgrade to the latest Python version, or at "
|
| 138 |
+
+ "least to Python 3.10, before then, and "
|
| 139 |
+
+ f"then update {_package_label}.",
|
| 140 |
+
FutureWarning,
|
| 141 |
+
)
|
| 142 |
+
|
| 143 |
+
def parse_version_to_tuple(version_string: str):
|
| 144 |
+
"""Safely converts a semantic version string to a comparable tuple of integers.
|
| 145 |
+
Example: "4.25.8" -> (4, 25, 8)
|
| 146 |
+
Ignores non-numeric parts and handles common version formats.
|
| 147 |
+
Args:
|
| 148 |
+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
|
| 149 |
+
Returns:
|
| 150 |
+
Tuple of integers for the parsed version string.
|
| 151 |
+
"""
|
| 152 |
+
parts = []
|
| 153 |
+
for part in version_string.split("."):
|
| 154 |
+
try:
|
| 155 |
+
parts.append(int(part))
|
| 156 |
+
except ValueError:
|
| 157 |
+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
|
| 158 |
+
# This is a simplification compared to 'packaging.parse_version', but sufficient
|
| 159 |
+
# for comparing strictly numeric semantic versions.
|
| 160 |
+
break
|
| 161 |
+
return tuple(parts)
|
| 162 |
+
|
| 163 |
+
def _get_version(dependency_name):
|
| 164 |
+
try:
|
| 165 |
+
version_string: str = metadata.version(dependency_name)
|
| 166 |
+
parsed_version = parse_version_to_tuple(version_string)
|
| 167 |
+
return (parsed_version, version_string)
|
| 168 |
+
except Exception:
|
| 169 |
+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
|
| 170 |
+
# or errors during parse_version_to_tuple
|
| 171 |
+
return (None, "--")
|
| 172 |
+
|
| 173 |
+
_dependency_package = "google.protobuf"
|
| 174 |
+
_next_supported_version = "4.25.8"
|
| 175 |
+
_next_supported_version_tuple = (4, 25, 8)
|
| 176 |
+
_recommendation = " (we recommend 6.x)"
|
| 177 |
+
(_version_used, _version_used_string) = _get_version(_dependency_package)
|
| 178 |
+
if _version_used and _version_used < _next_supported_version_tuple:
|
| 179 |
+
warnings.warn(
|
| 180 |
+
f"Package {_package_label} depends on "
|
| 181 |
+
+ f"{_dependency_package}, currently installed at version "
|
| 182 |
+
+ f"{_version_used_string}. Future updates to "
|
| 183 |
+
+ f"{_package_label} will require {_dependency_package} at "
|
| 184 |
+
+ f"version {_next_supported_version} or higher{_recommendation}."
|
| 185 |
+
+ " Please ensure "
|
| 186 |
+
+ "that either (a) your Python environment doesn't pin the "
|
| 187 |
+
+ f"version of {_dependency_package}, so that updates to "
|
| 188 |
+
+ f"{_package_label} can require the higher version, or "
|
| 189 |
+
+ "(b) you manually update your Python environment to use at "
|
| 190 |
+
+ f"least version {_next_supported_version} of "
|
| 191 |
+
+ f"{_dependency_package}.",
|
| 192 |
+
FutureWarning,
|
| 193 |
+
)
|
| 194 |
+
except Exception:
|
| 195 |
+
warnings.warn(
|
| 196 |
+
"Could not determine the version of Python "
|
| 197 |
+
+ "currently being used. To continue receiving "
|
| 198 |
+
+ "updates for {_package_label}, ensure you are "
|
| 199 |
+
+ "using a supported version of Python; see "
|
| 200 |
+
+ "https://devguide.python.org/versions/"
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
__all__ = (
|
| 204 |
+
"SpeechAsyncClient",
|
| 205 |
+
"AccessMetadata",
|
| 206 |
+
"AutoDetectDecodingConfig",
|
| 207 |
+
"BatchRecognizeFileMetadata",
|
| 208 |
+
"BatchRecognizeFileResult",
|
| 209 |
+
"BatchRecognizeMetadata",
|
| 210 |
+
"BatchRecognizeRequest",
|
| 211 |
+
"BatchRecognizeResponse",
|
| 212 |
+
"BatchRecognizeResults",
|
| 213 |
+
"BatchRecognizeTranscriptionMetadata",
|
| 214 |
+
"CloudStorageResult",
|
| 215 |
+
"Config",
|
| 216 |
+
"CreateCustomClassRequest",
|
| 217 |
+
"CreatePhraseSetRequest",
|
| 218 |
+
"CreateRecognizerRequest",
|
| 219 |
+
"CustomClass",
|
| 220 |
+
"CustomPromptConfig",
|
| 221 |
+
"DeleteCustomClassRequest",
|
| 222 |
+
"DeletePhraseSetRequest",
|
| 223 |
+
"DeleteRecognizerRequest",
|
| 224 |
+
"DenoiserConfig",
|
| 225 |
+
"ExplicitDecodingConfig",
|
| 226 |
+
"GcsOutputConfig",
|
| 227 |
+
"GetConfigRequest",
|
| 228 |
+
"GetCustomClassRequest",
|
| 229 |
+
"GetPhraseSetRequest",
|
| 230 |
+
"GetRecognizerRequest",
|
| 231 |
+
"InlineOutputConfig",
|
| 232 |
+
"InlineResult",
|
| 233 |
+
"LanguageMetadata",
|
| 234 |
+
"ListCustomClassesRequest",
|
| 235 |
+
"ListCustomClassesResponse",
|
| 236 |
+
"ListPhraseSetsRequest",
|
| 237 |
+
"ListPhraseSetsResponse",
|
| 238 |
+
"ListRecognizersRequest",
|
| 239 |
+
"ListRecognizersResponse",
|
| 240 |
+
"LocationsMetadata",
|
| 241 |
+
"ModelFeature",
|
| 242 |
+
"ModelFeatures",
|
| 243 |
+
"ModelMetadata",
|
| 244 |
+
"NativeOutputFileFormatConfig",
|
| 245 |
+
"OperationMetadata",
|
| 246 |
+
"OutputFormatConfig",
|
| 247 |
+
"PhraseSet",
|
| 248 |
+
"RecognitionConfig",
|
| 249 |
+
"RecognitionFeatures",
|
| 250 |
+
"RecognitionOutputConfig",
|
| 251 |
+
"RecognitionResponseMetadata",
|
| 252 |
+
"RecognizeRequest",
|
| 253 |
+
"RecognizeResponse",
|
| 254 |
+
"Recognizer",
|
| 255 |
+
"SpeakerDiarizationConfig",
|
| 256 |
+
"SpeechAdaptation",
|
| 257 |
+
"SpeechClient",
|
| 258 |
+
"SpeechRecognitionAlternative",
|
| 259 |
+
"SpeechRecognitionResult",
|
| 260 |
+
"SrtOutputFileFormatConfig",
|
| 261 |
+
"StreamingRecognitionConfig",
|
| 262 |
+
"StreamingRecognitionFeatures",
|
| 263 |
+
"StreamingRecognitionResult",
|
| 264 |
+
"StreamingRecognizeRequest",
|
| 265 |
+
"StreamingRecognizeResponse",
|
| 266 |
+
"TranscriptNormalization",
|
| 267 |
+
"TranslationConfig",
|
| 268 |
+
"UndeleteCustomClassRequest",
|
| 269 |
+
"UndeletePhraseSetRequest",
|
| 270 |
+
"UndeleteRecognizerRequest",
|
| 271 |
+
"UpdateConfigRequest",
|
| 272 |
+
"UpdateCustomClassRequest",
|
| 273 |
+
"UpdatePhraseSetRequest",
|
| 274 |
+
"UpdateRecognizerRequest",
|
| 275 |
+
"VttOutputFileFormatConfig",
|
| 276 |
+
"WordInfo",
|
| 277 |
+
)
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
|
| 3 |
+
"language": "python",
|
| 4 |
+
"libraryPackage": "google.cloud.speech_v2",
|
| 5 |
+
"protoPackage": "google.cloud.speech.v2",
|
| 6 |
+
"schema": "1.0",
|
| 7 |
+
"services": {
|
| 8 |
+
"Speech": {
|
| 9 |
+
"clients": {
|
| 10 |
+
"grpc": {
|
| 11 |
+
"libraryClient": "SpeechClient",
|
| 12 |
+
"rpcs": {
|
| 13 |
+
"BatchRecognize": {
|
| 14 |
+
"methods": [
|
| 15 |
+
"batch_recognize"
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
"CreateCustomClass": {
|
| 19 |
+
"methods": [
|
| 20 |
+
"create_custom_class"
|
| 21 |
+
]
|
| 22 |
+
},
|
| 23 |
+
"CreatePhraseSet": {
|
| 24 |
+
"methods": [
|
| 25 |
+
"create_phrase_set"
|
| 26 |
+
]
|
| 27 |
+
},
|
| 28 |
+
"CreateRecognizer": {
|
| 29 |
+
"methods": [
|
| 30 |
+
"create_recognizer"
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
"DeleteCustomClass": {
|
| 34 |
+
"methods": [
|
| 35 |
+
"delete_custom_class"
|
| 36 |
+
]
|
| 37 |
+
},
|
| 38 |
+
"DeletePhraseSet": {
|
| 39 |
+
"methods": [
|
| 40 |
+
"delete_phrase_set"
|
| 41 |
+
]
|
| 42 |
+
},
|
| 43 |
+
"DeleteRecognizer": {
|
| 44 |
+
"methods": [
|
| 45 |
+
"delete_recognizer"
|
| 46 |
+
]
|
| 47 |
+
},
|
| 48 |
+
"GetConfig": {
|
| 49 |
+
"methods": [
|
| 50 |
+
"get_config"
|
| 51 |
+
]
|
| 52 |
+
},
|
| 53 |
+
"GetCustomClass": {
|
| 54 |
+
"methods": [
|
| 55 |
+
"get_custom_class"
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"GetPhraseSet": {
|
| 59 |
+
"methods": [
|
| 60 |
+
"get_phrase_set"
|
| 61 |
+
]
|
| 62 |
+
},
|
| 63 |
+
"GetRecognizer": {
|
| 64 |
+
"methods": [
|
| 65 |
+
"get_recognizer"
|
| 66 |
+
]
|
| 67 |
+
},
|
| 68 |
+
"ListCustomClasses": {
|
| 69 |
+
"methods": [
|
| 70 |
+
"list_custom_classes"
|
| 71 |
+
]
|
| 72 |
+
},
|
| 73 |
+
"ListPhraseSets": {
|
| 74 |
+
"methods": [
|
| 75 |
+
"list_phrase_sets"
|
| 76 |
+
]
|
| 77 |
+
},
|
| 78 |
+
"ListRecognizers": {
|
| 79 |
+
"methods": [
|
| 80 |
+
"list_recognizers"
|
| 81 |
+
]
|
| 82 |
+
},
|
| 83 |
+
"Recognize": {
|
| 84 |
+
"methods": [
|
| 85 |
+
"recognize"
|
| 86 |
+
]
|
| 87 |
+
},
|
| 88 |
+
"StreamingRecognize": {
|
| 89 |
+
"methods": [
|
| 90 |
+
"streaming_recognize"
|
| 91 |
+
]
|
| 92 |
+
},
|
| 93 |
+
"UndeleteCustomClass": {
|
| 94 |
+
"methods": [
|
| 95 |
+
"undelete_custom_class"
|
| 96 |
+
]
|
| 97 |
+
},
|
| 98 |
+
"UndeletePhraseSet": {
|
| 99 |
+
"methods": [
|
| 100 |
+
"undelete_phrase_set"
|
| 101 |
+
]
|
| 102 |
+
},
|
| 103 |
+
"UndeleteRecognizer": {
|
| 104 |
+
"methods": [
|
| 105 |
+
"undelete_recognizer"
|
| 106 |
+
]
|
| 107 |
+
},
|
| 108 |
+
"UpdateConfig": {
|
| 109 |
+
"methods": [
|
| 110 |
+
"update_config"
|
| 111 |
+
]
|
| 112 |
+
},
|
| 113 |
+
"UpdateCustomClass": {
|
| 114 |
+
"methods": [
|
| 115 |
+
"update_custom_class"
|
| 116 |
+
]
|
| 117 |
+
},
|
| 118 |
+
"UpdatePhraseSet": {
|
| 119 |
+
"methods": [
|
| 120 |
+
"update_phrase_set"
|
| 121 |
+
]
|
| 122 |
+
},
|
| 123 |
+
"UpdateRecognizer": {
|
| 124 |
+
"methods": [
|
| 125 |
+
"update_recognizer"
|
| 126 |
+
]
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
"grpc-async": {
|
| 131 |
+
"libraryClient": "SpeechAsyncClient",
|
| 132 |
+
"rpcs": {
|
| 133 |
+
"BatchRecognize": {
|
| 134 |
+
"methods": [
|
| 135 |
+
"batch_recognize"
|
| 136 |
+
]
|
| 137 |
+
},
|
| 138 |
+
"CreateCustomClass": {
|
| 139 |
+
"methods": [
|
| 140 |
+
"create_custom_class"
|
| 141 |
+
]
|
| 142 |
+
},
|
| 143 |
+
"CreatePhraseSet": {
|
| 144 |
+
"methods": [
|
| 145 |
+
"create_phrase_set"
|
| 146 |
+
]
|
| 147 |
+
},
|
| 148 |
+
"CreateRecognizer": {
|
| 149 |
+
"methods": [
|
| 150 |
+
"create_recognizer"
|
| 151 |
+
]
|
| 152 |
+
},
|
| 153 |
+
"DeleteCustomClass": {
|
| 154 |
+
"methods": [
|
| 155 |
+
"delete_custom_class"
|
| 156 |
+
]
|
| 157 |
+
},
|
| 158 |
+
"DeletePhraseSet": {
|
| 159 |
+
"methods": [
|
| 160 |
+
"delete_phrase_set"
|
| 161 |
+
]
|
| 162 |
+
},
|
| 163 |
+
"DeleteRecognizer": {
|
| 164 |
+
"methods": [
|
| 165 |
+
"delete_recognizer"
|
| 166 |
+
]
|
| 167 |
+
},
|
| 168 |
+
"GetConfig": {
|
| 169 |
+
"methods": [
|
| 170 |
+
"get_config"
|
| 171 |
+
]
|
| 172 |
+
},
|
| 173 |
+
"GetCustomClass": {
|
| 174 |
+
"methods": [
|
| 175 |
+
"get_custom_class"
|
| 176 |
+
]
|
| 177 |
+
},
|
| 178 |
+
"GetPhraseSet": {
|
| 179 |
+
"methods": [
|
| 180 |
+
"get_phrase_set"
|
| 181 |
+
]
|
| 182 |
+
},
|
| 183 |
+
"GetRecognizer": {
|
| 184 |
+
"methods": [
|
| 185 |
+
"get_recognizer"
|
| 186 |
+
]
|
| 187 |
+
},
|
| 188 |
+
"ListCustomClasses": {
|
| 189 |
+
"methods": [
|
| 190 |
+
"list_custom_classes"
|
| 191 |
+
]
|
| 192 |
+
},
|
| 193 |
+
"ListPhraseSets": {
|
| 194 |
+
"methods": [
|
| 195 |
+
"list_phrase_sets"
|
| 196 |
+
]
|
| 197 |
+
},
|
| 198 |
+
"ListRecognizers": {
|
| 199 |
+
"methods": [
|
| 200 |
+
"list_recognizers"
|
| 201 |
+
]
|
| 202 |
+
},
|
| 203 |
+
"Recognize": {
|
| 204 |
+
"methods": [
|
| 205 |
+
"recognize"
|
| 206 |
+
]
|
| 207 |
+
},
|
| 208 |
+
"StreamingRecognize": {
|
| 209 |
+
"methods": [
|
| 210 |
+
"streaming_recognize"
|
| 211 |
+
]
|
| 212 |
+
},
|
| 213 |
+
"UndeleteCustomClass": {
|
| 214 |
+
"methods": [
|
| 215 |
+
"undelete_custom_class"
|
| 216 |
+
]
|
| 217 |
+
},
|
| 218 |
+
"UndeletePhraseSet": {
|
| 219 |
+
"methods": [
|
| 220 |
+
"undelete_phrase_set"
|
| 221 |
+
]
|
| 222 |
+
},
|
| 223 |
+
"UndeleteRecognizer": {
|
| 224 |
+
"methods": [
|
| 225 |
+
"undelete_recognizer"
|
| 226 |
+
]
|
| 227 |
+
},
|
| 228 |
+
"UpdateConfig": {
|
| 229 |
+
"methods": [
|
| 230 |
+
"update_config"
|
| 231 |
+
]
|
| 232 |
+
},
|
| 233 |
+
"UpdateCustomClass": {
|
| 234 |
+
"methods": [
|
| 235 |
+
"update_custom_class"
|
| 236 |
+
]
|
| 237 |
+
},
|
| 238 |
+
"UpdatePhraseSet": {
|
| 239 |
+
"methods": [
|
| 240 |
+
"update_phrase_set"
|
| 241 |
+
]
|
| 242 |
+
},
|
| 243 |
+
"UpdateRecognizer": {
|
| 244 |
+
"methods": [
|
| 245 |
+
"update_recognizer"
|
| 246 |
+
]
|
| 247 |
+
}
|
| 248 |
+
}
|
| 249 |
+
},
|
| 250 |
+
"rest": {
|
| 251 |
+
"libraryClient": "SpeechClient",
|
| 252 |
+
"rpcs": {
|
| 253 |
+
"BatchRecognize": {
|
| 254 |
+
"methods": [
|
| 255 |
+
"batch_recognize"
|
| 256 |
+
]
|
| 257 |
+
},
|
| 258 |
+
"CreateCustomClass": {
|
| 259 |
+
"methods": [
|
| 260 |
+
"create_custom_class"
|
| 261 |
+
]
|
| 262 |
+
},
|
| 263 |
+
"CreatePhraseSet": {
|
| 264 |
+
"methods": [
|
| 265 |
+
"create_phrase_set"
|
| 266 |
+
]
|
| 267 |
+
},
|
| 268 |
+
"CreateRecognizer": {
|
| 269 |
+
"methods": [
|
| 270 |
+
"create_recognizer"
|
| 271 |
+
]
|
| 272 |
+
},
|
| 273 |
+
"DeleteCustomClass": {
|
| 274 |
+
"methods": [
|
| 275 |
+
"delete_custom_class"
|
| 276 |
+
]
|
| 277 |
+
},
|
| 278 |
+
"DeletePhraseSet": {
|
| 279 |
+
"methods": [
|
| 280 |
+
"delete_phrase_set"
|
| 281 |
+
]
|
| 282 |
+
},
|
| 283 |
+
"DeleteRecognizer": {
|
| 284 |
+
"methods": [
|
| 285 |
+
"delete_recognizer"
|
| 286 |
+
]
|
| 287 |
+
},
|
| 288 |
+
"GetConfig": {
|
| 289 |
+
"methods": [
|
| 290 |
+
"get_config"
|
| 291 |
+
]
|
| 292 |
+
},
|
| 293 |
+
"GetCustomClass": {
|
| 294 |
+
"methods": [
|
| 295 |
+
"get_custom_class"
|
| 296 |
+
]
|
| 297 |
+
},
|
| 298 |
+
"GetPhraseSet": {
|
| 299 |
+
"methods": [
|
| 300 |
+
"get_phrase_set"
|
| 301 |
+
]
|
| 302 |
+
},
|
| 303 |
+
"GetRecognizer": {
|
| 304 |
+
"methods": [
|
| 305 |
+
"get_recognizer"
|
| 306 |
+
]
|
| 307 |
+
},
|
| 308 |
+
"ListCustomClasses": {
|
| 309 |
+
"methods": [
|
| 310 |
+
"list_custom_classes"
|
| 311 |
+
]
|
| 312 |
+
},
|
| 313 |
+
"ListPhraseSets": {
|
| 314 |
+
"methods": [
|
| 315 |
+
"list_phrase_sets"
|
| 316 |
+
]
|
| 317 |
+
},
|
| 318 |
+
"ListRecognizers": {
|
| 319 |
+
"methods": [
|
| 320 |
+
"list_recognizers"
|
| 321 |
+
]
|
| 322 |
+
},
|
| 323 |
+
"Recognize": {
|
| 324 |
+
"methods": [
|
| 325 |
+
"recognize"
|
| 326 |
+
]
|
| 327 |
+
},
|
| 328 |
+
"StreamingRecognize": {
|
| 329 |
+
"methods": [
|
| 330 |
+
"streaming_recognize"
|
| 331 |
+
]
|
| 332 |
+
},
|
| 333 |
+
"UndeleteCustomClass": {
|
| 334 |
+
"methods": [
|
| 335 |
+
"undelete_custom_class"
|
| 336 |
+
]
|
| 337 |
+
},
|
| 338 |
+
"UndeletePhraseSet": {
|
| 339 |
+
"methods": [
|
| 340 |
+
"undelete_phrase_set"
|
| 341 |
+
]
|
| 342 |
+
},
|
| 343 |
+
"UndeleteRecognizer": {
|
| 344 |
+
"methods": [
|
| 345 |
+
"undelete_recognizer"
|
| 346 |
+
]
|
| 347 |
+
},
|
| 348 |
+
"UpdateConfig": {
|
| 349 |
+
"methods": [
|
| 350 |
+
"update_config"
|
| 351 |
+
]
|
| 352 |
+
},
|
| 353 |
+
"UpdateCustomClass": {
|
| 354 |
+
"methods": [
|
| 355 |
+
"update_custom_class"
|
| 356 |
+
]
|
| 357 |
+
},
|
| 358 |
+
"UpdatePhraseSet": {
|
| 359 |
+
"methods": [
|
| 360 |
+
"update_phrase_set"
|
| 361 |
+
]
|
| 362 |
+
},
|
| 363 |
+
"UpdateRecognizer": {
|
| 364 |
+
"methods": [
|
| 365 |
+
"update_recognizer"
|
| 366 |
+
]
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
}
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
}
|
| 373 |
+
}
|