diff --git a/TextToSpeech/metadata/V1/CloudTtsLrs.php b/TextToSpeech/metadata/V1/CloudTtsLrs.php
new file mode 100644
index 00000000000..2e7febaca56
--- /dev/null
+++ b/TextToSpeech/metadata/V1/CloudTtsLrs.php
@@ -0,0 +1,49 @@
+internalAddGeneratedFile(
+ '
+
+
+0google/cloud/texttospeech/v1/cloud_tts_lrs.protogoogle.cloud.texttospeech.v1google/api/client.protogoogle/api/field_behavior.proto,google/cloud/texttospeech/v1/cloud_tts.proto#google/longrunning/operations.protogoogle/protobuf/timestamp.proto"
+SynthesizeLongAudioRequest
+parent ( @
+input (2,.google.cloud.texttospeech.v1.SynthesisInputBAD
+audio_config (2).google.cloud.texttospeech.v1.AudioConfigBA
+output_gcs_uri ( A
+voice (22.google.cloud.texttospeech.v1.VoiceSelectionParams"
+SynthesizeLongAudioResponse"
+SynthesizeLongAudioMetadata.
+
+start_time (2.google.protobuf.Timestamp4
+last_update_time (2.google.protobuf.Timestamp
+progress_percentage (2
+TextToSpeechLongAudioSynthesize
+SynthesizeLongAudio8.google.cloud.texttospeech.v1.SynthesizeLongAudioRequest.google.longrunning.Operation"E"@/v1/{parent=projects/*/locations/*/voices/*}:SynthesizeLongAudio:*A:
+SynthesizeLongAudioResponseSynthesizeLongAudioMetadataOAtexttospeech.googleapis.comA.https://www.googleapis.com/auth/cloud-platformB
+ com.google.cloud.texttospeech.v1B#TextToSpeechLongAudioSynthesisProtoPZHgoogle.golang.org/genproto/googleapis/cloud/texttospeech/v1;texttospeechGoogle.Cloud.TextToSpeech.V1Google\\Cloud\\TextToSpeech\\V1Google::Cloud::TextToSpeech::V1bproto3'
+ , true);
+
+ static::$is_initialized = true;
+ }
+}
+
diff --git a/TextToSpeech/samples/V1/TextToSpeechClient/synthesize_speech.php b/TextToSpeech/samples/V1/TextToSpeechClient/synthesize_speech.php
index 0a702aae6c5..7af449763fa 100644
--- a/TextToSpeech/samples/V1/TextToSpeechClient/synthesize_speech.php
+++ b/TextToSpeech/samples/V1/TextToSpeechClient/synthesize_speech.php
@@ -35,9 +35,9 @@
* 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
+ * @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
diff --git a/TextToSpeech/samples/V1/TextToSpeechLongAudioSynthesizeClient/synthesize_long_audio.php b/TextToSpeech/samples/V1/TextToSpeechLongAudioSynthesizeClient/synthesize_long_audio.php
new file mode 100644
index 00000000000..1898a6dceab
--- /dev/null
+++ b/TextToSpeech/samples/V1/TextToSpeechLongAudioSynthesizeClient/synthesize_long_audio.php
@@ -0,0 +1,85 @@
+setAudioEncoding($audioConfigAudioEncoding);
+
+ // Call the API and handle any network failures.
+ try {
+ /** @var OperationResponse $response */
+ $response = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
+ $response->pollUntilComplete();
+
+ if ($response->operationSucceeded()) {
+ /** @var SynthesizeLongAudioResponse $result */
+ $result = $response->getResult();
+ printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
+ } else {
+ /** @var Status $error */
+ $error = $response->getError();
+ printf('Operation failed with error data: %s' . PHP_EOL, $error->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
+{
+ $audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;
+
+ synthesize_long_audio_sample($audioConfigAudioEncoding);
+}
+// [END texttospeech_v1_generated_TextToSpeechLongAudioSynthesize_SynthesizeLongAudio_sync]
diff --git a/TextToSpeech/src/V1/AudioConfig.php b/TextToSpeech/src/V1/AudioConfig.php
index 5e59b254f4e..49a0532fadb 100644
--- a/TextToSpeech/src/V1/AudioConfig.php
+++ b/TextToSpeech/src/V1/AudioConfig.php
@@ -58,7 +58,7 @@ class AudioConfig extends \Google\Protobuf\Internal\Message
* converting to the desired sample rate (which might result in worse audio
* quality), unless the specified sample rate is not supported for the
* encoding chosen, in which case it will fail the request and return
- * [google.rpc.Code.INVALID_ARGUMENT][].
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].
*
* Generated from protobuf field int32 sample_rate_hertz = 5 [(.google.api.field_behavior) = OPTIONAL];
*/
@@ -108,7 +108,7 @@ class AudioConfig extends \Google\Protobuf\Internal\Message
* converting to the desired sample rate (which might result in worse audio
* quality), unless the specified sample rate is not supported for the
* encoding chosen, in which case it will fail the request and return
- * [google.rpc.Code.INVALID_ARGUMENT][].
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].
* @type array|\Google\Protobuf\Internal\RepeatedField $effects_profile_id
* Optional. Input only. An identifier which selects 'audio effects' profiles
* that are applied on (post synthesized) text to speech. Effects are applied
@@ -258,7 +258,7 @@ public function setVolumeGainDb($var)
* converting to the desired sample rate (which might result in worse audio
* quality), unless the specified sample rate is not supported for the
* encoding chosen, in which case it will fail the request and return
- * [google.rpc.Code.INVALID_ARGUMENT][].
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].
*
* Generated from protobuf field int32 sample_rate_hertz = 5 [(.google.api.field_behavior) = OPTIONAL];
* @return int
@@ -275,7 +275,7 @@ public function getSampleRateHertz()
* converting to the desired sample rate (which might result in worse audio
* quality), unless the specified sample rate is not supported for the
* encoding chosen, in which case it will fail the request and return
- * [google.rpc.Code.INVALID_ARGUMENT][].
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].
*
* Generated from protobuf field int32 sample_rate_hertz = 5 [(.google.api.field_behavior) = OPTIONAL];
* @param int $var
diff --git a/TextToSpeech/src/V1/AudioEncoding.php b/TextToSpeech/src/V1/AudioEncoding.php
index b74fb619a4f..1a3ee8800a9 100644
--- a/TextToSpeech/src/V1/AudioEncoding.php
+++ b/TextToSpeech/src/V1/AudioEncoding.php
@@ -15,7 +15,8 @@
class AudioEncoding
{
/**
- * Not specified. Will return result [google.rpc.Code.INVALID_ARGUMENT][].
+ * Not specified. Will return result
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT].
*
* Generated from protobuf enum AUDIO_ENCODING_UNSPECIFIED = 0;
*/
diff --git a/TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php b/TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php
new file mode 100644
index 00000000000..a49bb319dd4
--- /dev/null
+++ b/TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php
@@ -0,0 +1,331 @@
+synthesizeLongAudio($input, $audioConfig);
+ * $operationResponse->pollUntilComplete();
+ * if ($operationResponse->operationSucceeded()) {
+ * $result = $operationResponse->getResult();
+ * // doSomethingWith($result)
+ * } else {
+ * $error = $operationResponse->getError();
+ * // handleError($error)
+ * }
+ * // Alternatively:
+ * // start the operation, keep the operation name, and resume later
+ * $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
+ * $operationName = $operationResponse->getName();
+ * // ... do other work
+ * $newOperationResponse = $textToSpeechLongAudioSynthesizeClient->resumeOperation($operationName, 'synthesizeLongAudio');
+ * while (!$newOperationResponse->isDone()) {
+ * // ... do other work
+ * $newOperationResponse->reload();
+ * }
+ * if ($newOperationResponse->operationSucceeded()) {
+ * $result = $newOperationResponse->getResult();
+ * // doSomethingWith($result)
+ * } else {
+ * $error = $newOperationResponse->getError();
+ * // handleError($error)
+ * }
+ * } finally {
+ * $textToSpeechLongAudioSynthesizeClient->close();
+ * }
+ * ```
+ */
+class TextToSpeechLongAudioSynthesizeGapicClient
+{
+ use GapicClientTrait;
+
+ /** The name of the service. */
+ const SERVICE_NAME = 'google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize';
+
+ /** The default address of the service. */
+ const SERVICE_ADDRESS = 'texttospeech.googleapis.com';
+
+ /** The default port of the service. */
+ const DEFAULT_SERVICE_PORT = 443;
+
+ /** The name of the code generator, to be included in the agent header. */
+ const CODEGEN_NAME = 'gapic';
+
+ /** The default scopes required by the service. */
+ public static $serviceScopes = [
+ 'https://www.googleapis.com/auth/cloud-platform',
+ ];
+
+ private $operationsClient;
+
+ private static function getClientDefaults()
+ {
+ return [
+ 'serviceName' => self::SERVICE_NAME,
+ 'apiEndpoint' =>
+ self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT,
+ 'clientConfig' =>
+ __DIR__ .
+ '/../resources/text_to_speech_long_audio_synthesize_client_config.json',
+ 'descriptorsConfigPath' =>
+ __DIR__ .
+ '/../resources/text_to_speech_long_audio_synthesize_descriptor_config.php',
+ 'gcpApiConfigPath' =>
+ __DIR__ .
+ '/../resources/text_to_speech_long_audio_synthesize_grpc_config.json',
+ 'credentialsConfig' => [
+ 'defaultScopes' => self::$serviceScopes,
+ ],
+ 'transportConfig' => [
+ 'rest' => [
+ 'restClientConfigPath' =>
+ __DIR__ .
+ '/../resources/text_to_speech_long_audio_synthesize_rest_client_config.php',
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Return an OperationsClient object with the same endpoint as $this.
+ *
+ * @return OperationsClient
+ */
+ public function getOperationsClient()
+ {
+ return $this->operationsClient;
+ }
+
+ /**
+ * Resume an existing long running operation that was previously started by a long
+ * running API method. If $methodName is not provided, or does not match a long
+ * running API method, then the operation can still be resumed, but the
+ * OperationResponse object will not deserialize the final response.
+ *
+ * @param string $operationName The name of the long running operation
+ * @param string $methodName The name of the method used to start the operation
+ *
+ * @return OperationResponse
+ */
+ public function resumeOperation($operationName, $methodName = null)
+ {
+ $options = isset($this->descriptors[$methodName]['longRunning'])
+ ? $this->descriptors[$methodName]['longRunning']
+ : [];
+ $operation = new OperationResponse(
+ $operationName,
+ $this->getOperationsClient(),
+ $options
+ );
+ $operation->reload();
+ return $operation;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param array $options {
+ * Optional. Options for configuring the service API wrapper.
+ *
+ * @type string $apiEndpoint
+ * The address of the API remote host. May optionally include the port, formatted
+ * as ":". Default 'texttospeech.googleapis.com:443'.
+ * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
+ * 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 \Google\Auth\FetchAuthTokenInterface} object or
+ * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
+ * objects are provided, any settings in $credentialsConfig will be ignored.
+ * @type array $credentialsConfig
+ * Options used to configure credentials, including auth token caching, for the
+ * client. For a full list of supporting configuration options, see
+ * {@see \Google\ApiCore\CredentialsWrapper::build()} .
+ * @type bool $disableRetries
+ * Determines whether or not retries defined by the client configuration should be
+ * disabled. Defaults to `false`.
+ * @type string|array $clientConfig
+ * 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.
+ * @type string|TransportInterface $transport
+ * 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 \Google\ApiCore\Transport\TransportInterface} object. Note
+ * that when this object is provided, any settings in $transportConfig, and any
+ * $apiEndpoint setting, will be ignored.
+ * @type array $transportConfig
+ * 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 \Google\ApiCore\Transport\GrpcTransport::build()} and
+ * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the
+ * supported options.
+ * @type callable $clientCertSource
+ * 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.
+ * }
+ *
+ * @throws ValidationException
+ */
+ public function __construct(array $options = [])
+ {
+ $clientOptions = $this->buildClientOptions($options);
+ $this->setClientOptions($clientOptions);
+ $this->operationsClient = $this->createOperationsClient($clientOptions);
+ }
+
+ /**
+ * Synthesizes long form text asynchronously.
+ *
+ * Sample code:
+ * ```
+ * $textToSpeechLongAudioSynthesizeClient = new TextToSpeechLongAudioSynthesizeClient();
+ * try {
+ * $input = new SynthesisInput();
+ * $audioConfig = new AudioConfig();
+ * $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
+ * $operationResponse->pollUntilComplete();
+ * if ($operationResponse->operationSucceeded()) {
+ * $result = $operationResponse->getResult();
+ * // doSomethingWith($result)
+ * } else {
+ * $error = $operationResponse->getError();
+ * // handleError($error)
+ * }
+ * // Alternatively:
+ * // start the operation, keep the operation name, and resume later
+ * $operationResponse = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
+ * $operationName = $operationResponse->getName();
+ * // ... do other work
+ * $newOperationResponse = $textToSpeechLongAudioSynthesizeClient->resumeOperation($operationName, 'synthesizeLongAudio');
+ * while (!$newOperationResponse->isDone()) {
+ * // ... do other work
+ * $newOperationResponse->reload();
+ * }
+ * if ($newOperationResponse->operationSucceeded()) {
+ * $result = $newOperationResponse->getResult();
+ * // doSomethingWith($result)
+ * } else {
+ * $error = $newOperationResponse->getError();
+ * // handleError($error)
+ * }
+ * } finally {
+ * $textToSpeechLongAudioSynthesizeClient->close();
+ * }
+ * ```
+ *
+ * @param SynthesisInput $input Required. The Synthesizer requires either plain text or SSML as input.
+ * @param AudioConfig $audioConfig Required. The configuration of the synthesized audio.
+ * @param array $optionalArgs {
+ * Optional.
+ *
+ * @type string $parent
+ * The resource states of the request in the form of
+ * `projects/*/locations/*/voices/*`.
+ * @type string $outputGcsUri
+ * Specifies a Cloud Storage URI for the synthesis results. Must be
+ * specified in the format: `gs://bucket_name/object_name`, and the bucket
+ * must already exist.
+ * @type VoiceSelectionParams $voice
+ * The desired voice 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
+ * {@see RetrySettings} for example usage.
+ * }
+ *
+ * @return \Google\ApiCore\OperationResponse
+ *
+ * @throws ApiException if the remote call fails
+ */
+ public function synthesizeLongAudio(
+ $input,
+ $audioConfig,
+ array $optionalArgs = []
+ ) {
+ $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['outputGcsUri'])) {
+ $request->setOutputGcsUri($optionalArgs['outputGcsUri']);
+ }
+
+ if (isset($optionalArgs['voice'])) {
+ $request->setVoice($optionalArgs['voice']);
+ }
+
+ $requestParams = new RequestParamsHeaderDescriptor(
+ $requestParamHeaders
+ );
+ $optionalArgs['headers'] = isset($optionalArgs['headers'])
+ ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
+ : $requestParams->getHeader();
+ return $this->startOperationsCall(
+ 'SynthesizeLongAudio',
+ $optionalArgs,
+ $request,
+ $this->getOperationsClient()
+ )->wait();
+ }
+}
diff --git a/TextToSpeech/src/V1/SynthesisInput.php b/TextToSpeech/src/V1/SynthesisInput.php
index fd3fc0e0666..4e8f0065c3c 100644
--- a/TextToSpeech/src/V1/SynthesisInput.php
+++ b/TextToSpeech/src/V1/SynthesisInput.php
@@ -11,8 +11,8 @@
/**
* Contains text input to be synthesized. Either `text` or `ssml` must be
* supplied. Supplying both or neither returns
- * [google.rpc.Code.INVALID_ARGUMENT][]. The input size is limited to 5000
- * characters.
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. The
+ * input size is limited to 5000 bytes.
*
* Generated from protobuf message google.cloud.texttospeech.v1.SynthesisInput
*/
@@ -31,7 +31,8 @@ class SynthesisInput extends \Google\Protobuf\Internal\Message
* @type string $ssml
* The SSML document to be synthesized. The SSML document must be valid
* and well-formed. Otherwise the RPC will fail and return
- * [google.rpc.Code.INVALID_ARGUMENT][]. For more information, see
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. For
+ * more information, see
* [SSML](https://cloud.google.com/text-to-speech/docs/ssml).
* }
*/
@@ -74,7 +75,8 @@ public function setText($var)
/**
* The SSML document to be synthesized. The SSML document must be valid
* and well-formed. Otherwise the RPC will fail and return
- * [google.rpc.Code.INVALID_ARGUMENT][]. For more information, see
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. For
+ * more information, see
* [SSML](https://cloud.google.com/text-to-speech/docs/ssml).
*
* Generated from protobuf field string ssml = 2;
@@ -93,7 +95,8 @@ public function hasSsml()
/**
* The SSML document to be synthesized. The SSML document must be valid
* and well-formed. Otherwise the RPC will fail and return
- * [google.rpc.Code.INVALID_ARGUMENT][]. For more information, see
+ * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. For
+ * more information, see
* [SSML](https://cloud.google.com/text-to-speech/docs/ssml).
*
* Generated from protobuf field string ssml = 2;
diff --git a/TextToSpeech/src/V1/SynthesizeLongAudioMetadata.php b/TextToSpeech/src/V1/SynthesizeLongAudioMetadata.php
new file mode 100644
index 00000000000..7f23aab7200
--- /dev/null
+++ b/TextToSpeech/src/V1/SynthesizeLongAudioMetadata.php
@@ -0,0 +1,155 @@
+google.cloud.texttospeech.v1.SynthesizeLongAudioMetadata
+ */
+class SynthesizeLongAudioMetadata extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Time when the request was received.
+ *
+ * Generated from protobuf field .google.protobuf.Timestamp start_time = 1;
+ */
+ private $start_time = null;
+ /**
+ * Time of the most recent processing update.
+ *
+ * Generated from protobuf field .google.protobuf.Timestamp last_update_time = 2;
+ */
+ private $last_update_time = null;
+ /**
+ * The progress of the most recent processing update in percentage, ie. 70.0%.
+ *
+ * Generated from protobuf field double progress_percentage = 3;
+ */
+ private $progress_percentage = 0.0;
+
+ /**
+ * Constructor.
+ *
+ * @param array $data {
+ * Optional. Data for populating the Message object.
+ *
+ * @type \Google\Protobuf\Timestamp $start_time
+ * Time when the request was received.
+ * @type \Google\Protobuf\Timestamp $last_update_time
+ * Time of the most recent processing update.
+ * @type float $progress_percentage
+ * The progress of the most recent processing update in percentage, ie. 70.0%.
+ * }
+ */
+ public function __construct($data = NULL) {
+ \GPBMetadata\Google\Cloud\Texttospeech\V1\CloudTtsLrs::initOnce();
+ parent::__construct($data);
+ }
+
+ /**
+ * Time when the request was received.
+ *
+ * Generated from protobuf field .google.protobuf.Timestamp start_time = 1;
+ * @return \Google\Protobuf\Timestamp|null
+ */
+ public function getStartTime()
+ {
+ return $this->start_time;
+ }
+
+ public function hasStartTime()
+ {
+ return isset($this->start_time);
+ }
+
+ public function clearStartTime()
+ {
+ unset($this->start_time);
+ }
+
+ /**
+ * Time when the request was received.
+ *
+ * Generated from protobuf field .google.protobuf.Timestamp start_time = 1;
+ * @param \Google\Protobuf\Timestamp $var
+ * @return $this
+ */
+ public function setStartTime($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
+ $this->start_time = $var;
+
+ return $this;
+ }
+
+ /**
+ * Time of the most recent processing update.
+ *
+ * Generated from protobuf field .google.protobuf.Timestamp last_update_time = 2;
+ * @return \Google\Protobuf\Timestamp|null
+ */
+ public function getLastUpdateTime()
+ {
+ return $this->last_update_time;
+ }
+
+ public function hasLastUpdateTime()
+ {
+ return isset($this->last_update_time);
+ }
+
+ public function clearLastUpdateTime()
+ {
+ unset($this->last_update_time);
+ }
+
+ /**
+ * Time of the most recent processing update.
+ *
+ * Generated from protobuf field .google.protobuf.Timestamp last_update_time = 2;
+ * @param \Google\Protobuf\Timestamp $var
+ * @return $this
+ */
+ public function setLastUpdateTime($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
+ $this->last_update_time = $var;
+
+ return $this;
+ }
+
+ /**
+ * The progress of the most recent processing update in percentage, ie. 70.0%.
+ *
+ * Generated from protobuf field double progress_percentage = 3;
+ * @return float
+ */
+ public function getProgressPercentage()
+ {
+ return $this->progress_percentage;
+ }
+
+ /**
+ * The progress of the most recent processing update in percentage, ie. 70.0%.
+ *
+ * Generated from protobuf field double progress_percentage = 3;
+ * @param float $var
+ * @return $this
+ */
+ public function setProgressPercentage($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->progress_percentage = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/TextToSpeech/src/V1/SynthesizeLongAudioRequest.php b/TextToSpeech/src/V1/SynthesizeLongAudioRequest.php
new file mode 100644
index 00000000000..7b1cac4128d
--- /dev/null
+++ b/TextToSpeech/src/V1/SynthesizeLongAudioRequest.php
@@ -0,0 +1,246 @@
+google.cloud.texttospeech.v1.SynthesizeLongAudioRequest
+ */
+class SynthesizeLongAudioRequest extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * The resource states of the request in the form of
+ * `projects/*/locations/*/voices/*`.
+ *
+ * Generated from protobuf field string parent = 1;
+ */
+ private $parent = '';
+ /**
+ * Required. The Synthesizer requires either plain text or SSML as input.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.SynthesisInput input = 2 [(.google.api.field_behavior) = REQUIRED];
+ */
+ private $input = null;
+ /**
+ * Required. The configuration of the synthesized audio.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.AudioConfig audio_config = 3 [(.google.api.field_behavior) = REQUIRED];
+ */
+ private $audio_config = null;
+ /**
+ * Specifies a Cloud Storage URI for the synthesis results. Must be
+ * specified in the format: `gs://bucket_name/object_name`, and the bucket
+ * must already exist.
+ *
+ * Generated from protobuf field string output_gcs_uri = 4;
+ */
+ private $output_gcs_uri = '';
+ /**
+ * The desired voice of the synthesized audio.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.VoiceSelectionParams voice = 5;
+ */
+ private $voice = null;
+
+ /**
+ * Constructor.
+ *
+ * @param array $data {
+ * Optional. Data for populating the Message object.
+ *
+ * @type string $parent
+ * The resource states of the request in the form of
+ * `projects/*/locations/*/voices/*`.
+ * @type \Google\Cloud\TextToSpeech\V1\SynthesisInput $input
+ * Required. The Synthesizer requires either plain text or SSML as input.
+ * @type \Google\Cloud\TextToSpeech\V1\AudioConfig $audio_config
+ * Required. The configuration of the synthesized audio.
+ * @type string $output_gcs_uri
+ * Specifies a Cloud Storage URI for the synthesis results. Must be
+ * specified in the format: `gs://bucket_name/object_name`, and the bucket
+ * must already exist.
+ * @type \Google\Cloud\TextToSpeech\V1\VoiceSelectionParams $voice
+ * The desired voice of the synthesized audio.
+ * }
+ */
+ public function __construct($data = NULL) {
+ \GPBMetadata\Google\Cloud\Texttospeech\V1\CloudTtsLrs::initOnce();
+ parent::__construct($data);
+ }
+
+ /**
+ * The resource states of the request in the form of
+ * `projects/*/locations/*/voices/*`.
+ *
+ * Generated from protobuf field string parent = 1;
+ * @return string
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * The resource states of the request in the form of
+ * `projects/*/locations/*/voices/*`.
+ *
+ * Generated from protobuf field string parent = 1;
+ * @param string $var
+ * @return $this
+ */
+ public function setParent($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->parent = $var;
+
+ return $this;
+ }
+
+ /**
+ * Required. The Synthesizer requires either plain text or SSML as input.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.SynthesisInput input = 2 [(.google.api.field_behavior) = REQUIRED];
+ * @return \Google\Cloud\TextToSpeech\V1\SynthesisInput|null
+ */
+ public function getInput()
+ {
+ return $this->input;
+ }
+
+ public function hasInput()
+ {
+ return isset($this->input);
+ }
+
+ public function clearInput()
+ {
+ unset($this->input);
+ }
+
+ /**
+ * Required. The Synthesizer requires either plain text or SSML as input.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.SynthesisInput input = 2 [(.google.api.field_behavior) = REQUIRED];
+ * @param \Google\Cloud\TextToSpeech\V1\SynthesisInput $var
+ * @return $this
+ */
+ public function setInput($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\SynthesisInput::class);
+ $this->input = $var;
+
+ return $this;
+ }
+
+ /**
+ * Required. The configuration of the synthesized audio.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.AudioConfig audio_config = 3 [(.google.api.field_behavior) = REQUIRED];
+ * @return \Google\Cloud\TextToSpeech\V1\AudioConfig|null
+ */
+ public function getAudioConfig()
+ {
+ return $this->audio_config;
+ }
+
+ public function hasAudioConfig()
+ {
+ return isset($this->audio_config);
+ }
+
+ public function clearAudioConfig()
+ {
+ unset($this->audio_config);
+ }
+
+ /**
+ * Required. The configuration of the synthesized audio.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.AudioConfig audio_config = 3 [(.google.api.field_behavior) = REQUIRED];
+ * @param \Google\Cloud\TextToSpeech\V1\AudioConfig $var
+ * @return $this
+ */
+ public function setAudioConfig($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\AudioConfig::class);
+ $this->audio_config = $var;
+
+ return $this;
+ }
+
+ /**
+ * Specifies a Cloud Storage URI for the synthesis results. Must be
+ * specified in the format: `gs://bucket_name/object_name`, and the bucket
+ * must already exist.
+ *
+ * Generated from protobuf field string output_gcs_uri = 4;
+ * @return string
+ */
+ public function getOutputGcsUri()
+ {
+ return $this->output_gcs_uri;
+ }
+
+ /**
+ * Specifies a Cloud Storage URI for the synthesis results. Must be
+ * specified in the format: `gs://bucket_name/object_name`, and the bucket
+ * must already exist.
+ *
+ * Generated from protobuf field string output_gcs_uri = 4;
+ * @param string $var
+ * @return $this
+ */
+ public function setOutputGcsUri($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->output_gcs_uri = $var;
+
+ return $this;
+ }
+
+ /**
+ * The desired voice of the synthesized audio.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.VoiceSelectionParams voice = 5;
+ * @return \Google\Cloud\TextToSpeech\V1\VoiceSelectionParams|null
+ */
+ public function getVoice()
+ {
+ return $this->voice;
+ }
+
+ public function hasVoice()
+ {
+ return isset($this->voice);
+ }
+
+ public function clearVoice()
+ {
+ unset($this->voice);
+ }
+
+ /**
+ * The desired voice of the synthesized audio.
+ *
+ * Generated from protobuf field .google.cloud.texttospeech.v1.VoiceSelectionParams voice = 5;
+ * @param \Google\Cloud\TextToSpeech\V1\VoiceSelectionParams $var
+ * @return $this
+ */
+ public function setVoice($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\VoiceSelectionParams::class);
+ $this->voice = $var;
+
+ return $this;
+ }
+
+}
+
diff --git a/TextToSpeech/src/V1/SynthesizeLongAudioResponse.php b/TextToSpeech/src/V1/SynthesizeLongAudioResponse.php
new file mode 100644
index 00000000000..e1a3d25b413
--- /dev/null
+++ b/TextToSpeech/src/V1/SynthesizeLongAudioResponse.php
@@ -0,0 +1,33 @@
+google.cloud.texttospeech.v1.SynthesizeLongAudioResponse
+ */
+class SynthesizeLongAudioResponse extends \Google\Protobuf\Internal\Message
+{
+
+ /**
+ * Constructor.
+ *
+ * @param array $data {
+ * Optional. Data for populating the Message object.
+ *
+ * }
+ */
+ public function __construct($data = NULL) {
+ \GPBMetadata\Google\Cloud\Texttospeech\V1\CloudTtsLrs::initOnce();
+ parent::__construct($data);
+ }
+
+}
+
diff --git a/TextToSpeech/src/V1/TextToSpeechLongAudioSynthesizeClient.php b/TextToSpeech/src/V1/TextToSpeechLongAudioSynthesizeClient.php
new file mode 100644
index 00000000000..8f5aff29208
--- /dev/null
+++ b/TextToSpeech/src/V1/TextToSpeechLongAudioSynthesizeClient.php
@@ -0,0 +1,34 @@
+_simpleRequest('/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio',
+ $argument,
+ ['\Google\LongRunning\Operation', 'decode'],
+ $metadata, $options);
+ }
+
+}
diff --git a/TextToSpeech/src/V1/VoiceSelectionParams.php b/TextToSpeech/src/V1/VoiceSelectionParams.php
index 5e3724d6110..f16860365f0 100644
--- a/TextToSpeech/src/V1/VoiceSelectionParams.php
+++ b/TextToSpeech/src/V1/VoiceSelectionParams.php
@@ -16,9 +16,9 @@
class VoiceSelectionParams extends \Google\Protobuf\Internal\Message
{
/**
- * Required. 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
+ * Required. 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
@@ -64,9 +64,9 @@ class VoiceSelectionParams extends \Google\Protobuf\Internal\Message
* Optional. Data for populating the Message object.
*
* @type string $language_code
- * Required. 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
+ * Required. 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
@@ -96,9 +96,9 @@ public function __construct($data = NULL) {
}
/**
- * Required. 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
+ * Required. 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
@@ -117,9 +117,9 @@ public function getLanguageCode()
}
/**
- * Required. 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
+ * Required. 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
diff --git a/TextToSpeech/src/V1/gapic_metadata.json b/TextToSpeech/src/V1/gapic_metadata.json
index b54cabd9089..a81769c36b8 100644
--- a/TextToSpeech/src/V1/gapic_metadata.json
+++ b/TextToSpeech/src/V1/gapic_metadata.json
@@ -23,6 +23,20 @@
}
}
}
+ },
+ "TextToSpeechLongAudioSynthesize": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "TextToSpeechLongAudioSynthesizeGapicClient",
+ "rpcs": {
+ "SynthesizeLongAudio": {
+ "methods": [
+ "synthesizeLongAudio"
+ ]
+ }
+ }
+ }
+ }
}
}
}
\ No newline at end of file
diff --git a/TextToSpeech/src/V1/resources/text_to_speech_client_config.json b/TextToSpeech/src/V1/resources/text_to_speech_client_config.json
index b06f5913693..819663a1f52 100644
--- a/TextToSpeech/src/V1/resources/text_to_speech_client_config.json
+++ b/TextToSpeech/src/V1/resources/text_to_speech_client_config.json
@@ -6,7 +6,8 @@
"retry_policy_1_codes": [
"UNAVAILABLE",
"DEADLINE_EXCEEDED"
- ]
+ ],
+ "no_retry_1_codes": []
},
"retry_params": {
"no_retry_params": {
@@ -26,6 +27,15 @@
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 300000,
"total_timeout_millis": 300000
+ },
+ "no_retry_1_params": {
+ "initial_retry_delay_millis": 0,
+ "retry_delay_multiplier": 0.0,
+ "max_retry_delay_millis": 0,
+ "initial_rpc_timeout_millis": 5000000,
+ "rpc_timeout_multiplier": 1.0,
+ "max_rpc_timeout_millis": 5000000,
+ "total_timeout_millis": 5000000
}
},
"methods": {
diff --git a/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_client_config.json b/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_client_config.json
new file mode 100644
index 00000000000..1f2cda4e7cf
--- /dev/null
+++ b/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_client_config.json
@@ -0,0 +1,37 @@
+{
+ "interfaces": {
+ "google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize": {
+ "retry_codes": {
+ "no_retry_codes": [],
+ "no_retry_1_codes": []
+ },
+ "retry_params": {
+ "no_retry_params": {
+ "initial_retry_delay_millis": 0,
+ "retry_delay_multiplier": 0.0,
+ "max_retry_delay_millis": 0,
+ "initial_rpc_timeout_millis": 0,
+ "rpc_timeout_multiplier": 1.0,
+ "max_rpc_timeout_millis": 0,
+ "total_timeout_millis": 0
+ },
+ "no_retry_1_params": {
+ "initial_retry_delay_millis": 0,
+ "retry_delay_multiplier": 0.0,
+ "max_retry_delay_millis": 0,
+ "initial_rpc_timeout_millis": 5000000,
+ "rpc_timeout_multiplier": 1.0,
+ "max_rpc_timeout_millis": 5000000,
+ "total_timeout_millis": 5000000
+ }
+ },
+ "methods": {
+ "SynthesizeLongAudio": {
+ "timeout_millis": 5000000,
+ "retry_codes_name": "no_retry_1_codes",
+ "retry_params_name": "no_retry_1_params"
+ }
+ }
+ }
+ }
+}
diff --git a/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_descriptor_config.php b/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_descriptor_config.php
new file mode 100644
index 00000000000..9b9262bbc12
--- /dev/null
+++ b/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_descriptor_config.php
@@ -0,0 +1,18 @@
+ [
+ 'google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize' => [
+ 'SynthesizeLongAudio' => [
+ 'longRunning' => [
+ 'operationReturnType' => '\Google\Cloud\TextToSpeech\V1\SynthesizeLongAudioResponse',
+ 'metadataReturnType' => '\Google\Cloud\TextToSpeech\V1\SynthesizeLongAudioMetadata',
+ 'initialPollDelayMillis' => '500',
+ 'pollDelayMultiplier' => '1.5',
+ 'maxPollDelayMillis' => '5000',
+ 'totalPollTimeoutMillis' => '300000',
+ ],
+ ],
+ ],
+ ],
+];
diff --git a/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_rest_client_config.php b/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_rest_client_config.php
new file mode 100644
index 00000000000..d8108479e29
--- /dev/null
+++ b/TextToSpeech/src/V1/resources/text_to_speech_long_audio_synthesize_rest_client_config.php
@@ -0,0 +1,20 @@
+ [
+ 'google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize' => [
+ 'SynthesizeLongAudio' => [
+ 'method' => 'post',
+ 'uriTemplate' => '/v1/{parent=projects/*/locations/*/voices/*}:SynthesizeLongAudio',
+ 'body' => '*',
+ 'placeholders' => [
+ 'parent' => [
+ 'getters' => [
+ 'getParent',
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+];
diff --git a/TextToSpeech/tests/Unit/V1/TextToSpeechLongAudioSynthesizeClientTest.php b/TextToSpeech/tests/Unit/V1/TextToSpeechLongAudioSynthesizeClientTest.php
new file mode 100644
index 00000000000..c691205c119
--- /dev/null
+++ b/TextToSpeech/tests/Unit/V1/TextToSpeechLongAudioSynthesizeClientTest.php
@@ -0,0 +1,193 @@
+getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
+ }
+
+ /** @return TextToSpeechLongAudioSynthesizeClient */
+ private function createClient(array $options = [])
+ {
+ $options += [
+ 'credentials' => $this->createCredentials(),
+ ];
+ return new TextToSpeechLongAudioSynthesizeClient($options);
+ }
+
+ /** @test */
+ public function synthesizeLongAudioTest()
+ {
+ $operationsTransport = $this->createTransport();
+ $operationsClient = new OperationsClient([
+ 'apiEndpoint' => '',
+ 'transport' => $operationsTransport,
+ 'credentials' => $this->createCredentials(),
+ ]);
+ $transport = $this->createTransport();
+ $gapicClient = $this->createClient([
+ 'transport' => $transport,
+ 'operationsClient' => $operationsClient,
+ ]);
+ $this->assertTrue($transport->isExhausted());
+ $this->assertTrue($operationsTransport->isExhausted());
+ // Mock response
+ $incompleteOperation = new Operation();
+ $incompleteOperation->setName('operations/synthesizeLongAudioTest');
+ $incompleteOperation->setDone(false);
+ $transport->addResponse($incompleteOperation);
+ $expectedResponse = new SynthesizeLongAudioResponse();
+ $anyResponse = new Any();
+ $anyResponse->setValue($expectedResponse->serializeToString());
+ $completeOperation = new Operation();
+ $completeOperation->setName('operations/synthesizeLongAudioTest');
+ $completeOperation->setDone(true);
+ $completeOperation->setResponse($anyResponse);
+ $operationsTransport->addResponse($completeOperation);
+ // Mock request
+ $input = new SynthesisInput();
+ $audioConfig = new AudioConfig();
+ $audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;
+ $audioConfig->setAudioEncoding($audioConfigAudioEncoding);
+ $response = $gapicClient->synthesizeLongAudio($input, $audioConfig);
+ $this->assertFalse($response->isDone());
+ $this->assertNull($response->getResult());
+ $apiRequests = $transport->popReceivedCalls();
+ $this->assertSame(1, count($apiRequests));
+ $operationsRequestsEmpty = $operationsTransport->popReceivedCalls();
+ $this->assertSame(0, count($operationsRequestsEmpty));
+ $actualApiFuncCall = $apiRequests[0]->getFuncCall();
+ $actualApiRequestObject = $apiRequests[0]->getRequestObject();
+ $this->assertSame('/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio', $actualApiFuncCall);
+ $actualValue = $actualApiRequestObject->getInput();
+ $this->assertProtobufEquals($input, $actualValue);
+ $actualValue = $actualApiRequestObject->getAudioConfig();
+ $this->assertProtobufEquals($audioConfig, $actualValue);
+ $expectedOperationsRequestObject = new GetOperationRequest();
+ $expectedOperationsRequestObject->setName('operations/synthesizeLongAudioTest');
+ $response->pollUntilComplete([
+ 'initialPollDelayMillis' => 1,
+ ]);
+ $this->assertTrue($response->isDone());
+ $this->assertEquals($expectedResponse, $response->getResult());
+ $apiRequestsEmpty = $transport->popReceivedCalls();
+ $this->assertSame(0, count($apiRequestsEmpty));
+ $operationsRequests = $operationsTransport->popReceivedCalls();
+ $this->assertSame(1, count($operationsRequests));
+ $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall();
+ $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject();
+ $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall);
+ $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject);
+ $this->assertTrue($transport->isExhausted());
+ $this->assertTrue($operationsTransport->isExhausted());
+ }
+
+ /** @test */
+ public function synthesizeLongAudioExceptionTest()
+ {
+ $operationsTransport = $this->createTransport();
+ $operationsClient = new OperationsClient([
+ 'apiEndpoint' => '',
+ 'transport' => $operationsTransport,
+ 'credentials' => $this->createCredentials(),
+ ]);
+ $transport = $this->createTransport();
+ $gapicClient = $this->createClient([
+ 'transport' => $transport,
+ 'operationsClient' => $operationsClient,
+ ]);
+ $this->assertTrue($transport->isExhausted());
+ $this->assertTrue($operationsTransport->isExhausted());
+ // Mock response
+ $incompleteOperation = new Operation();
+ $incompleteOperation->setName('operations/synthesizeLongAudioTest');
+ $incompleteOperation->setDone(false);
+ $transport->addResponse($incompleteOperation);
+ $status = new stdClass();
+ $status->code = Code::DATA_LOSS;
+ $status->details = 'internal error';
+ $expectedExceptionMessage = json_encode([
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ], JSON_PRETTY_PRINT);
+ $operationsTransport->addResponse(null, $status);
+ // Mock request
+ $input = new SynthesisInput();
+ $audioConfig = new AudioConfig();
+ $audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;
+ $audioConfig->setAudioEncoding($audioConfigAudioEncoding);
+ $response = $gapicClient->synthesizeLongAudio($input, $audioConfig);
+ $this->assertFalse($response->isDone());
+ $this->assertNull($response->getResult());
+ $expectedOperationsRequestObject = new GetOperationRequest();
+ $expectedOperationsRequestObject->setName('operations/synthesizeLongAudioTest');
+ try {
+ $response->pollUntilComplete([
+ 'initialPollDelayMillis' => 1,
+ ]);
+ // If the pollUntilComplete() method call did not throw, fail the test
+ $this->fail('Expected an ApiException, but no exception was thrown.');
+ } catch (ApiException $ex) {
+ $this->assertEquals($status->code, $ex->getCode());
+ $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
+ }
+ // Call popReceivedCalls to ensure the stubs are exhausted
+ $transport->popReceivedCalls();
+ $operationsTransport->popReceivedCalls();
+ $this->assertTrue($transport->isExhausted());
+ $this->assertTrue($operationsTransport->isExhausted());
+ }
+}