Class SpeechClient (2.20.1)

SpeechClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.speech_v2.services.speech.transports.base.SpeechTransport]] = None, client_options: typing.Optional[typing.Union[google.api_core.client_options.ClientOptions, dict]] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)

Enables speech transcription and resource management.

Properties

transport

Returns the transport used by the client instance.

Returns
TypeDescription
SpeechTransportThe transport used by the client instance.

Methods

SpeechClient

SpeechClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.speech_v2.services.speech.transports.base.SpeechTransport]] = None, client_options: typing.Optional[typing.Union[google.api_core.client_options.ClientOptions, dict]] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)

Instantiates the speech client.

Parameters
NameDescription
credentials Optional[google.auth.credentials.Credentials]

The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.

transport Union[str, SpeechTransport]

The transport to use. If set to None, a transport is chosen automatically.

client_options Optional[Union[google.api_core.client_options.ClientOptions, dict]]

Custom options for the client. It won't take effect if a transport instance is provided. (1) The api_endpoint property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: "always" (always use the default mTLS endpoint), "never" (always use the default regular endpoint) and "auto" (auto switch to the default mTLS endpoint if client certificate is present, this is the default value). However, the api_endpoint property takes precedence if provided. (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is "true", then the client_cert_source property can be used to provide client certificate for mutual TLS transport. If not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not set, no client certificate will be used.

client_info google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

Exceptions
TypeDescription
google.auth.exceptions.MutualTLSChannelErrorIf mutual TLS transport creation failed for any reason.

__exit__

__exit__(type, value, traceback)

Releases underlying transport's resources.

batch_recognize

batch_recognize(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.BatchRecognizeRequest, dict
        ]
    ] = None,
    *,
    recognizer: typing.Optional[str] = None,
    config: typing.Optional[
        google.cloud.speech_v2.types.cloud_speech.RecognitionConfig
    ] = None,
    config_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None,
    files: typing.Optional[
        typing.MutableSequence[
            google.cloud.speech_v2.types.cloud_speech.BatchRecognizeFileMetadata
        ]
    ] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Performs batch asynchronous speech recognition: send a request with N audio files and receive a long running operation that can be polled to see when the transcriptions are finished.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_batch_recognize():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.BatchRecognizeRequest(
        recognizer="recognizer_value",
    )

    # Make the request
    operation = client.batch_recognize(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.BatchRecognizeRequest, dict]

The request object. Request message for the BatchRecognize method.

recognizer str

Required. Resource name of the recognizer to be used for ASR. This corresponds to the recognizer field on the request instance; if request is provided, this should not be set.

config google.cloud.speech_v2.types.RecognitionConfig

Features and audio metadata to use for the Automatic Speech Recognition. This field in combination with the config_mask field can be used to override parts of the default_recognition_config of the Recognizer resource. This corresponds to the config field on the request instance; if request is provided, this should not be set.

config_mask google.protobuf.field_mask_pb2.FieldMask

The list of fields in config that override the values in the default_recognition_config of the recognizer during this recognition request. If no mask is provided, all given fields in config override the values in the recognizer for this recognition request. If a mask is provided, only the fields listed in the mask override the config in the recognizer for this recognition request. If a wildcard (*) is provided, config completely overrides and replaces the config in the recognizer for this recognition request. This corresponds to the config_mask field on the request instance; if request is provided, this should not be set.

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. This corresponds to the files field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be BatchRecognizeResponse Response message for BatchRecognize that is packaged into a longrunning Operation][google.longrunning.Operation].

cancel_operation

