Skip to content

Commit

Permalink
feat: [google-cloud-speech] add locations metadata proto file (#12917)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

BEGIN_COMMIT_OVERRIDE
feat: [google-cloud-speech] add locations metadata proto file
docs: update the list of automatically detected encodings
docs: update the maximum number of files that may be included in a
BatchRecognizeRequest
END_COMMIT_OVERRIDE

PiperOrigin-RevId: 653986958

Source-Link:
googleapis/googleapis@58cd55f

Source-Link:
googleapis/googleapis-gen@7d99f9c
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNwZWVjaC8uT3dsQm90LnlhbWwiLCJoIjoiN2Q5OWY5YzFkMWViMTEzZjU5YzAwZDUyZDc0YjJjZTA2YzE4ZWMyYiJ9

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Victor Chudnovsky <vchudnov@google.com>
  • Loading branch information
3 people authored Jul 23, 2024
1 parent 7b156ee commit a6b3bc7
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.26.1" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.26.1" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.26.1" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
14 changes: 14 additions & 0 deletions packages/google-cloud-speech/google/cloud/speech_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,18 @@
VttOutputFileFormatConfig,
WordInfo,
)
from .types.locations_metadata import (
AccessMetadata,
LanguageMetadata,
LocationsMetadata,
ModelFeature,
ModelFeatures,
ModelMetadata,
)

__all__ = (
"SpeechAsyncClient",
"AccessMetadata",
"AutoDetectDecodingConfig",
"BatchRecognizeFileMetadata",
"BatchRecognizeFileResult",
Expand All @@ -112,12 +121,17 @@
"GetRecognizerRequest",
"InlineOutputConfig",
"InlineResult",
"LanguageMetadata",
"ListCustomClassesRequest",
"ListCustomClassesResponse",
"ListPhraseSetsRequest",
"ListPhraseSetsResponse",
"ListRecognizersRequest",
"ListRecognizersResponse",
"LocationsMetadata",
"ModelFeature",
"ModelFeatures",
"ModelMetadata",
"NativeOutputFileFormatConfig",
"OperationMetadata",
"OutputFormatConfig",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.26.1" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ async def sample_batch_recognize():
files (:class:`MutableSequence[google.cloud.speech_v2.types.BatchRecognizeFileMetadata]`):
Audio files with file metadata for
ASR. The maximum number of files allowed
to be specified is 5.
to be specified is 15.
This corresponds to the ``files`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ def sample_batch_recognize():
files (MutableSequence[google.cloud.speech_v2.types.BatchRecognizeFileMetadata]):
Audio files with file metadata for
ASR. The maximum number of files allowed
to be specified is 5.
to be specified is 15.
This corresponds to the ``files`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
VttOutputFileFormatConfig,
WordInfo,
)
from .locations_metadata import (
AccessMetadata,
LanguageMetadata,
LocationsMetadata,
ModelFeature,
ModelFeatures,
ModelMetadata,
)

