Cloud Speech V1p1beta1 Client - Class AdaptationClient (1.16.0)

Reference documentation and code samples for the Cloud Speech V1p1beta1 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.

Namespace

Google \ Cloud \ Speech \ V1p1beta1

Methods

__construct

Constructor.

Parameters
NameDescription
options array

Optional. Options for configuring the service API wrapper.

↳ 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 Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper 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 Google\ApiCore\CredentialsWrapper::build() .

↳ 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 Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint 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 Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() 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.

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\V1p1beta1\CustomClass

Required. The custom class to create.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1p1beta1\CustomClass
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;
use Google\Cloud\Speech\V1p1beta1\CustomClass;

/**
 * @param string $formattedParent 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](https://cloud.google.com/speech-to-text/docs/endpoints)
 *                                with matching `us` or `eu` location value. Please see
 *                                {@see AdaptationClient::locationName()} for help formatting this field.
 * @param string $customClassId   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.
 */
function create_custom_class_sample(string $formattedParent, string $customClassId): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $customClass = new CustomClass();

    // Call the API and handle any network failures.
    try {
        /** @var CustomClass $response */
        $response = $adaptationClient->createCustomClass($formattedParent, $customClassId, $customClass);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = AdaptationClient::locationName('[PROJECT]', '[LOCATION]');
    $customClassId = '[CUSTOM_CLASS_ID]';

    create_custom_class_sample($formattedParent, $customClassId);
}

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.

Parameters
NameDescription
parent string

Required. The parent resource where this phrase set will be created. 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.

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\V1p1beta1\PhraseSet

Required. The phrase set to create.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1p1beta1\PhraseSet
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;
use Google\Cloud\Speech\V1p1beta1\PhraseSet;

/**
 * @param string $formattedParent The parent resource where this phrase set will be created.
 *                                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](https://cloud.google.com/speech-to-text/docs/endpoints)
 *                                with matching `us` or `eu` location value. Please see
 *                                {@see AdaptationClient::locationName()} for help formatting this field.
 * @param string $phraseSetId     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.
 */
function create_phrase_set_sample(string $formattedParent, string $phraseSetId): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $phraseSet = new PhraseSet();

    // Call the API and handle any network failures.
    try {
        /** @var PhraseSet $response */
        $response = $adaptationClient->createPhraseSet($formattedParent, $phraseSetId, $phraseSet);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = AdaptationClient::locationName('[PROJECT]', '[LOCATION]');
    $phraseSetId = '[PHRASE_SET_ID]';

    create_phrase_set_sample($formattedParent, $phraseSetId);
}

deleteCustomClass

Delete a custom class.

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 Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;

/**
 * @param string $formattedName 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](https://cloud.google.com/speech-to-text/docs/endpoints)
 *                              with matching `us` or `eu` location value. Please see
 *                              {@see AdaptationClient::customClassName()} for help formatting this field.
 */
function delete_custom_class_sample(string $formattedName): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Call the API and handle any network failures.
    try {
        $adaptationClient->deleteCustomClass($formattedName);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = AdaptationClient::customClassName('[PROJECT]', '[LOCATION]', '[CUSTOM_CLASS]');

    delete_custom_class_sample($formattedName);
}

deletePhraseSet

Delete a phrase set.

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 Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;

/**
 * @param string $formattedName The name of the phrase set to delete. Format:
 *
 *                              `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
 *                              Please see {@see AdaptationClient::phraseSetName()} for help formatting this field.
 */
function delete_phrase_set_sample(string $formattedName): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Call the API and handle any network failures.
    try {
        $adaptationClient->deletePhraseSet($formattedName);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = AdaptationClient::phraseSetName('[PROJECT]', '[LOCATION]', '[PHRASE_SET]');

    delete_phrase_set_sample($formattedName);
}

getCustomClass

Get a custom class.

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 Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1p1beta1\CustomClass
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;
use Google\Cloud\Speech\V1p1beta1\CustomClass;

