Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore

from google.cloud.speech_v1p1beta1.services.adaptation import pagers
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
Expand Down Expand Up @@ -75,6 +76,12 @@ class AdaptationAsyncClient:
_DEFAULT_ENDPOINT_TEMPLATE = AdaptationClient._DEFAULT_ENDPOINT_TEMPLATE
_DEFAULT_UNIVERSE = AdaptationClient._DEFAULT_UNIVERSE

crypto_key_path = staticmethod(AdaptationClient.crypto_key_path)
parse_crypto_key_path = staticmethod(AdaptationClient.parse_crypto_key_path)
crypto_key_version_path = staticmethod(AdaptationClient.crypto_key_version_path)
parse_crypto_key_version_path = staticmethod(
AdaptationClient.parse_crypto_key_version_path
)
custom_class_path = staticmethod(AdaptationClient.custom_class_path)
parse_custom_class_path = staticmethod(AdaptationClient.parse_custom_class_path)
phrase_set_path = staticmethod(AdaptationClient.phrase_set_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore

from google.cloud.speech_v1p1beta1.services.adaptation import pagers
from google.cloud.speech_v1p1beta1.types import cloud_speech_adaptation, resource
Expand Down Expand Up @@ -196,6 +197,56 @@ def transport(self) -> AdaptationTransport:
"""
return self._transport

@staticmethod
def crypto_key_path(
project: str,
location: str,
key_ring: str,
crypto_key: str,
) -> str:
"""Returns a fully-qualified crypto_key string."""
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format(
project=project,
location=location,
key_ring=key_ring,
crypto_key=crypto_key,
)

@staticmethod
def parse_crypto_key_path(path: str) -> Dict[str, str]:
"""Parses a crypto_key path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def crypto_key_version_path(
project: str,
location: str,
key_ring: str,
crypto_key: str,
crypto_key_version: str,
) -> str:
"""Returns a fully-qualified crypto_key_version string."""
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format(
project=project,
location=location,
key_ring=key_ring,
crypto_key=crypto_key,
crypto_key_version=crypto_key_version,
)

@staticmethod
def parse_crypto_key_version_path(path: str) -> Dict[str, str]:
"""Parses a crypto_key_version path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)/cryptoKeyVersions/(?P<crypto_key_version>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def custom_class_path(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ class SpeechAsyncClient:
_DEFAULT_ENDPOINT_TEMPLATE = SpeechClient._DEFAULT_ENDPOINT_TEMPLATE
_DEFAULT_UNIVERSE = SpeechClient._DEFAULT_UNIVERSE

crypto_key_path = staticmethod(SpeechClient.crypto_key_path)
parse_crypto_key_path = staticmethod(SpeechClient.parse_crypto_key_path)
crypto_key_version_path = staticmethod(SpeechClient.crypto_key_version_path)
parse_crypto_key_version_path = staticmethod(
SpeechClient.parse_crypto_key_version_path
)
custom_class_path = staticmethod(SpeechClient.custom_class_path)
parse_custom_class_path = staticmethod(SpeechClient.parse_custom_class_path)
phrase_set_path = staticmethod(SpeechClient.phrase_set_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,56 @@ def transport(self) -> SpeechTransport:
"""
return self._transport

@staticmethod
def crypto_key_path(
project: str,
location: str,
key_ring: str,
crypto_key: str,
) -> str:
"""Returns a fully-qualified crypto_key string."""
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format(
project=project,
location=location,
key_ring=key_ring,
crypto_key=crypto_key,
)

@staticmethod
def parse_crypto_key_path(path: str) -> Dict[str, str]:
"""Parses a crypto_key path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def crypto_key_version_path(
project: str,
location: str,
key_ring: str,
crypto_key: str,
crypto_key_version: str,
) -> str:
"""Returns a fully-qualified crypto_key_version string."""
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}".format(
project=project,
location=location,
key_ring=key_ring,
crypto_key=crypto_key,
crypto_key_version=crypto_key_version,
)

@staticmethod
def parse_crypto_key_version_path(path: str) -> Dict[str, str]:
"""Parses a crypto_key_version path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)/cryptoKeyVersions/(?P<crypto_key_version>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def custom_class_path(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ class StreamingRecognitionConfig(proto.Message):

The ``single_utterance`` field can only be used with
specified models, otherwise an error is thrown. The
``model`` field in [``RecognitionConfig``][] must be set to:
``model`` field in
[RecognitionConfig][google.cloud.speech.v1p1beta1.RecognitionConfig]
must be set to:

- ``command_and_search``
- ``phone_call`` AND additional field
Expand Down Expand Up @@ -360,7 +362,7 @@ class RecognitionConfig(proto.Message):
documentation. When speech adaptation is set it supersedes
the ``speech_contexts`` field.
transcript_normalization (google.cloud.speech_v1p1beta1.types.TranscriptNormalization):
Use transcription normalization to
Optional. Use transcription normalization to
automatically replace parts of the transcript
with phrases of your choosing. For
StreamingRecognize, this normalization only
Expand Down Expand Up @@ -409,7 +411,7 @@ class RecognitionConfig(proto.Message):
enable_speaker_diarization (bool):
If 'true', enables speaker detection for each recognized
word in the top alternative of the recognition result using
a speaker_tag provided in the WordInfo. Note: Use
a speaker_label provided in the WordInfo. Note: Use
diarization_config instead.
diarization_speaker_count (int):
If set, specifies the estimated number of speakers in the
Expand Down Expand Up @@ -576,9 +578,12 @@ class AudioEncoding(proto.Enum):
file being used.
WEBM_OPUS (9):
Opus encoded audio frames in WebM container
(`OggOpus <https://wiki.xiph.org/OggOpus>`__).
(`WebM <https://www.webmproject.org/docs/container/>`__).
``sample_rate_hertz`` must be one of 8000, 12000, 16000,
24000, or 48000.
ALAW (10):
8-bit samples that compand 13-bit audio
samples using G.711 PCMU/a-law.
"""
ENCODING_UNSPECIFIED = 0
LINEAR16 = 1
Expand All @@ -590,6 +595,7 @@ class AudioEncoding(proto.Enum):
SPEEX_WITH_HEADER_BYTE = 7
MP3 = 8
WEBM_OPUS = 9
ALAW = 10

encoding: AudioEncoding = proto.Field(
proto.ENUM,
Expand Down Expand Up @@ -696,7 +702,7 @@ class SpeakerDiarizationConfig(proto.Message):
enable_speaker_diarization (bool):
If 'true', enables speaker detection for each recognized
word in the top alternative of the recognition result using
a speaker_tag provided in the WordInfo.
a speaker_label provided in the WordInfo.
min_speaker_count (int):
Minimum number of speakers in the
conversation. This range gives you more
Expand Down Expand Up @@ -1042,6 +1048,10 @@ class RecognizeResponse(proto.Message):
request_id (int):
The ID associated with the request. This is a
unique ID specific only to the given request.
using_legacy_models (bool):
Whether request used legacy asr models (was
not automatically migrated to use conformer
models).
"""

results: MutableSequence["SpeechRecognitionResult"] = proto.RepeatedField(
Expand All @@ -1063,6 +1073,10 @@ class RecognizeResponse(proto.Message):
proto.INT64,
number=8,
)
using_legacy_models: bool = proto.Field(
proto.BOOL,
number=9,
)


class LongRunningRecognizeResponse(proto.Message):
Expand Down Expand Up @@ -1523,8 +1537,17 @@ class WordInfo(proto.Message):
speaker within the audio. This field specifies which one of
those speakers was detected to have spoken this word. Value
ranges from '1' to diarization_speaker_count. speaker_tag is
set if enable_speaker_diarization = 'true' and only in the
top alternative.
set if enable_speaker_diarization = 'true' and only for the
top alternative. Note: Use speaker_label instead.
speaker_label (str):
Output only. A label value assigned for every unique speaker
within the audio. This field specifies which speaker was
detected to have spoken this word. For some models, like
medical_conversation this can be actual speaker role, for
example "patient" or "provider", but generally this would be
a number identifying a speaker. This field is only set if
enable_speaker_diarization = 'true' and only for the top
alternative.
"""

start_time: duration_pb2.Duration = proto.Field(
Expand All @@ -1549,6 +1572,10 @@ class WordInfo(proto.Message):
proto.INT32,
number=5,
)
speaker_label: str = proto.Field(
proto.STRING,
number=6,
)


class SpeechAdaptationInfo(proto.Message):
Expand Down
Loading