cancel_operation(
    request: typing.Optional[
        google.longrunning.operations_pb2.CancelOperationRequest
    ] = None,
    *,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> None

Starts asynchronous cancellation on a long-running operation.

The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.

Parameters
NameDescription
request .operations_pb2.CancelOperationRequest

The request object. Request message for CancelOperation method.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

common_billing_account_path

common_billing_account_path(billing_account: str) -> str

Returns a fully-qualified billing_account string.

common_folder_path

common_folder_path(folder: str) -> str

Returns a fully-qualified folder string.

common_location_path

common_location_path(project: str, location: str) -> str

Returns a fully-qualified location string.

common_organization_path

common_organization_path(organization: str) -> str

Returns a fully-qualified organization string.

common_project_path

common_project_path(project: str) -> str

Returns a fully-qualified project string.

config_path

config_path(project: str, location: str) -> str

Returns a fully-qualified config string.

create_custom_class

create_custom_class(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.CreateCustomClassRequest, dict
        ]
    ] = None,
    *,
    parent: typing.Optional[str] = None,
    custom_class: typing.Optional[
        google.cloud.speech_v2.types.cloud_speech.CustomClass
    ] = None,
    custom_class_id: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Creates a xref_CustomClass.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_create_custom_class():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.CreateCustomClassRequest(
        parent="parent_value",
    )

    # Make the request
    operation = client.create_custom_class(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.CreateCustomClassRequest, dict]

The request object. Request message for the CreateCustomClass method.

parent str

Required. The project and location where this CustomClass will be created. The expected format is projects/{project}/locations/{location}. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

custom_class google.cloud.speech_v2.types.CustomClass

Required. The CustomClass to create. This corresponds to the custom_class field on the request instance; if request is provided, this should not be set.

custom_class_id str

The ID to use for the CustomClass, which will become the final component of the CustomClass's resource name. This value should be 4-63 characters, and valid characters are /a-z][0-9]-/. This corresponds to the custom_class_id field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be CustomClass CustomClass for biasing in speech recognition. Used to define a set of words or phrases that represents a common concept or theme likely to appear in your audio, for example a list of passenger ship names.

create_phrase_set

create_phrase_set(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.CreatePhraseSetRequest, dict
        ]
    ] = None,
    *,
    parent: typing.Optional[str] = None,
    phrase_set: typing.Optional[
        google.cloud.speech_v2.types.cloud_speech.PhraseSet
    ] = None,
    phrase_set_id: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Creates a xref_PhraseSet.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_create_phrase_set():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.CreatePhraseSetRequest(
        parent="parent_value",
    )

    # Make the request
    operation = client.create_phrase_set(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.CreatePhraseSetRequest, dict]

The request object. Request message for the CreatePhraseSet method.

parent str

Required. The project and location where this PhraseSet will be created. The expected format is projects/{project}/locations/{location}. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

phrase_set google.cloud.speech_v2.types.PhraseSet

Required. The PhraseSet to create. This corresponds to the phrase_set field on the request instance; if request is provided, this should not be set.

phrase_set_id str

The ID to use for the PhraseSet, which will become the final component of the PhraseSet's resource name. This value should be 4-63 characters, and valid characters are /a-z][0-9]-/. This corresponds to the phrase_set_id field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be PhraseSet PhraseSet for biasing in speech recognition. A PhraseSet is used to provide "hints" to the speech recognizer to favor specific words and phrases in the results.

create_recognizer

create_recognizer(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.CreateRecognizerRequest, dict
        ]
    ] = None,
    *,
    parent: typing.Optional[str] = None,
    recognizer: typing.Optional[
        google.cloud.speech_v2.types.cloud_speech.Recognizer
    ] = None,
    recognizer_id: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Creates a xref_Recognizer.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_create_recognizer():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    recognizer = speech_v2.Recognizer()
    recognizer.model = "model_value"
    recognizer.language_codes = ['language_codes_value1', 'language_codes_value2']

    request = speech_v2.CreateRecognizerRequest(
        recognizer=recognizer,
        parent="parent_value",
    )

    # Make the request
    operation = client.create_recognizer(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.CreateRecognizerRequest, dict]

The request object. Request message for the CreateRecognizer method.

parent str

Required. The project and location where this Recognizer will be created. The expected format is projects/{project}/locations/{location}. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

recognizer google.cloud.speech_v2.types.Recognizer

Required. The Recognizer to create. This corresponds to the recognizer field on the request instance; if request is provided, this should not be set.

recognizer_id str

The ID to use for the Recognizer, which will become the final component of the Recognizer's resource name. This value should be 4-63 characters, and valid characters are /a-z][0-9]-/. This corresponds to the recognizer_id field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be Recognizer A Recognizer message. Stores recognition configuration and metadata.

crypto_key_path

crypto_key_path(project: str, location: str, key_ring: str, crypto_key: str) -> str