__all__ = (
"AutoDetectDecodingConfig",
Expand Down Expand Up @@ -143,4 +151,10 @@
"UpdateRecognizerRequest",
"VttOutputFileFormatConfig",
"WordInfo",
"AccessMetadata",
"LanguageMetadata",
"LocationsMetadata",
"ModelFeature",
"ModelFeatures",
"ModelMetadata",
)
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,11 @@ class AutoDetectDecodingConfig(proto.Message):
- WEBM_OPUS: Opus audio frames in a WebM container.
- M4A: M4A audio format.
- MP4_AAC: AAC audio frames in an MP4 container.
- M4A_AAC: AAC audio frames in an M4A container.
- MOV_AAC: AAC audio frames in an MOV container.
"""

Expand Down Expand Up @@ -1347,11 +1351,18 @@ class RecognitionResponseMetadata(proto.Message):
r"""Metadata about the recognition request and response.
Attributes:
request_id (str):
Global request identifier auto-generated by
the API.
total_billed_duration (google.protobuf.duration_pb2.Duration):
When available, billed audio seconds for the
corresponding request.
"""

request_id: str = proto.Field(
proto.STRING,
number=9,
)
total_billed_duration: duration_pb2.Duration = proto.Field(
proto.MESSAGE,
number=6,
Expand Down Expand Up @@ -1757,7 +1768,7 @@ class BatchRecognizeRequest(proto.Message):
files (MutableSequence[google.cloud.speech_v2.types.BatchRecognizeFileMetadata]):
Audio files with file metadata for ASR.
The maximum number of files allowed to be
specified is 5.
specified is 15.
recognition_output_config (google.cloud.speech_v2.types.RecognitionOutputConfig):
Configuration options for where to output the
transcripts of each file.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# -*- coding: utf-8 -*-
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import annotations

from typing import MutableMapping, MutableSequence

import proto # type: ignore

__protobuf__ = proto.module(
package="google.cloud.speech.v2",
manifest={
"ModelFeature",
"ModelFeatures",
"ModelMetadata",
"LanguageMetadata",
"AccessMetadata",
"LocationsMetadata",
},
)


class ModelFeature(proto.Message):
r"""Representes a singular feature of a model. If the feature is
``recognizer``, the release_state of the feature represents the
release_state of the model
Attributes:
feature (str):
The name of the feature (Note: the feature can be
``recognizer``)
release_state (str):
The release state of the feature
"""

feature: str = proto.Field(
proto.STRING,
number=1,
)
release_state: str = proto.Field(
proto.STRING,
number=2,
)


class ModelFeatures(proto.Message):
r"""Represents the collection of features belonging to a model
Attributes:
model_feature (MutableSequence[google.cloud.speech_v2.types.ModelFeature]):
Repeated field that contains all features of
the model
"""

model_feature: MutableSequence["ModelFeature"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="ModelFeature",
)


class ModelMetadata(proto.Message):
r"""The metadata about the models in a given region for a
specific locale. Currently this is just the features of the
model
Attributes:
model_features (MutableMapping[str, google.cloud.speech_v2.types.ModelFeatures]):
Map of the model name -> features of that
model
"""

model_features: MutableMapping[str, "ModelFeatures"] = proto.MapField(
proto.STRING,
proto.MESSAGE,
number=1,
message="ModelFeatures",
)


class LanguageMetadata(proto.Message):
r"""The metadata about locales available in a given region.
Currently this is just the models that are available for each
locale
Attributes:
models (MutableMapping[str, google.cloud.speech_v2.types.ModelMetadata]):
Map of locale (language code) -> models
"""

models: MutableMapping[str, "ModelMetadata"] = proto.MapField(
proto.STRING,
proto.MESSAGE,
number=1,
message="ModelMetadata",
)


class AccessMetadata(proto.Message):
r"""The access metadata for a particular region. This can be
applied if the org policy for the given project disallows a
particular region.
Attributes:
constraint_type (google.cloud.speech_v2.types.AccessMetadata.ConstraintType):
Describes the different types of constraints
that are applied.
"""

class ConstraintType(proto.Enum):
r"""Describes the different types of constraints that can be
applied on a region.
Values:
CONSTRAINT_TYPE_UNSPECIFIED (0):
Unspecified constraint applied.
RESOURCE_LOCATIONS_ORG_POLICY_CREATE_CONSTRAINT (1):
The project's org policy disallows the given
region.
"""
CONSTRAINT_TYPE_UNSPECIFIED = 0
RESOURCE_LOCATIONS_ORG_POLICY_CREATE_CONSTRAINT = 1

constraint_type: ConstraintType = proto.Field(
proto.ENUM,
number=1,
enum=ConstraintType,
)


class LocationsMetadata(proto.Message):
r"""Main metadata for the Locations API for STT V2. Currently
this is just the metadata about locales, models, and features
Attributes:
languages (google.cloud.speech_v2.types.LanguageMetadata):
Information about available locales, models,
and features represented in the hierarchical
structure of locales -> models -> features
access_metadata (google.cloud.speech_v2.types.AccessMetadata):
Information about access metadata for the
region and given project.
"""

languages: "LanguageMetadata" = proto.Field(
proto.MESSAGE,
number=1,
message="LanguageMetadata",
)
access_metadata: "AccessMetadata" = proto.Field(
proto.MESSAGE,
number=2,
message="AccessMetadata",
)


__all__ = tuple(sorted(__protobuf__.manifest))
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-speech",
"version": "2.26.1"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-speech",
"version": "2.26.1"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-speech",
"version": "2.26.1"
"version": "0.1.0"
},
"snippets": [
{
Expand Down

0 comments on commit a6b3bc7

Please sign in to comment.