/**
 * @param string $formattedName The name of the custom class to retrieve. Format:
 *
 *                              `projects/{project}/locations/{location}/customClasses/{custom_class}`
 *                              Please see {@see AdaptationClient::customClassName()} for help formatting this field.
 */
function get_custom_class_sample(string $formattedName): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Call the API and handle any network failures.
    try {
        /** @var CustomClass $response */
        $response = $adaptationClient->getCustomClass($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = AdaptationClient::customClassName('[PROJECT]', '[LOCATION]', '[CUSTOM_CLASS]');

    get_custom_class_sample($formattedName);
}

getPhraseSet

Get a phrase set.

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 Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1p1beta1\PhraseSet
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;
use Google\Cloud\Speech\V1p1beta1\PhraseSet;

/**
 * @param string $formattedName 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](https://cloud.google.com/speech-to-text/docs/endpoints)
 *                              with matching `us` or `eu` location value. Please see
 *                              {@see AdaptationClient::phraseSetName()} for help formatting this field.
 */
function get_phrase_set_sample(string $formattedName): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Call the API and handle any network failures.
    try {
        /** @var PhraseSet $response */
        $response = $adaptationClient->getPhraseSet($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = AdaptationClient::phraseSetName('[PROJECT]', '[LOCATION]', '[PHRASE_SET]');

    get_phrase_set_sample($formattedName);
}

listCustomClasses

List custom classes.

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 Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;
use Google\Cloud\Speech\V1p1beta1\CustomClass;

/**
 * @param string $formattedParent 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](https://cloud.google.com/speech-to-text/docs/endpoints)
 *                                with matching `us` or `eu` location value. Please see
 *                                {@see AdaptationClient::locationName()} for help formatting this field.
 */
function list_custom_classes_sample(string $formattedParent): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $adaptationClient->listCustomClasses($formattedParent);

        /** @var CustomClass $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = AdaptationClient::locationName('[PROJECT]', '[LOCATION]');

    list_custom_classes_sample($formattedParent);
}

listPhraseSet

List phrase sets.

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 Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;
use Google\Cloud\Speech\V1p1beta1\PhraseSet;

/**
 * @param string $formattedParent 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](https://cloud.google.com/speech-to-text/docs/endpoints)
 *                                with matching `us` or `eu` location value. Please see
 *                                {@see AdaptationClient::locationName()} for help formatting this field.
 */
function list_phrase_set_sample(string $formattedParent): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $adaptationClient->listPhraseSet($formattedParent);

        /** @var PhraseSet $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = AdaptationClient::locationName('[PROJECT]', '[LOCATION]');

    list_phrase_set_sample($formattedParent);
}

updateCustomClass

Update a custom class.

Parameters
NameDescription
customClass Google\Cloud\Speech\V1p1beta1\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 Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1p1beta1\CustomClass
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;
use Google\Cloud\Speech\V1p1beta1\CustomClass;

/**
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_custom_class_sample(): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $customClass = new CustomClass();

    // Call the API and handle any network failures.
    try {
        /** @var CustomClass $response */
        $response = $adaptationClient->updateCustomClass($customClass);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

updatePhraseSet

Update a phrase set.

Parameters
NameDescription
phraseSet Google\Cloud\Speech\V1p1beta1\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 Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Speech\V1p1beta1\PhraseSet
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1p1beta1\AdaptationClient;
use Google\Cloud\Speech\V1p1beta1\PhraseSet;

/**
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_phrase_set_sample(): void
{
    // Create a client.
    $adaptationClient = new AdaptationClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $phraseSet = new PhraseSet();

    // Call the API and handle any network failures.
    try {
        /** @var PhraseSet $response */
        $response = $adaptationClient->updatePhraseSet($phraseSet);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

static::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.

static::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.

static::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.

static::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.

Constants

SERVICE_NAME

Value: 'google.cloud.speech.v1p1beta1.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.