Returns a fully-qualified crypto_key string.

crypto_key_version_path

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.

custom_class_path

custom_class_path(project: str, location: str, custom_class: str) -> str

Returns a fully-qualified custom_class string.

delete_custom_class

delete_custom_class(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.DeleteCustomClassRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Deletes the xref_CustomClass.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_delete_custom_class():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.DeleteCustomClassRequest(
        name="name_value",
    )

    # Make the request
    operation = client.delete_custom_class(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.DeleteCustomClassRequest, dict]

The request object. Request message for the DeleteCustomClass method.

name str

Required. The name of the CustomClass to delete. Format: projects/{project}/locations/{location}/customClasses/{custom_class} This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be CustomClass CustomClass for biasing in speech recognition. Used to define a set of words or phrases that represents a common concept or theme likely to appear in your audio, for example a list of passenger ship names.

delete_operation

delete_operation(
    request: typing.Optional[
        google.longrunning.operations_pb2.DeleteOperationRequest
    ] = None,
    *,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> None

Deletes a long-running operation.

This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.

Parameters
NameDescription
request .operations_pb2.DeleteOperationRequest

The request object. Request message for DeleteOperation method.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

delete_phrase_set

delete_phrase_set(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.DeletePhraseSetRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Deletes the xref_PhraseSet.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_delete_phrase_set():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.DeletePhraseSetRequest(
        name="name_value",
    )

    # Make the request
    operation = client.delete_phrase_set(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.DeletePhraseSetRequest, dict]

The request object. Request message for the DeletePhraseSet method.

name str

Required. The name of the PhraseSet to delete. Format: projects/{project}/locations/{location}/phraseSets/{phrase_set} This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be PhraseSet PhraseSet for biasing in speech recognition. A PhraseSet is used to provide "hints" to the speech recognizer to favor specific words and phrases in the results.

delete_recognizer

delete_recognizer(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.DeleteRecognizerRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Deletes the xref_Recognizer.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_delete_recognizer():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.DeleteRecognizerRequest(
        name="name_value",
    )

    # Make the request
    operation = client.delete_recognizer(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.DeleteRecognizerRequest, dict]

The request object. Request message for the DeleteRecognizer method.

name str

Required. The name of the Recognizer to delete. Format: projects/{project}/locations/{location}/recognizers/{recognizer} This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be Recognizer A Recognizer message. Stores recognition configuration and metadata.

from_service_account_file

from_service_account_file(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
SpeechClientThe constructed client.

from_service_account_info

from_service_account_info(info: dict, *args, **kwargs)

Creates an instance of this client using the provided credentials info.

Parameter
NameDescription
info dict

The service account private key info.

Returns
TypeDescription
SpeechClientThe constructed client.

from_service_account_json

from_service_account_json(filename: str, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
SpeechClientThe constructed client.

get_config

get_config(
    request: typing.Optional[
        typing.Union[google.cloud.speech_v2.types.cloud_speech.GetConfigRequest, dict]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.types.cloud_speech.Config

Returns the requested xref_Config.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_get_config():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.GetConfigRequest(
        name="name_value",
    )

    # Make the request
    response = client.get_config(request=request)

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.GetConfigRequest, dict]

The request object. Request message for the GetConfig method.

name str

Required. The name of the config to retrieve. There is exactly one config resource per project per location. The expected format is projects/{project}/locations/{location}/config. This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.types.ConfigMessage representing the config for the Speech-to-Text API. This includes an optional [KMS key](\ https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which incoming data will be encrypted.

get_custom_class

get_custom_class(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.GetCustomClassRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.types.cloud_speech.CustomClass

Returns the requested xref_CustomClass.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_get_custom_class():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.GetCustomClassRequest(
        name="name_value",
    )

    # Make the request
    response = client.get_custom_class(request=request)

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.GetCustomClassRequest, dict]

The request object. Request message for the GetCustomClass method.

name str

Required. The name of the CustomClass to retrieve. The expected format is projects/{project}/locations/{location}/customClasses/{custom_class}. This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.types.CustomClassCustomClass for biasing in speech recognition. Used to define a set of words or phrases that represents a common concept or theme likely to appear in your audio, for example a list of passenger ship names.

get_location

get_location(
    request: typing.Optional[
        google.cloud.location.locations_pb2.GetLocationRequest
    ] = None,
    *,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.location.locations_pb2.Location

Gets information about a location.

Parameters
NameDescription
request .location_pb2.GetLocationRequest

The request object. Request message for GetLocation method.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.location_pb2.LocationLocation object.

get_mtls_endpoint_and_cert_source

get_mtls_endpoint_and_cert_source(
    client_options: typing.Optional[
        google.api_core.client_options.ClientOptions
    ] = None,
)

Return the API endpoint and client cert source for mutual TLS.

The client cert source is determined in the following order: (1) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is not "true", the client cert source is None. (2) if client_options.client_cert_source is provided, use the provided one; if the default client cert source exists, use the default one; otherwise the client cert source is None.

The API endpoint is determined in the following order: (1) if client_options.api_endpoint if provided, use the provided one. (2) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is "always", use the default mTLS endpoint; if the environment variable is "never", use the default API endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise use the default API endpoint.

More details can be found at https://google.aip.dev/auth/4114.

Parameter
NameDescription
client_options google.api_core.client_options.ClientOptions

Custom options for the client. Only the api_endpoint and client_cert_source properties may be used in this method.

Exceptions
TypeDescription
google.auth.exceptions.MutualTLSChannelErrorIf any errors happen.
Returns
TypeDescription
Tuple[str, Callable[[], Tuple[bytes, bytes]]]returns the API endpoint and the client cert source to use.

get_operation

get_operation(
    request: typing.Optional[
        google.longrunning.operations_pb2.GetOperationRequest
    ] = None,
    *,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.longrunning.operations_pb2.Operation

Gets the latest state of a long-running operation.

Parameters
NameDescription
request .operations_pb2.GetOperationRequest

The request object. Request message for GetOperation method.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.operations_pb2.OperationAn Operation object.

get_phrase_set

get_phrase_set(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.GetPhraseSetRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.types.cloud_speech.PhraseSet

Returns the requested xref_PhraseSet.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_get_phrase_set():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.GetPhraseSetRequest(
        name="name_value",
    )

    # Make the request
    response = client.get_phrase_set(request=request)

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.GetPhraseSetRequest, dict]

The request object. Request message for the GetPhraseSet method.

name str

Required. The name of the PhraseSet to retrieve. The expected format is projects/{project}/locations/{location}/phraseSets/{phrase_set}. This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.types.PhraseSetPhraseSet for biasing in speech recognition. A PhraseSet is used to provide "hints" to the speech recognizer to favor specific words and phrases in the results.

get_recognizer

get_recognizer(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.GetRecognizerRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.types.cloud_speech.Recognizer

Returns the requested xref_Recognizer. Fails with NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested Recognizer doesn't exist.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_get_recognizer():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.GetRecognizerRequest(
        name="name_value",
    )

    # Make the request
    response = client.get_recognizer(request=request)

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.GetRecognizerRequest, dict]

The request object. Request message for the GetRecognizer method.

name str

Required. The name of the Recognizer to retrieve. The expected format is projects/{project}/locations/{location}/recognizers/{recognizer}. This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.types.RecognizerA Recognizer message. Stores recognition configuration and metadata.

list_custom_classes

list_custom_classes(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.ListCustomClassesRequest, dict
        ]
    ] = None,
    *,
    parent: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.services.speech.pagers.ListCustomClassesPager

Lists CustomClasses.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_list_custom_classes():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.ListCustomClassesRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_custom_classes(request=request)

    # Handle the response
    for response in page_result:
        print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.ListCustomClassesRequest, dict]

The request object. Request message for the ListCustomClasses method.

parent str

Required. The project and location of CustomClass resources to list. The expected format is projects/{project}/locations/{location}. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.services.speech.pagers.ListCustomClassesPagerResponse message for the ListCustomClasses method. Iterating over this object will yield results and resolve additional pages automatically.

list_locations

list_locations(
    request: typing.Optional[
        google.cloud.location.locations_pb2.ListLocationsRequest
    ] = None,
    *,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.location.locations_pb2.ListLocationsResponse

Lists information about the supported locations for this service.

Parameters
NameDescription
request .location_pb2.ListLocationsRequest

The request object. Request message for ListLocations method.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.location_pb2.ListLocationsResponseResponse message for ListLocations method.

list_operations

list_operations(
    request: typing.Optional[
        google.longrunning.operations_pb2.ListOperationsRequest
    ] = None,
    *,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.longrunning.operations_pb2.ListOperationsResponse

Lists operations that match the specified filter in the request.

Parameters
NameDescription
request .operations_pb2.ListOperationsRequest

The request object. Request message for ListOperations method.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
.operations_pb2.ListOperationsResponseResponse message for ListOperations method.

list_phrase_sets

list_phrase_sets(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.ListPhraseSetsRequest, dict
        ]
    ] = None,
    *,
    parent: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.services.speech.pagers.ListPhraseSetsPager

Lists PhraseSets.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_list_phrase_sets():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.ListPhraseSetsRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_phrase_sets(request=request)

    # Handle the response
    for response in page_result:
        print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.ListPhraseSetsRequest, dict]

The request object. Request message for the ListPhraseSets method.

parent str

Required. The project and location of PhraseSet resources to list. The expected format is projects/{project}/locations/{location}. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.services.speech.pagers.ListPhraseSetsPagerResponse message for the ListPhraseSets method. Iterating over this object will yield results and resolve additional pages automatically.

list_recognizers

list_recognizers(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.ListRecognizersRequest, dict
        ]
    ] = None,
    *,
    parent: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.services.speech.pagers.ListRecognizersPager

Lists Recognizers.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_list_recognizers():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.ListRecognizersRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_recognizers(request=request)

    # Handle the response
    for response in page_result:
        print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.ListRecognizersRequest, dict]

The request object. Request message for the ListRecognizers method.

parent str

Required. The project and location of Recognizers to list. The expected format is projects/{project}/locations/{location}. This corresponds to the parent field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.services.speech.pagers.ListRecognizersPagerResponse message for the ListRecognizers method. Iterating over this object will yield results and resolve additional pages automatically.

parse_common_billing_account_path

parse_common_billing_account_path(path: str) -> typing.Dict[str, str]

Parse a billing_account path into its component segments.

parse_common_folder_path

parse_common_folder_path(path: str) -> typing.Dict[str, str]

Parse a folder path into its component segments.

parse_common_location_path

parse_common_location_path(path: str) -> typing.Dict[str, str]

Parse a location path into its component segments.

parse_common_organization_path

parse_common_organization_path(path: str) -> typing.Dict[str, str]

Parse a organization path into its component segments.

parse_common_project_path

parse_common_project_path(path: str) -> typing.Dict[str, str]

Parse a project path into its component segments.

parse_config_path

parse_config_path(path: str) -> typing.Dict[str, str]

Parses a config path into its component segments.

parse_crypto_key_path

parse_crypto_key_path(path: str) -> typing.Dict[str, str]

Parses a crypto_key path into its component segments.

parse_crypto_key_version_path

parse_crypto_key_version_path(path: str) -> typing.Dict[str, str]

Parses a crypto_key_version path into its component segments.

parse_custom_class_path

parse_custom_class_path(path: str) -> typing.Dict[str, str]

Parses a custom_class path into its component segments.

parse_phrase_set_path

parse_phrase_set_path(path: str) -> typing.Dict[str, str]

Parses a phrase_set path into its component segments.

parse_recognizer_path

parse_recognizer_path(path: str) -> typing.Dict[str, str]

Parses a recognizer path into its component segments.

phrase_set_path

phrase_set_path(project: str, location: str, phrase_set: str) -> str

Returns a fully-qualified phrase_set string.

recognize

recognize(
    request: typing.Optional[
        typing.Union[google.cloud.speech_v2.types.cloud_speech.RecognizeRequest, dict]
    ] = None,
    *,
    recognizer: typing.Optional[str] = None,
    config: typing.Optional[
        google.cloud.speech_v2.types.cloud_speech.RecognitionConfig
    ] = None,
    config_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None,
    content: typing.Optional[bytes] = None,
    uri: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.types.cloud_speech.RecognizeResponse

Performs synchronous Speech recognition: receive results after all audio has been sent and processed.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_recognize():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.RecognizeRequest(
        content=b'content_blob',
        recognizer="recognizer_value",
    )

    # Make the request
    response = client.recognize(request=request)

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.RecognizeRequest, dict]

The request object. Request message for the Recognize method. Either content or uri must be supplied. Supplying both or neither returns INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See content limits https://cloud.google.com/speech-to-text/quotas#content__.

recognizer str

Required. The name of the Recognizer to use during recognition. The expected format is projects/{project}/locations/{location}/recognizers/{recognizer}. This corresponds to the recognizer field on the request instance; if request is provided, this should not be set.

config google.cloud.speech_v2.types.RecognitionConfig

Features and audio metadata to use for the Automatic Speech Recognition. This field in combination with the config_mask field can be used to override parts of the default_recognition_config of the Recognizer resource. This corresponds to the config field on the request instance; if request is provided, this should not be set.

config_mask google.protobuf.field_mask_pb2.FieldMask

The list of fields in config that override the values in the default_recognition_config of the recognizer during this recognition request. If no mask is provided, all non-default valued fields in config override the values in the recognizer for this recognition request. If a mask is provided, only the fields listed in the mask override the config in the recognizer for this recognition request. If a wildcard (*) is provided, config completely overrides and replaces the config in the recognizer for this recognition request. This corresponds to the config_mask field on the request instance; if request is provided, this should not be set.

content bytes

The audio data bytes encoded as specified in RecognitionConfig. As with all bytes fields, proto buffers use a pure binary representation, whereas JSON representations use base64. This corresponds to the content field on the request instance; if request is provided, this should not be set.

uri str

URI that points to a file that contains audio data bytes as specified in RecognitionConfig. The file must not be compressed (for example, gzip). Currently, only Google Cloud Storage URIs are supported, which must be specified in the following format: gs://bucket_name/object_name (other URI formats return INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see Request URIs https://cloud.google.com/storage/docs/reference-uris__. This corresponds to the uri field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.types.RecognizeResponseResponse message for the Recognize method.

recognizer_path

recognizer_path(project: str, location: str, recognizer: str) -> str

Returns a fully-qualified recognizer string.

streaming_recognize

streaming_recognize(
    requests: typing.Optional[
        typing.Iterator[
            google.cloud.speech_v2.types.cloud_speech.StreamingRecognizeRequest
        ]
    ] = None,
    *,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> typing.Iterable[
    google.cloud.speech_v2.types.cloud_speech.StreamingRecognizeResponse
]

Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only available via the gRPC API (not REST).

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_streaming_recognize():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.StreamingRecognizeRequest(
        recognizer="recognizer_value",
    )

    # This method expects an iterator which contains
    # 'speech_v2.StreamingRecognizeRequest' objects
    # Here we create a generator that yields a single `request` for
    # demonstrative purposes.
    requests = [request]

    def request_generator():
        for request in requests:
            yield request

    # Make the request
    stream = client.streaming_recognize(requests=request_generator())

    # Handle the response
    for response in stream:
        print(response)
Parameters
NameDescription
requests Iterator[google.cloud.speech_v2.types.StreamingRecognizeRequest]

The request object iterator. Request message for the StreamingRecognize method. Multiple StreamingRecognizeRequest messages are sent. The first message must contain a recognizer and optionally a streaming_config message and must not contain audio. All subsequent messages must contain audio and must not contain a streaming_config message.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
Iterable[google.cloud.speech_v2.types.StreamingRecognizeResponse]StreamingRecognizeResponse is the only message returned to the client by StreamingRecognize. A series of zero or more StreamingRecognizeResponse messages are streamed back to the client. If there is no recognizable audio then no messages are streamed back to the client. Here are some examples of StreamingRecognizeResponses that might be returned while processing audio: 1. results { alternatives { transcript: "tube" } stability: 0.01 } 2. results { alternatives { transcript: "to be a" } stability: 0.01 } 3. results { alternatives { transcript: "to be" } stability: 0.9 } results { alternatives { transcript: " or not to be" } stability: 0.01 } 4. results { alternatives { transcript: "to be or not to be" confidence: 0.92 } alternatives { transcript: "to bee or not to bee" } is_final: true } 5. results { alternatives { transcript: " that's" } stability: 0.01 } 6. results { alternatives { transcript: " that is" } stability: 0.9 } results { alternatives { transcript: " the question" } stability: 0.01 } 7. results { alternatives { transcript: " that is the question" confidence: 0.98 } alternatives { transcript: " that was the question" } is_final: true } Notes: - Only two of the above responses #4 and #7 contain final results; they are indicated by is_final: true. Concatenating these together generates the full transcript: "to be or not to be that is the question". - The others contain interim results. #3 and #6 contain two interim \results: the first portion has a high stability and is less likely to change; the second portion has a low stability and is very likely to change. A UI designer might choose to show only high stability results. - The specific stability and confidence values shown above are only for illustrative purposes. Actual values may vary. - In each response, only one of these fields will be set: error, speech_event_type, or one or more (repeated) results.

undelete_custom_class

undelete_custom_class(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.UndeleteCustomClassRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Undeletes the xref_CustomClass.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_undelete_custom_class():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.UndeleteCustomClassRequest(
        name="name_value",
    )

    # Make the request
    operation = client.undelete_custom_class(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.UndeleteCustomClassRequest, dict]

The request object. Request message for the UndeleteCustomClass method.

name str

Required. The name of the CustomClass to undelete. Format: projects/{project}/locations/{location}/customClasses/{custom_class} This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be CustomClass CustomClass for biasing in speech recognition. Used to define a set of words or phrases that represents a common concept or theme likely to appear in your audio, for example a list of passenger ship names.

undelete_phrase_set

undelete_phrase_set(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.UndeletePhraseSetRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Undeletes the xref_PhraseSet.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_undelete_phrase_set():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.UndeletePhraseSetRequest(
        name="name_value",
    )

    # Make the request
    operation = client.undelete_phrase_set(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.UndeletePhraseSetRequest, dict]

The request object. Request message for the UndeletePhraseSet method.

name str

Required. The name of the PhraseSet to undelete. Format: projects/{project}/locations/{location}/phraseSets/{phrase_set} This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be PhraseSet PhraseSet for biasing in speech recognition. A PhraseSet is used to provide "hints" to the speech recognizer to favor specific words and phrases in the results.

undelete_recognizer

undelete_recognizer(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.UndeleteRecognizerRequest, dict
        ]
    ] = None,
    *,
    name: typing.Optional[str] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Undeletes the xref_Recognizer.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_undelete_recognizer():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.UndeleteRecognizerRequest(
        name="name_value",
    )

    # Make the request
    operation = client.undelete_recognizer(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.UndeleteRecognizerRequest, dict]

The request object. Request message for the UndeleteRecognizer method.

name str

Required. The name of the Recognizer to undelete. Format: projects/{project}/locations/{location}/recognizers/{recognizer} This corresponds to the name field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be Recognizer A Recognizer message. Stores recognition configuration and metadata.

update_config

update_config(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.UpdateConfigRequest, dict
        ]
    ] = None,
    *,
    config: typing.Optional[google.cloud.speech_v2.types.cloud_speech.Config] = None,
    update_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.speech_v2.types.cloud_speech.Config

Updates the xref_Config.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_update_config():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.UpdateConfigRequest(
    )

    # Make the request
    response = client.update_config(request=request)

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.UpdateConfigRequest, dict]

The request object. Request message for the UpdateConfig method.

config google.cloud.speech_v2.types.Config

Required. The config to update. The config's name field is used to identify the config to be updated. The expected format is projects/{project}/locations/{location}/config. This corresponds to the config field on the request instance; if request is provided, this should not be set.

update_mask google.protobuf.field_mask_pb2.FieldMask

The list of fields to be updated. This corresponds to the update_mask field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.cloud.speech_v2.types.ConfigMessage representing the config for the Speech-to-Text API. This includes an optional [KMS key](\ https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which incoming data will be encrypted.

update_custom_class

update_custom_class(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.UpdateCustomClassRequest, dict
        ]
    ] = None,
    *,
    custom_class: typing.Optional[
        google.cloud.speech_v2.types.cloud_speech.CustomClass
    ] = None,
    update_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Updates the xref_CustomClass.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_update_custom_class():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.UpdateCustomClassRequest(
    )

    # Make the request
    operation = client.update_custom_class(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.UpdateCustomClassRequest, dict]

The request object. Request message for the UpdateCustomClass method.

custom_class google.cloud.speech_v2.types.CustomClass

Required. The CustomClass to update. The CustomClass's name field is used to identify the CustomClass to update. Format: projects/{project}/locations/{location}/customClasses/{custom_class}. This corresponds to the custom_class field on the request instance; if request is provided, this should not be set.

update_mask google.protobuf.field_mask_pb2.FieldMask

The list of fields to be updated. If empty, all fields are considered for update. This corresponds to the update_mask field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be CustomClass CustomClass for biasing in speech recognition. Used to define a set of words or phrases that represents a common concept or theme likely to appear in your audio, for example a list of passenger ship names.

update_phrase_set

update_phrase_set(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.UpdatePhraseSetRequest, dict
        ]
    ] = None,
    *,
    phrase_set: typing.Optional[
        google.cloud.speech_v2.types.cloud_speech.PhraseSet
    ] = None,
    update_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Updates the xref_PhraseSet.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_update_phrase_set():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    request = speech_v2.UpdatePhraseSetRequest(
    )

    # Make the request
    operation = client.update_phrase_set(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.UpdatePhraseSetRequest, dict]

The request object. Request message for the UpdatePhraseSet method.

phrase_set google.cloud.speech_v2.types.PhraseSet

Required. The PhraseSet to update. The PhraseSet's name field is used to identify the PhraseSet to update. Format: projects/{project}/locations/{location}/phraseSets/{phrase_set}. This corresponds to the phrase_set field on the request instance; if request is provided, this should not be set.

update_mask google.protobuf.field_mask_pb2.FieldMask

The list of fields to update. If empty, all non-default valued fields are considered for update. Use * to update the entire PhraseSet resource. This corresponds to the update_mask field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be PhraseSet PhraseSet for biasing in speech recognition. A PhraseSet is used to provide "hints" to the speech recognizer to favor specific words and phrases in the results.

update_recognizer

update_recognizer(
    request: typing.Optional[
        typing.Union[
            google.cloud.speech_v2.types.cloud_speech.UpdateRecognizerRequest, dict
        ]
    ] = None,
    *,
    recognizer: typing.Optional[
        google.cloud.speech_v2.types.cloud_speech.Recognizer
    ] = None,
    update_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None,
    retry: typing.Union[
        google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
    ] = _MethodDefault._DEFAULT_VALUE,
    timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
    metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation

Updates the xref_Recognizer.

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import speech_v2

def sample_update_recognizer():
    # Create a client
    client = speech_v2.SpeechClient()

    # Initialize request argument(s)
    recognizer = speech_v2.Recognizer()
    recognizer.model = "model_value"
    recognizer.language_codes = ['language_codes_value1', 'language_codes_value2']

    request = speech_v2.UpdateRecognizerRequest(
        recognizer=recognizer,
    )

    # Make the request
    operation = client.update_recognizer(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
Parameters
NameDescription
request Union[google.cloud.speech_v2.types.UpdateRecognizerRequest, dict]

The request object. Request message for the UpdateRecognizer method.

recognizer google.cloud.speech_v2.types.Recognizer

Required. The Recognizer to update. The Recognizer's name field is used to identify the Recognizer to update. Format: projects/{project}/locations/{location}/recognizers/{recognizer}. This corresponds to the recognizer field on the request instance; if request is provided, this should not be set.

update_mask google.protobuf.field_mask_pb2.FieldMask

The list of fields to update. If empty, all non-default valued fields are considered for update. Use * to update the entire Recognizer resource. This corresponds to the update_mask field on the request instance; if request is provided, this should not be set.

retry google.api_core.retry.Retry

Designation of what errors, if any, should be retried.

timeout float

The timeout for this request.

metadata Sequence[Tuple[str, str]]

Strings which should be sent along with the request as metadata.

Returns
TypeDescription
google.api_core.operation.OperationAn object representing a long-running operation. The result type for the operation will be Recognizer A Recognizer message. Stores recognition configuration and metadata.