Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Feb 1, 2024
1 parent 651cc49 commit b9b9ba8
Show file tree
Hide file tree
Showing 2,211 changed files with 7,913 additions and 318,580 deletions.
Binary file modified TextToSpeech/metadata/V1/CloudTts.php
Binary file not shown.
19 changes: 9 additions & 10 deletions TextToSpeech/metadata/V1/CloudTtsLrs.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 7 additions & 43 deletions TextToSpeech/samples/V1/TextToSpeechClient/synthesize_speech.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,27 @@

// [START texttospeech_v1_generated_TextToSpeech_SynthesizeSpeech_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\TextToSpeech\V1\AudioConfig;
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechResponse;
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;

/**
* Synthesizes speech synchronously: receive results after all text input
* has been processed.
*
* @param string $voiceLanguageCode The language (and potentially also the region) of the voice
* expressed as a [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt)
* language tag, e.g. "en-US". This should not include a script tag (e.g. use
* "cmn-cn" rather than "cmn-Hant-cn"), because the script will be inferred
* from the input provided in the SynthesisInput. The TTS service
* will use this parameter to help choose an appropriate voice. Note that
* the TTS service may choose a voice with a slightly different language code
* than the one selected; it may substitute a different region
* (e.g. using en-US rather than en-CA if there isn't a Canadian voice
* available), or even a different language, e.g. using "nb" (Norwegian
* Bokmal) instead of "no" (Norwegian)".
* @param int $audioConfigAudioEncoding The format of the audio byte stream.
* 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 synthesize_speech_sample(string $voiceLanguageCode, int $audioConfigAudioEncoding): void
function synthesize_speech_sample(): void
{
// Create a client.
$textToSpeechClient = new TextToSpeechClient();

// Prepare the request message.
$input = new SynthesisInput();
$voice = (new VoiceSelectionParams())
->setLanguageCode($voiceLanguageCode);
$audioConfig = (new AudioConfig())
->setAudioEncoding($audioConfigAudioEncoding);
$request = (new SynthesizeSpeechRequest())
->setInput($input)
->setVoice($voice)
->setAudioConfig($audioConfig);
$request = new SynthesizeSpeechRequest();

// Call the API and handle any network failures.
try {
Expand All @@ -74,21 +55,4 @@ function synthesize_speech_sample(string $voiceLanguageCode, int $audioConfigAud
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
{
$voiceLanguageCode = '[LANGUAGE_CODE]';
$audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;

synthesize_speech_sample($voiceLanguageCode, $audioConfigAudioEncoding);
}
// [END texttospeech_v1_generated_TextToSpeech_SynthesizeSpeech_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,27 @@
// [START texttospeech_v1_generated_TextToSpeechLongAudioSynthesize_SynthesizeLongAudio_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\TextToSpeech\V1\AudioConfig;
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechLongAudioSynthesizeClient;
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
use Google\Cloud\TextToSpeech\V1\SynthesizeLongAudioRequest;
use Google\Cloud\TextToSpeech\V1\SynthesizeLongAudioResponse;
use Google\Rpc\Status;

/**
* Synthesizes long form text asynchronously.
*
* @param int $audioConfigAudioEncoding The format of the audio byte stream.
* 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 synthesize_long_audio_sample(int $audioConfigAudioEncoding): void
function synthesize_long_audio_sample(): void
{
// Create a client.
$textToSpeechLongAudioSynthesizeClient = new TextToSpeechLongAudioSynthesizeClient();

// Prepare the request message.
$input = new SynthesisInput();
$audioConfig = (new AudioConfig())
->setAudioEncoding($audioConfigAudioEncoding);
$request = (new SynthesizeLongAudioRequest())
->setInput($input)
->setAudioConfig($audioConfig);
$request = new SynthesizeLongAudioRequest();

// Call the API and handle any network failures.
try {
Expand All @@ -70,20 +66,4 @@ function synthesize_long_audio_sample(int $audioConfigAudioEncoding): void
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
{
$audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;

synthesize_long_audio_sample($audioConfigAudioEncoding);
}
// [END texttospeech_v1_generated_TextToSpeechLongAudioSynthesize_SynthesizeLongAudio_sync]
39 changes: 22 additions & 17 deletions TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,21 @@ public function listVoices(array $optionalArgs = [])
* ```
* $textToSpeechClient = new TextToSpeechClient();
* try {
* $input = new SynthesisInput();
* $voice = new VoiceSelectionParams();
* $audioConfig = new AudioConfig();
* $response = $textToSpeechClient->synthesizeSpeech($input, $voice, $audioConfig);
* $response = $textToSpeechClient->synthesizeSpeech();
* } finally {
* $textToSpeechClient->close();
* }
* ```
*
* @param SynthesisInput $input Required. The Synthesizer requires either plain text or SSML as input.
* @param VoiceSelectionParams $voice Required. The desired voice of the synthesized audio.
* @param AudioConfig $audioConfig Required. The configuration of the synthesized audio.
* @param array $optionalArgs {
* @param array $optionalArgs {
* Optional.
*
* @type SynthesisInput $input
* Required. The Synthesizer requires either plain text or SSML as input.
* @type VoiceSelectionParams $voice
* Required. The desired voice of the synthesized audio.
* @type AudioConfig $audioConfig
* Required. The configuration of the synthesized audio.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
Expand All @@ -348,16 +348,21 @@ public function listVoices(array $optionalArgs = [])
*
* @throws ApiException if the remote call fails
*/
public function synthesizeSpeech(
$input,
$voice,
$audioConfig,
array $optionalArgs = []
) {
public function synthesizeSpeech(array $optionalArgs = [])

Check failure on line 351 in TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

The parameter $input of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechGapicClient#synthesizeSpeech() changed from no type to a non-contravariant array

Check failure on line 351 in TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

The parameter $input of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechGapicClient#synthesizeSpeech() changed from no type to array

Check failure on line 351 in TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

Parameter 0 of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechGapicClient#synthesizeSpeech() changed name from input to optionalArgs

Check failure on line 351 in TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

The parameter $input of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechGapicClient#synthesizeSpeech() changed from no type to a non-contravariant array

Check failure on line 351 in TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

The parameter $input of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechGapicClient#synthesizeSpeech() changed from no type to array

Check failure on line 351 in TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

Parameter 0 of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechGapicClient#synthesizeSpeech() changed name from input to optionalArgs
{
$request = new SynthesizeSpeechRequest();
$request->setInput($input);
$request->setVoice($voice);
$request->setAudioConfig($audioConfig);
if (isset($optionalArgs['input'])) {
$request->setInput($optionalArgs['input']);
}

if (isset($optionalArgs['voice'])) {
$request->setVoice($optionalArgs['voice']);
}

if (isset($optionalArgs['audioConfig'])) {
$request->setAudioConfig($optionalArgs['audioConfig']);
}

return $this->startCall(
'SynthesizeSpeech',
SynthesizeSpeechResponse::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
* ```
* $textToSpeechLongAudioSynthesizeClient = new TextToSpeechLongAudioSynthesizeClient();
* try {
* $input = new SynthesisInput();
* $audioConfig = new AudioConfig();
* $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
* $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio();
* $operationResponse->pollUntilComplete();
* if ($operationResponse->operationSucceeded()) {
* $result = $operationResponse->getResult();
Expand All @@ -63,7 +61,7 @@
* }
* // Alternatively:
* // start the operation, keep the operation name, and resume later
* $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
* $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio();
* $operationName = $operationResponse->getName();
* // ... do other work
* $newOperationResponse = $textToSpeechLongAudioSynthesizeClient->resumeOperation($operationName, 'synthesizeLongAudio');
Expand Down Expand Up @@ -341,9 +339,7 @@ public function __construct(array $options = [])
* ```
* $textToSpeechLongAudioSynthesizeClient = new TextToSpeechLongAudioSynthesizeClient();
* try {
* $input = new SynthesisInput();
* $audioConfig = new AudioConfig();
* $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
* $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio();
* $operationResponse->pollUntilComplete();
* if ($operationResponse->operationSucceeded()) {
* $result = $operationResponse->getResult();
Expand All @@ -354,7 +350,7 @@ public function __construct(array $options = [])
* }
* // Alternatively:
* // start the operation, keep the operation name, and resume later
* $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
* $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio();
* $operationName = $operationResponse->getName();
* // ... do other work
* $newOperationResponse = $textToSpeechLongAudioSynthesizeClient->resumeOperation($operationName, 'synthesizeLongAudio');
Expand All @@ -374,15 +370,17 @@ public function __construct(array $options = [])
* }
* ```
*
* @param SynthesisInput $input Required. The Synthesizer requires either plain text or SSML as input.
* While Long Audio is in preview, SSML is temporarily unsupported.
* @param AudioConfig $audioConfig Required. The configuration of the synthesized audio.
* @param array $optionalArgs {
* @param array $optionalArgs {
* Optional.
*
* @type string $parent
* The resource states of the request in the form of
* `projects/*/locations/*`.
* @type SynthesisInput $input
* Required. The Synthesizer requires either plain text or SSML as input.
* While Long Audio is in preview, SSML is temporarily unsupported.
* @type AudioConfig $audioConfig
* Required. The configuration of the synthesized audio.
* @type string $outputGcsUri
* Required. Specifies a Cloud Storage URI for the synthesis results. Must be
* specified in the format: `gs://bucket_name/object_name`, and the bucket
Expand All @@ -399,20 +397,23 @@ public function __construct(array $options = [])
*
* @throws ApiException if the remote call fails
*/
public function synthesizeLongAudio(
$input,
$audioConfig,
array $optionalArgs = []
) {
public function synthesizeLongAudio(array $optionalArgs = [])

Check failure on line 400 in TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

The parameter $input of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechLongAudioSynthesizeGapicClient#synthesizeLongAudio() changed from no type to a non-contravariant array

Check failure on line 400 in TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

The parameter $input of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechLongAudioSynthesizeGapicClient#synthesizeLongAudio() changed from no type to array

Check failure on line 400 in TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

Parameter 0 of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechLongAudioSynthesizeGapicClient#synthesizeLongAudio() changed name from input to optionalArgs

Check failure on line 400 in TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php

View workflow job for this annotation

GitHub Actions / backwards-compatibility-check

The parameter $input of Google\Cloud\TextToSpeech\V1\Gapic\TextToSpeechLongAudioSynthesizeGapicClient#synthesizeLongAudio() changed from no type to a non-contravariant array
{
$request = new SynthesizeLongAudioRequest();
$requestParamHeaders = [];
$request->setInput($input);
$request->setAudioConfig($audioConfig);
if (isset($optionalArgs['parent'])) {
$request->setParent($optionalArgs['parent']);
$requestParamHeaders['parent'] = $optionalArgs['parent'];
}

if (isset($optionalArgs['input'])) {
$request->setInput($optionalArgs['input']);
}

if (isset($optionalArgs['audioConfig'])) {
$request->setAudioConfig($optionalArgs['audioConfig']);
}

if (isset($optionalArgs['outputGcsUri'])) {
$request->setOutputGcsUri($optionalArgs['outputGcsUri']);
}
Expand Down
36 changes: 2 additions & 34 deletions TextToSpeech/tests/Unit/V1/Client/TextToSpeechClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@
use Google\ApiCore\CredentialsWrapper;
use Google\ApiCore\Testing\GeneratedTest;
use Google\ApiCore\Testing\MockTransport;
use Google\Cloud\TextToSpeech\V1\AudioConfig;
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
use Google\Cloud\TextToSpeech\V1\ListVoicesRequest;
use Google\Cloud\TextToSpeech\V1\ListVoicesResponse;
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechResponse;
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
use Google\Rpc\Code;
use stdClass;

Expand Down Expand Up @@ -133,31 +129,14 @@ public function synthesizeSpeechTest()
$expectedResponse = new SynthesizeSpeechResponse();
$expectedResponse->setAudioContent($audioContent);
$transport->addResponse($expectedResponse);
// Mock request
$input = new SynthesisInput();
$voice = new VoiceSelectionParams();
$voiceLanguageCode = 'voiceLanguageCode-686472265';
$voice->setLanguageCode($voiceLanguageCode);
$audioConfig = new AudioConfig();
$audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;
$audioConfig->setAudioEncoding($audioConfigAudioEncoding);
$request = (new SynthesizeSpeechRequest())
->setInput($input)
->setVoice($voice)
->setAudioConfig($audioConfig);
$request = new SynthesizeSpeechRequest();
$response = $gapicClient->synthesizeSpeech($request);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
$actualFuncCall = $actualRequests[0]->getFuncCall();
$actualRequestObject = $actualRequests[0]->getRequestObject();
$this->assertSame('/google.cloud.texttospeech.v1.TextToSpeech/SynthesizeSpeech', $actualFuncCall);
$actualValue = $actualRequestObject->getInput();
$this->assertProtobufEquals($input, $actualValue);
$actualValue = $actualRequestObject->getVoice();
$this->assertProtobufEquals($voice, $actualValue);
$actualValue = $actualRequestObject->getAudioConfig();
$this->assertProtobufEquals($audioConfig, $actualValue);
$this->assertTrue($transport->isExhausted());
}

Expand All @@ -179,18 +158,7 @@ public function synthesizeSpeechExceptionTest()
'details' => [],
], JSON_PRETTY_PRINT);
$transport->addResponse(null, $status);
// Mock request
$input = new SynthesisInput();
$voice = new VoiceSelectionParams();
$voiceLanguageCode = 'voiceLanguageCode-686472265';
$voice->setLanguageCode($voiceLanguageCode);
$audioConfig = new AudioConfig();
$audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;
$audioConfig->setAudioEncoding($audioConfigAudioEncoding);
$request = (new SynthesizeSpeechRequest())
->setInput($input)
->setVoice($voice)
->setAudioConfig($audioConfig);
$request = new SynthesizeSpeechRequest();
try {
$gapicClient->synthesizeSpeech($request);
// If the $gapicClient method call did not throw, fail the test
Expand Down
Loading

0 comments on commit b9b9ba8

Please sign in to comment.