Skip to content

Commit

Permalink
feat: [Speech] Added new fields to facilitate debugging (#5668)
Browse files Browse the repository at this point in the history
* feat: Added new fields to facilitate debugging
* Added new field to Speech response proto, to give more information to indicate whether, or not, Biasing was applied (eg. did Biasing application timed out).
* Added request_id to Speech response protos.

PiperOrigin-RevId: 492276727

Source-Link: googleapis/googleapis@4c25335

Source-Link: googleapis/googleapis-gen@f15b9ac
Copy-Tag: eyJwIjoiU3BlZWNoLy5Pd2xCb3QueWFtbCIsImgiOiJmMTViOWFjYTdhYzJiZDQwYjIwZTY3MTUxODg3MzJkMDhmYzdmZTIxIn0=

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore(bazel): update gapic-generator-php to v1.6.2

PiperOrigin-RevId: 493134713

Source-Link: googleapis/googleapis@83d92bd

Source-Link: googleapis/googleapis-gen@223117b
Copy-Tag: eyJwIjoiU3BlZWNoLy5Pd2xCb3QueWFtbCIsImgiOiIyMjMxMTdiNzJhZjEyYzZiOWFiNjExZjMxMDcyOWMzYTJmNDkzZjJmIn0=

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: Added new fields to facilitate debugging
* Added new field to Speech response proto, to give more information to indicate whether, or not, Biasing was applied (eg. did Biasing application timed out).
* Added request_id to Speech response protos.

PiperOrigin-RevId: 493311906

Source-Link: googleapis/googleapis@c9b244b

Source-Link: googleapis/googleapis-gen@d63ac84
Copy-Tag: eyJwIjoiU3BlZWNoLy5Pd2xCb3QueWFtbCIsImgiOiJkNjNhYzg0MGRlYzg1NGVlN2FjYWI3YjUyYjE1ZGVhZjgxOWVhZTA3In0=

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Dec 9, 2022
1 parent 44bb316 commit 42e734c
Show file tree
Hide file tree
Showing 71 changed files with 4,622 additions and 504 deletions.
Binary file modified Speech/metadata/V1/CloudSpeech.php
Binary file not shown.
Binary file modified Speech/metadata/V1P1Beta1/CloudSpeech.php
Binary file not shown.
83 changes: 83 additions & 0 deletions Speech/samples/V1/AdaptationClient/create_custom_class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START speech_v1_generated_Adaptation_CreateCustomClass_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1\AdaptationClient;
use Google\Cloud\Speech\V1\CustomClass;

/**
* Create a custom class.
*
* @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);
}
// [END speech_v1_generated_Adaptation_CreateCustomClass_sync]
85 changes: 85 additions & 0 deletions Speech/samples/V1/AdaptationClient/create_phrase_set.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START speech_v1_generated_Adaptation_CreatePhraseSet_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1\AdaptationClient;
use Google\Cloud\Speech\V1\PhraseSet;

/**
* 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.
*
* @param string $formattedParent 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](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);
}
// [END speech_v1_generated_Adaptation_CreatePhraseSet_sync]
72 changes: 72 additions & 0 deletions Speech/samples/V1/AdaptationClient/delete_custom_class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START speech_v1_generated_Adaptation_DeleteCustomClass_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1\AdaptationClient;

/**
* Delete a custom class.
*
* @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);
}
// [END speech_v1_generated_Adaptation_DeleteCustomClass_sync]
66 changes: 66 additions & 0 deletions Speech/samples/V1/AdaptationClient/delete_phrase_set.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START speech_v1_generated_Adaptation_DeletePhraseSet_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1\AdaptationClient;

/**
* Delete a phrase set.
*
* @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);
}
// [END speech_v1_generated_Adaptation_DeletePhraseSet_sync]
68 changes: 68 additions & 0 deletions Speech/samples/V1/AdaptationClient/get_custom_class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START speech_v1_generated_Adaptation_GetCustomClass_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Speech\V1\AdaptationClient;
use Google\Cloud\Speech\V1\CustomClass;

/**
* Get a custom class.
*
* @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);
}
// [END speech_v1_generated_Adaptation_GetCustomClass_sync]
Loading

0 comments on commit 42e734c

Please sign in to comment.