Cloud Speech V1 Client - Class AdaptationClient (1.7.0)

Reference documentation and code samples for the Cloud Speech V1 Client class AdaptationClient.

Service Description: Service that implements Google Cloud Speech Adaptation API.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:

$adaptationClient = new AdaptationClient();
try {
    $formattedParent = $adaptationClient->locationName('[PROJECT]', '[LOCATION]');
    $customClassId = 'custom_class_id';
    $customClass = new CustomClass();
    $response = $adaptationClient->createCustomClass($formattedParent, $customClassId, $customClass);
} finally {
    $adaptationClient->close();
}

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Methods

customClassName

Formats a string containing the fully-qualified path to represent a custom_class resource.

Parameters
NameDescription
project string
location string
customClass string
Returns
TypeDescription
stringThe formatted custom_class resource.

locationName

Formats a string containing the fully-qualified path to represent a location resource.

Parameters
NameDescription
project string
location string
Returns
TypeDescription
stringThe formatted location resource.

phraseSetName

Formats a string containing the fully-qualified path to represent a phrase_set resource.

Parameters
NameDescription
project string
location string
phraseSet string
Returns
TypeDescription
stringThe formatted phrase_set resource.

parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • customClass: projects/{project}/locations/{location}/customClasses/{custom_class}
  • location: projects/{project}/locations/{location}
  • phraseSet: projects/{project}/locations/{location}/phraseSets/{phrase_set}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

__construct

Constructor.

Parameters
NameDescription
options array

Optional. Options for configuring the service API wrapper.

↳ serviceAddress string

Deprecated. This option will be removed in a future major release. Please utilize the $apiEndpoint option instead.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed {@see} object or {@see} object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see {@see} .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated {@see} object. Note that when this object is provided, any settings in $transportConfig, and any $serviceAddress setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the {@see} and {@see} methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

createCustomClass

Create a custom class.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $formattedParent = $adaptationClient->locationName('[PROJECT]', '[LOCATION]');
    $customClassId = 'custom_class_id';
    $customClass = new CustomClass();
    $response = $adaptationClient->createCustomClass($formattedParent, $customClassId, $customClass);
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
parent string

Required. The parent resource where this custom class will be created. Format: projects/{project}/locations/{location}/customClasses Speech-to-Text supports three locations: global, us (US North America), and eu (Europe). If you are calling the speech.googleapis.com endpoint, use the global location. To specify a region, use a regional endpoint with matching us or eu location value.

customClassId string

Required. The ID to use for the custom class, which will become the final component of the custom class' resource name. This value should restrict to letters, numbers, and hyphens, with the first character a letter, the last a letter or a number, and be 4-63 characters.

customClass Google\Cloud\Speech\V1\CustomClass

Required. The custom class to create.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1\CustomClass

createPhraseSet

Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. The items in the PhraseSet are favored by the recognition model when you send a call that includes the PhraseSet.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $formattedParent = $adaptationClient->locationName('[PROJECT]', '[LOCATION]');
    $phraseSetId = 'phrase_set_id';
    $phraseSet = new PhraseSet();
    $response = $adaptationClient->createPhraseSet($formattedParent, $phraseSetId, $phraseSet);
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
parent string

Required. The parent resource where this phrase set will be created. Format: projects/{project}/locations/{location}/phraseSets Speech-to-Text supports three locations: global, us (US North America), and eu (Europe). If you are calling the speech.googleapis.com endpoint, use the global location. To specify a region, use a regional endpoint with matching us or eu location value.

phraseSetId string

Required. The ID to use for the phrase set, which will become the final component of the phrase set's resource name. This value should restrict to letters, numbers, and hyphens, with the first character a letter, the last a letter or a number, and be 4-63 characters.

phraseSet Google\Cloud\Speech\V1\PhraseSet

Required. The phrase set to create.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1\PhraseSet

deleteCustomClass

Delete a custom class.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $formattedName = $adaptationClient->customClassName('[PROJECT]', '[LOCATION]', '[CUSTOM_CLASS]');
    $adaptationClient->deleteCustomClass($formattedName);
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
name string

Required. The name of the custom class to delete. Format: projects/{project}/locations/{location}/customClasses/{custom_class} Speech-to-Text supports three locations: global, us (US North America), and eu (Europe). If you are calling the speech.googleapis.com endpoint, use the global location. To specify a region, use a regional endpoint with matching us or eu location value.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

deletePhraseSet

Delete a phrase set.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $formattedName = $adaptationClient->phraseSetName('[PROJECT]', '[LOCATION]', '[PHRASE_SET]');
    $adaptationClient->deletePhraseSet($formattedName);
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
name string

Required. The name of the phrase set to delete. Format: projects/{project}/locations/{location}/phraseSets/{phrase_set}

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

getCustomClass

Get a custom class.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $formattedName = $adaptationClient->customClassName('[PROJECT]', '[LOCATION]', '[CUSTOM_CLASS]');
    $response = $adaptationClient->getCustomClass($formattedName);
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
name string

Required. The name of the custom class to retrieve. Format: projects/{project}/locations/{location}/customClasses/{custom_class}

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1\CustomClass

getPhraseSet

Get a phrase set.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $formattedName = $adaptationClient->phraseSetName('[PROJECT]', '[LOCATION]', '[PHRASE_SET]');
    $response = $adaptationClient->getPhraseSet($formattedName);
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
name string

Required. The name of the phrase set to retrieve. Format: projects/{project}/locations/{location}/phraseSets/{phrase_set} Speech-to-Text supports three locations: global, us (US North America), and eu (Europe). If you are calling the speech.googleapis.com endpoint, use the global location. To specify a region, use a regional endpoint with matching us or eu location value.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1\PhraseSet

listCustomClasses

List custom classes.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $formattedParent = $adaptationClient->locationName('[PROJECT]', '[LOCATION]');
    // Iterate over pages of elements
    $pagedResponse = $adaptationClient->listCustomClasses($formattedParent);
    foreach ($pagedResponse->iteratePages() as $page) {
        foreach ($page as $element) {
            // doSomethingWith($element);
        }
    }
    // Alternatively:
    // Iterate through all elements
    $pagedResponse = $adaptationClient->listCustomClasses($formattedParent);
    foreach ($pagedResponse->iterateAllElements() as $element) {
        // doSomethingWith($element);
    }
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
parent string

Required. The parent, which owns this collection of custom classes. Format: projects/{project}/locations/{location}/customClasses Speech-to-Text supports three locations: global, us (US North America), and eu (Europe). If you are calling the speech.googleapis.com endpoint, use the global location. To specify a region, use a regional endpoint with matching us or eu location value.

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse

listPhraseSet

List phrase sets.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $formattedParent = $adaptationClient->locationName('[PROJECT]', '[LOCATION]');
    // Iterate over pages of elements
    $pagedResponse = $adaptationClient->listPhraseSet($formattedParent);
    foreach ($pagedResponse->iteratePages() as $page) {
        foreach ($page as $element) {
            // doSomethingWith($element);
        }
    }
    // Alternatively:
    // Iterate through all elements
    $pagedResponse = $adaptationClient->listPhraseSet($formattedParent);
    foreach ($pagedResponse->iterateAllElements() as $element) {
        // doSomethingWith($element);
    }
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
parent string

Required. The parent, which owns this collection of phrase set. Format: projects/{project}/locations/{location} Speech-to-Text supports three locations: global, us (US North America), and eu (Europe). If you are calling the speech.googleapis.com endpoint, use the global location. To specify a region, use a regional endpoint with matching us or eu location value.

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse

updateCustomClass

Update a custom class.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $customClass = new CustomClass();
    $response = $adaptationClient->updateCustomClass($customClass);
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
customClass Google\Cloud\Speech\V1\CustomClass

Required. The custom class to update. The custom class's name field is used to identify the custom class to be updated. Format: projects/{project}/locations/{location}/customClasses/{custom_class} Speech-to-Text supports three locations: global, us (US North America), and eu (Europe). If you are calling the speech.googleapis.com endpoint, use the global location. To specify a region, use a regional endpoint with matching us or eu location value.

optionalArgs array

Optional.

↳ updateMask FieldMask

The list of fields to be updated.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1\CustomClass

updatePhraseSet

Update a phrase set.

Sample code:

$adaptationClient = new AdaptationClient();
try {
    $phraseSet = new PhraseSet();
    $response = $adaptationClient->updatePhraseSet($phraseSet);
} finally {
    $adaptationClient->close();
}
Parameters
NameDescription
phraseSet Google\Cloud\Speech\V1\PhraseSet

Required. The phrase set to update. The phrase set's name field is used to identify the set to be updated. Format: projects/{project}/locations/{location}/phraseSets/{phrase_set} Speech-to-Text supports three locations: global, us (US North America), and eu (Europe). If you are calling the speech.googleapis.com endpoint, use the global location. To specify a region, use a regional endpoint with matching us or eu location value.

optionalArgs array

Optional.

↳ updateMask FieldMask

The list of fields to be updated.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1\PhraseSet

Constants

SERVICE_NAME

Value: 'google.cloud.speech.v1.Adaptation'

The name of the service.

SERVICE_ADDRESS

Value: 'speech.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.