diff --git a/TextToSpeech/owlbot.py b/TextToSpeech/owlbot.py
index 6f26c8b7db49..6e99b3c79ca5 100644
--- a/TextToSpeech/owlbot.py
+++ b/TextToSpeech/owlbot.py
@@ -1,4 +1,4 @@
-# Copyright 2018 Google LLC
+# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,31 +32,14 @@
php.owlbot_main(src=src, dest=dest)
-### [START] protoc backwards compatibility fixes
-
-# roll back to private properties.
-s.replace(
- "src/**/V*/**/*.php",
- r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$",
- r"""Generated from protobuf field \1
- */
- private $""")
-
-# Replace "Unwrapped" with "Value" for method names.
-s.replace(
- "src/**/V*/**/*.php",
- r"public function ([s|g]\w{3,})Unwrapped",
- r"public function \1Value"
-)
-
-### [END] protoc backwards compatibility fixes
-
-# fix relative cloud.google.com links
+# remove class_alias code
s.replace(
- "src/**/V*/**/*.php",
- r"(.{0,})\]\((/.{0,})\)",
- r"\1](https://cloud.google.com\2)"
-)
+ "src/V*/**/*.php",
+ r"^// Adding a class alias for backwards compatibility with the previous class name.$"
+ + "\n"
+ + r"^class_alias\(.*\);$"
+ + "\n",
+ '')
# format generated clients
subprocess.run([
@@ -66,8 +49,8 @@
'--package=@prettier/plugin-php@^0.16',
'--',
'prettier',
- '**/Gapic/*',
+ '**/Client/*',
'--write',
'--parser=php',
'--single-quote',
- '--print-width=80'])
+ '--print-width=120'])
diff --git a/TextToSpeech/src/V1/AdvancedVoiceOptions.php b/TextToSpeech/src/V1/AdvancedVoiceOptions.php
index ed664e1ba685..2222ba2fcb32 100644
--- a/TextToSpeech/src/V1/AdvancedVoiceOptions.php
+++ b/TextToSpeech/src/V1/AdvancedVoiceOptions.php
@@ -21,7 +21,7 @@ class AdvancedVoiceOptions extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field optional bool low_latency_journey_synthesis = 1;
*/
- private $low_latency_journey_synthesis = null;
+ protected $low_latency_journey_synthesis = null;
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/AudioConfig.php b/TextToSpeech/src/V1/AudioConfig.php
index 49a0532fadb7..7d299d36de5a 100644
--- a/TextToSpeech/src/V1/AudioConfig.php
+++ b/TextToSpeech/src/V1/AudioConfig.php
@@ -20,7 +20,7 @@ class AudioConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.texttospeech.v1.AudioEncoding audio_encoding = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $audio_encoding = 0;
+ protected $audio_encoding = 0;
/**
* Optional. Input only. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is
* the normal native speed supported by the specific voice. 2.0 is twice as
@@ -29,7 +29,7 @@ class AudioConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field double speaking_rate = 2 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = OPTIONAL];
*/
- private $speaking_rate = 0.0;
+ protected $speaking_rate = 0.0;
/**
* Optional. Input only. Speaking pitch, in the range [-20.0, 20.0]. 20 means
* increase 20 semitones from the original pitch. -20 means decrease 20
@@ -37,7 +37,7 @@ class AudioConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field double pitch = 3 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = OPTIONAL];
*/
- private $pitch = 0.0;
+ protected $pitch = 0.0;
/**
* Optional. Input only. Volume gain (in dB) of the normal native volume
* supported by the specific voice, in the range [-96.0, 16.0]. If unset, or
@@ -50,7 +50,7 @@ class AudioConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field double volume_gain_db = 4 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = OPTIONAL];
*/
- private $volume_gain_db = 0.0;
+ protected $volume_gain_db = 0.0;
/**
* Optional. The synthesis sample rate (in hertz) for this audio. When this is
* specified in SynthesizeSpeechRequest, if this is different from the voice's
@@ -62,7 +62,7 @@ class AudioConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field int32 sample_rate_hertz = 5 [(.google.api.field_behavior) = OPTIONAL];
*/
- private $sample_rate_hertz = 0;
+ protected $sample_rate_hertz = 0;
/**
* Optional. Input only. An identifier which selects 'audio effects' profiles
* that are applied on (post synthesized) text to speech. Effects are applied
diff --git a/TextToSpeech/src/V1/Client/TextToSpeechClient.php b/TextToSpeech/src/V1/Client/TextToSpeechClient.php
index fee05b775d9e..47d825a0d2eb 100644
--- a/TextToSpeech/src/V1/Client/TextToSpeechClient.php
+++ b/TextToSpeech/src/V1/Client/TextToSpeechClient.php
@@ -1,6 +1,6 @@
startApiCall('SynthesizeSpeech', $request, $callOptions)->wait();
}
}
diff --git a/TextToSpeech/src/V1/Client/TextToSpeechLongAudioSynthesizeClient.php b/TextToSpeech/src/V1/Client/TextToSpeechLongAudioSynthesizeClient.php
index 41093acd73df..adb28777c582 100644
--- a/TextToSpeech/src/V1/Client/TextToSpeechLongAudioSynthesizeClient.php
+++ b/TextToSpeech/src/V1/Client/TextToSpeechLongAudioSynthesizeClient.php
@@ -1,6 +1,6 @@
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',
+ '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',
+ 'restClientConfigPath' =>
+ __DIR__ . '/../resources/text_to_speech_long_audio_synthesize_rest_client_config.php',
],
],
];
@@ -124,12 +124,33 @@ public function getOperationsClient()
*/
public function resumeOperation($operationName, $methodName = null)
{
- $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : [];
+ $options = isset($this->descriptors[$methodName]['longRunning'])
+ ? $this->descriptors[$methodName]['longRunning']
+ : [];
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
$operation->reload();
return $operation;
}
+ /**
+ * Create the default operation client for the service.
+ *
+ * @param array $options ClientOptions for the client.
+ *
+ * @return OperationsClient
+ */
+ private function createOperationsClient(array $options)
+ {
+ // Unset client-specific configuration options
+ unset($options['serviceName'], $options['clientConfig'], $options['descriptorsConfigPath']);
+
+ if (isset($options['operationsClient'])) {
+ return $options['operationsClient'];
+ }
+
+ return new OperationsClient($options);
+ }
+
/**
* Formats a string containing the fully-qualified path to represent a model
* resource.
diff --git a/TextToSpeech/src/V1/CustomPronunciationParams.php b/TextToSpeech/src/V1/CustomPronunciationParams.php
index b7ae33a3dadf..2a2283ce0dea 100644
--- a/TextToSpeech/src/V1/CustomPronunciationParams.php
+++ b/TextToSpeech/src/V1/CustomPronunciationParams.php
@@ -22,20 +22,20 @@ class CustomPronunciationParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field optional string phrase = 1;
*/
- private $phrase = null;
+ protected $phrase = null;
/**
* The phonetic encoding of the phrase.
*
* Generated from protobuf field optional .google.cloud.texttospeech.v1.CustomPronunciationParams.PhoneticEncoding phonetic_encoding = 2;
*/
- private $phonetic_encoding = null;
+ protected $phonetic_encoding = null;
/**
* The pronunciation of the phrase. This must be in the phonetic encoding
* specified above.
*
* Generated from protobuf field optional string pronunciation = 3;
*/
- private $pronunciation = null;
+ protected $pronunciation = null;
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/CustomPronunciationParams/PhoneticEncoding.php b/TextToSpeech/src/V1/CustomPronunciationParams/PhoneticEncoding.php
index d7631a1efee4..c75a17431f2a 100644
--- a/TextToSpeech/src/V1/CustomPronunciationParams/PhoneticEncoding.php
+++ b/TextToSpeech/src/V1/CustomPronunciationParams/PhoneticEncoding.php
@@ -61,6 +61,4 @@ public static function value($name)
}
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(PhoneticEncoding::class, \Google\Cloud\TextToSpeech\V1\CustomPronunciationParams_PhoneticEncoding::class);
diff --git a/TextToSpeech/src/V1/CustomVoiceParams.php b/TextToSpeech/src/V1/CustomVoiceParams.php
index 175f22bed38e..bc208aa890c7 100644
--- a/TextToSpeech/src/V1/CustomVoiceParams.php
+++ b/TextToSpeech/src/V1/CustomVoiceParams.php
@@ -20,7 +20,7 @@ class CustomVoiceParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string model = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
*/
- private $model = '';
+ protected $model = '';
/**
* Optional. Deprecated. The usage of the synthesized audio to be reported.
*
diff --git a/TextToSpeech/src/V1/CustomVoiceParams/ReportedUsage.php b/TextToSpeech/src/V1/CustomVoiceParams/ReportedUsage.php
index 6e8d93d63f04..253853aa0e70 100644
--- a/TextToSpeech/src/V1/CustomVoiceParams/ReportedUsage.php
+++ b/TextToSpeech/src/V1/CustomVoiceParams/ReportedUsage.php
@@ -63,6 +63,4 @@ public static function value($name)
}
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(ReportedUsage::class, \Google\Cloud\TextToSpeech\V1\CustomVoiceParams_ReportedUsage::class);
diff --git a/TextToSpeech/src/V1/CustomVoiceParams_ReportedUsage.php b/TextToSpeech/src/V1/CustomVoiceParams_ReportedUsage.php
deleted file mode 100644
index 85d643cbca1f..000000000000
--- a/TextToSpeech/src/V1/CustomVoiceParams_ReportedUsage.php
+++ /dev/null
@@ -1,16 +0,0 @@
-listVoices();
- * } finally {
- * $textToSpeechClient->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.
- *
- * @deprecated Please use the new service client {@see \Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient}.
- */
-class TextToSpeechGapicClient
-{
- use GapicClientTrait;
-
- /** The name of the service. */
- const SERVICE_NAME = 'google.cloud.texttospeech.v1.TextToSpeech';
-
- /**
- * The default address of the service.
- *
- * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead.
- */
- const SERVICE_ADDRESS = 'texttospeech.googleapis.com';
-
- /** The address template of the service. */
- private const SERVICE_ADDRESS_TEMPLATE = 'texttospeech.UNIVERSE_DOMAIN';
-
- /** 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 static $modelNameTemplate;
-
- private static $pathTemplateMap;
-
- private static function getClientDefaults()
- {
- return [
- 'serviceName' => self::SERVICE_NAME,
- 'apiEndpoint' =>
- self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT,
- 'clientConfig' =>
- __DIR__ . '/../resources/text_to_speech_client_config.json',
- 'descriptorsConfigPath' =>
- __DIR__ . '/../resources/text_to_speech_descriptor_config.php',
- 'gcpApiConfigPath' =>
- __DIR__ . '/../resources/text_to_speech_grpc_config.json',
- 'credentialsConfig' => [
- 'defaultScopes' => self::$serviceScopes,
- ],
- 'transportConfig' => [
- 'rest' => [
- 'restClientConfigPath' =>
- __DIR__ .
- '/../resources/text_to_speech_rest_client_config.php',
- ],
- ],
- ];
- }
-
- private static function getModelNameTemplate()
- {
- if (self::$modelNameTemplate == null) {
- self::$modelNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/models/{model}'
- );
- }
-
- return self::$modelNameTemplate;
- }
-
- private static function getPathTemplateMap()
- {
- if (self::$pathTemplateMap == null) {
- self::$pathTemplateMap = [
- 'model' => self::getModelNameTemplate(),
- ];
- }
-
- return self::$pathTemplateMap;
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a model
- * resource.
- *
- * @param string $project
- * @param string $location
- * @param string $model
- *
- * @return string The formatted model resource.
- */
- public static function modelName($project, $location, $model)
- {
- return self::getModelNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'model' => $model,
- ]);
- }
-
- /**
- * Parses a formatted name string and returns an associative array of the components in the name.
- * The following name formats are supported:
- * Template: Pattern
- * - model: projects/{project}/locations/{location}/models/{model}
- *
- * 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.
- *
- * @param string $formattedName The formatted name string
- * @param string $template Optional name of template to match
- *
- * @return array An associative array from name component IDs to component values.
- *
- * @throws ValidationException If $formattedName could not be matched.
- */
- public static function parseName($formattedName, $template = null)
- {
- $templateMap = self::getPathTemplateMap();
- if ($template) {
- if (!isset($templateMap[$template])) {
- throw new ValidationException(
- "Template name $template does not exist"
- );
- }
-
- return $templateMap[$template]->match($formattedName);
- }
-
- foreach ($templateMap as $templateName => $pathTemplate) {
- try {
- return $pathTemplate->match($formattedName);
- } catch (ValidationException $ex) {
- // Swallow the exception to continue trying other path templates
- }
- }
-
- throw new ValidationException(
- "Input did not match any known format. Input: $formattedName"
- );
- }
-
- /**
- * 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);
- }
-
- /**
- * Returns a list of Voice supported for synthesis.
- *
- * Sample code:
- * ```
- * $textToSpeechClient = new TextToSpeechClient();
- * try {
- * $response = $textToSpeechClient->listVoices();
- * } finally {
- * $textToSpeechClient->close();
- * }
- * ```
- *
- * @param array $optionalArgs {
- * Optional.
- *
- * @type string $languageCode
- * Optional. Recommended.
- * [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
- * If not specified, the API will return all supported voices.
- * If specified, the ListVoices call will only return voices that can be used
- * to synthesize this language_code. For example, if you specify `"en-NZ"`,
- * all `"en-NZ"` voices will be returned. If you specify `"no"`, both
- * `"no-\*"` (Norwegian) and `"nb-\*"` (Norwegian Bokmal) voices will be
- * returned.
- * @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\Cloud\TextToSpeech\V1\ListVoicesResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function listVoices(array $optionalArgs = [])
- {
- $request = new ListVoicesRequest();
- if (isset($optionalArgs['languageCode'])) {
- $request->setLanguageCode($optionalArgs['languageCode']);
- }
-
- return $this->startCall(
- 'ListVoices',
- ListVoicesResponse::class,
- $optionalArgs,
- $request
- )->wait();
- }
-
- /**
- * Performs bidirectional streaming speech synthesis: receive audio while
- * sending text.
- *
- * Sample code:
- * ```
- * $textToSpeechClient = new TextToSpeechClient();
- * try {
- * $request = new StreamingSynthesizeRequest();
- * // Write all requests to the server, then read all responses until the
- * // stream is complete
- * $requests = [
- * $request,
- * ];
- * $stream = $textToSpeechClient->streamingSynthesize();
- * $stream->writeAll($requests);
- * foreach ($stream->closeWriteAndReadAll() as $element) {
- * // doSomethingWith($element);
- * }
- * // Alternatively:
- * // Write requests individually, making read() calls if
- * // required. Call closeWrite() once writes are complete, and read the
- * // remaining responses from the server.
- * $requests = [
- * $request,
- * ];
- * $stream = $textToSpeechClient->streamingSynthesize();
- * foreach ($requests as $request) {
- * $stream->write($request);
- * // if required, read a single response from the stream
- * $element = $stream->read();
- * // doSomethingWith($element)
- * }
- * $stream->closeWrite();
- * $element = $stream->read();
- * while (!is_null($element)) {
- * // doSomethingWith($element)
- * $element = $stream->read();
- * }
- * } finally {
- * $textToSpeechClient->close();
- * }
- * ```
- *
- * @param array $optionalArgs {
- * Optional.
- *
- * @type int $timeoutMillis
- * Timeout to use for this call.
- * }
- *
- * @return \Google\ApiCore\BidiStream
- *
- * @throws ApiException if the remote call fails
- */
- public function streamingSynthesize(array $optionalArgs = [])
- {
- return $this->startCall(
- 'StreamingSynthesize',
- StreamingSynthesizeResponse::class,
- $optionalArgs,
- null,
- Call::BIDI_STREAMING_CALL
- );
- }
-
- /**
- * Synthesizes speech synchronously: receive results after all text input
- * has been processed.
- *
- * Sample code:
- * ```
- * $textToSpeechClient = new TextToSpeechClient();
- * try {
- * $input = new SynthesisInput();
- * $voice = new VoiceSelectionParams();
- * $audioConfig = new AudioConfig();
- * $response = $textToSpeechClient->synthesizeSpeech($input, $voice, $audioConfig);
- * } 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 {
- * Optional.
- *
- * @type AdvancedVoiceOptions $advancedVoiceOptions
- * Advanced voice options.
- * @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\Cloud\TextToSpeech\V1\SynthesizeSpeechResponse
- *
- * @throws ApiException if the remote call fails
- */
- public function synthesizeSpeech(
- $input,
- $voice,
- $audioConfig,
- array $optionalArgs = []
- ) {
- $request = new SynthesizeSpeechRequest();
- $request->setInput($input);
- $request->setVoice($voice);
- $request->setAudioConfig($audioConfig);
- if (isset($optionalArgs['advancedVoiceOptions'])) {
- $request->setAdvancedVoiceOptions(
- $optionalArgs['advancedVoiceOptions']
- );
- }
-
- return $this->startCall(
- 'SynthesizeSpeech',
- SynthesizeSpeechResponse::class,
- $optionalArgs,
- $request
- )->wait();
- }
-}
diff --git a/TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php b/TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php
deleted file mode 100644
index 466a0f5c3406..000000000000
--- a/TextToSpeech/src/V1/Gapic/TextToSpeechLongAudioSynthesizeGapicClient.php
+++ /dev/null
@@ -1,436 +0,0 @@
-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();
- * }
- * ```
- *
- * 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.
- *
- * @deprecated Please use the new service client {@see \Google\Cloud\TextToSpeech\V1\Client\TextToSpeechLongAudioSynthesizeClient}.
- */
-class TextToSpeechLongAudioSynthesizeGapicClient
-{
- use GapicClientTrait;
-
- /** The name of the service. */
- const SERVICE_NAME = 'google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize';
-
- /**
- * The default address of the service.
- *
- * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead.
- */
- const SERVICE_ADDRESS = 'texttospeech.googleapis.com';
-
- /** The address template of the service. */
- private const SERVICE_ADDRESS_TEMPLATE = 'texttospeech.UNIVERSE_DOMAIN';
-
- /** 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 static $modelNameTemplate;
-
- private static $pathTemplateMap;
-
- 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',
- ],
- ],
- ];
- }
-
- private static function getModelNameTemplate()
- {
- if (self::$modelNameTemplate == null) {
- self::$modelNameTemplate = new PathTemplate(
- 'projects/{project}/locations/{location}/models/{model}'
- );
- }
-
- return self::$modelNameTemplate;
- }
-
- private static function getPathTemplateMap()
- {
- if (self::$pathTemplateMap == null) {
- self::$pathTemplateMap = [
- 'model' => self::getModelNameTemplate(),
- ];
- }
-
- return self::$pathTemplateMap;
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent a model
- * resource.
- *
- * @param string $project
- * @param string $location
- * @param string $model
- *
- * @return string The formatted model resource.
- */
- public static function modelName($project, $location, $model)
- {
- return self::getModelNameTemplate()->render([
- 'project' => $project,
- 'location' => $location,
- 'model' => $model,
- ]);
- }
-
- /**
- * Parses a formatted name string and returns an associative array of the components in the name.
- * The following name formats are supported:
- * Template: Pattern
- * - model: projects/{project}/locations/{location}/models/{model}
- *
- * 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.
- *
- * @param string $formattedName The formatted name string
- * @param string $template Optional name of template to match
- *
- * @return array An associative array from name component IDs to component values.
- *
- * @throws ValidationException If $formattedName could not be matched.
- */
- public static function parseName($formattedName, $template = null)
- {
- $templateMap = self::getPathTemplateMap();
- if ($template) {
- if (!isset($templateMap[$template])) {
- throw new ValidationException(
- "Template name $template does not exist"
- );
- }
-
- return $templateMap[$template]->match($formattedName);
- }
-
- foreach ($templateMap as $templateName => $pathTemplate) {
- try {
- return $pathTemplate->match($formattedName);
- } catch (ValidationException $ex) {
- // Swallow the exception to continue trying other path templates
- }
- }
-
- throw new ValidationException(
- "Input did not match any known format. Input: $formattedName"
- );
- }
-
- /**
- * 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/*`.
- * @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
- * must already exist.
- * @type VoiceSelectionParams $voice
- * Required. 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/ListVoicesRequest.php b/TextToSpeech/src/V1/ListVoicesRequest.php
index 9e798c977161..a1f5971ee7a9 100644
--- a/TextToSpeech/src/V1/ListVoicesRequest.php
+++ b/TextToSpeech/src/V1/ListVoicesRequest.php
@@ -27,7 +27,7 @@ class ListVoicesRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string language_code = 1 [(.google.api.field_behavior) = OPTIONAL];
*/
- private $language_code = '';
+ protected $language_code = '';
/**
* @param string $languageCode Optional. Recommended.
diff --git a/TextToSpeech/src/V1/MultiSpeakerMarkup/Turn.php b/TextToSpeech/src/V1/MultiSpeakerMarkup/Turn.php
index 380e3001b4ed..98d51e27a86b 100644
--- a/TextToSpeech/src/V1/MultiSpeakerMarkup/Turn.php
+++ b/TextToSpeech/src/V1/MultiSpeakerMarkup/Turn.php
@@ -21,13 +21,13 @@ class Turn extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string speaker = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $speaker = '';
+ protected $speaker = '';
/**
* Required. The text to speak.
*
* Generated from protobuf field string text = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $text = '';
+ protected $text = '';
/**
* Constructor.
@@ -103,6 +103,4 @@ public function setText($var)
}
-// Adding a class alias for backwards compatibility with the previous class name.
-class_alias(Turn::class, \Google\Cloud\TextToSpeech\V1\MultiSpeakerMarkup_Turn::class);
diff --git a/TextToSpeech/src/V1/README.md b/TextToSpeech/src/V1/README.md
deleted file mode 100644
index c553df84b19e..000000000000
--- a/TextToSpeech/src/V1/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Google Cloud Text-to-Speech V1 generated client for PHP
-
-### Sample
-
-```php
-require __DIR__ . '/vendor/autoload.php';
-
-use Google\Cloud\TextToSpeech\V1\AudioConfig;
-use Google\Cloud\TextToSpeech\V1\AudioEncoding;
-use Google\Cloud\TextToSpeech\V1\SynthesisInput;
-use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
-use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
-
-$textToSpeechClient = new TextToSpeechClient();
-
-$input = new SynthesisInput();
-$input->setText('Japan\'s national soccer team won against Colombia!');
-$voice = new VoiceSelectionParams();
-$voice->setLanguageCode('en-US');
-$audioConfig = new AudioConfig();
-$audioConfig->setAudioEncoding(AudioEncoding::MP3);
-
-$resp = $textToSpeechClient->synthesizeSpeech($input, $voice, $audioConfig);
-file_put_contents('test.mp3', $resp->getAudioContent());
-```
diff --git a/TextToSpeech/src/V1/StreamingSynthesizeConfig.php b/TextToSpeech/src/V1/StreamingSynthesizeConfig.php
index 5cc55b9ba05f..85db9a292704 100644
--- a/TextToSpeech/src/V1/StreamingSynthesizeConfig.php
+++ b/TextToSpeech/src/V1/StreamingSynthesizeConfig.php
@@ -20,7 +20,7 @@ class StreamingSynthesizeConfig extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.texttospeech.v1.VoiceSelectionParams voice = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $voice = null;
+ protected $voice = null;
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/StreamingSynthesizeResponse.php b/TextToSpeech/src/V1/StreamingSynthesizeResponse.php
index fba3170cc07a..34eb029802fd 100644
--- a/TextToSpeech/src/V1/StreamingSynthesizeResponse.php
+++ b/TextToSpeech/src/V1/StreamingSynthesizeResponse.php
@@ -23,7 +23,7 @@ class StreamingSynthesizeResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field bytes audio_content = 1;
*/
- private $audio_content = '';
+ protected $audio_content = '';
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/SynthesisInput.php b/TextToSpeech/src/V1/SynthesisInput.php
index d0cee9b951b4..35aa6a12b35e 100644
--- a/TextToSpeech/src/V1/SynthesisInput.php
+++ b/TextToSpeech/src/V1/SynthesisInput.php
@@ -32,7 +32,7 @@ class SynthesisInput extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.texttospeech.v1.CustomPronunciations custom_pronunciations = 3 [(.google.api.field_behavior) = OPTIONAL];
*/
- private $custom_pronunciations = null;
+ protected $custom_pronunciations = null;
protected $input_source;
/**
diff --git a/TextToSpeech/src/V1/SynthesizeLongAudioMetadata.php b/TextToSpeech/src/V1/SynthesizeLongAudioMetadata.php
index e19a87f60d32..ab9407b4e614 100644
--- a/TextToSpeech/src/V1/SynthesizeLongAudioMetadata.php
+++ b/TextToSpeech/src/V1/SynthesizeLongAudioMetadata.php
@@ -20,7 +20,7 @@ class SynthesizeLongAudioMetadata extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.protobuf.Timestamp start_time = 1;
*/
- private $start_time = null;
+ protected $start_time = null;
/**
* Deprecated. Do not use.
*
@@ -33,7 +33,7 @@ class SynthesizeLongAudioMetadata extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field double progress_percentage = 3;
*/
- private $progress_percentage = 0.0;
+ protected $progress_percentage = 0.0;
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/SynthesizeLongAudioRequest.php b/TextToSpeech/src/V1/SynthesizeLongAudioRequest.php
index b33d6ad93030..951eaaae4f4d 100644
--- a/TextToSpeech/src/V1/SynthesizeLongAudioRequest.php
+++ b/TextToSpeech/src/V1/SynthesizeLongAudioRequest.php
@@ -22,19 +22,19 @@ class SynthesizeLongAudioRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string parent = 1;
*/
- private $parent = '';
+ protected $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;
+ protected $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;
+ protected $audio_config = null;
/**
* Required. Specifies a Cloud Storage URI for the synthesis results. Must be
* specified in the format: `gs://bucket_name/object_name`, and the bucket
@@ -42,13 +42,13 @@ class SynthesizeLongAudioRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string output_gcs_uri = 4 [(.google.api.field_behavior) = REQUIRED];
*/
- private $output_gcs_uri = '';
+ protected $output_gcs_uri = '';
/**
* Required. The desired voice of the synthesized audio.
*
* Generated from protobuf field .google.cloud.texttospeech.v1.VoiceSelectionParams voice = 5 [(.google.api.field_behavior) = REQUIRED];
*/
- private $voice = null;
+ protected $voice = null;
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/SynthesizeSpeechRequest.php b/TextToSpeech/src/V1/SynthesizeSpeechRequest.php
index 706d3b0e9cb4..ee0e47f31fe5 100644
--- a/TextToSpeech/src/V1/SynthesizeSpeechRequest.php
+++ b/TextToSpeech/src/V1/SynthesizeSpeechRequest.php
@@ -20,25 +20,25 @@ class SynthesizeSpeechRequest extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.texttospeech.v1.SynthesisInput input = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $input = null;
+ protected $input = null;
/**
* Required. The desired voice of the synthesized audio.
*
* Generated from protobuf field .google.cloud.texttospeech.v1.VoiceSelectionParams voice = 2 [(.google.api.field_behavior) = REQUIRED];
*/
- private $voice = null;
+ protected $voice = 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;
+ protected $audio_config = null;
/**
* Advanced voice options.
*
* Generated from protobuf field optional .google.cloud.texttospeech.v1.AdvancedVoiceOptions advanced_voice_options = 8;
*/
- private $advanced_voice_options = null;
+ protected $advanced_voice_options = null;
/**
* @param \Google\Cloud\TextToSpeech\V1\SynthesisInput $input Required. The Synthesizer requires either plain text or SSML as input.
diff --git a/TextToSpeech/src/V1/SynthesizeSpeechResponse.php b/TextToSpeech/src/V1/SynthesizeSpeechResponse.php
index b53a96aa3a18..bfe3329eb5e2 100644
--- a/TextToSpeech/src/V1/SynthesizeSpeechResponse.php
+++ b/TextToSpeech/src/V1/SynthesizeSpeechResponse.php
@@ -24,7 +24,7 @@ class SynthesizeSpeechResponse extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field bytes audio_content = 1;
*/
- private $audio_content = '';
+ protected $audio_content = '';
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/TextToSpeechClient.php b/TextToSpeech/src/V1/TextToSpeechClient.php
deleted file mode 100644
index f24c28dac4d1..000000000000
--- a/TextToSpeech/src/V1/TextToSpeechClient.php
+++ /dev/null
@@ -1,34 +0,0 @@
-_simpleRequest('/google.cloud.texttospeech.v1.TextToSpeech/ListVoices',
- $argument,
- ['\Google\Cloud\TextToSpeech\V1\ListVoicesResponse', 'decode'],
- $metadata, $options);
- }
-
- /**
- * Synthesizes speech synchronously: receive results after all text input
- * has been processed.
- * @param \Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest $argument input argument
- * @param array $metadata metadata
- * @param array $options call options
- * @return \Grpc\UnaryCall
- */
- public function SynthesizeSpeech(\Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest $argument,
- $metadata = [], $options = []) {
- return $this->_simpleRequest('/google.cloud.texttospeech.v1.TextToSpeech/SynthesizeSpeech',
- $argument,
- ['\Google\Cloud\TextToSpeech\V1\SynthesizeSpeechResponse', 'decode'],
- $metadata, $options);
- }
-
-}
diff --git a/TextToSpeech/src/V1/TextToSpeechLongAudioSynthesizeClient.php b/TextToSpeech/src/V1/TextToSpeechLongAudioSynthesizeClient.php
deleted file mode 100644
index 8f5aff29208a..000000000000
--- a/TextToSpeech/src/V1/TextToSpeechLongAudioSynthesizeClient.php
+++ /dev/null
@@ -1,34 +0,0 @@
-_simpleRequest('/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio',
- $argument,
- ['\Google\LongRunning\Operation', 'decode'],
- $metadata, $options);
- }
-
-}
diff --git a/TextToSpeech/src/V1/Voice.php b/TextToSpeech/src/V1/Voice.php
index e79780e350e4..f53642965390 100644
--- a/TextToSpeech/src/V1/Voice.php
+++ b/TextToSpeech/src/V1/Voice.php
@@ -28,19 +28,19 @@ class Voice extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 2;
*/
- private $name = '';
+ protected $name = '';
/**
* The gender of this voice.
*
* Generated from protobuf field .google.cloud.texttospeech.v1.SsmlVoiceGender ssml_gender = 3;
*/
- private $ssml_gender = 0;
+ protected $ssml_gender = 0;
/**
* The natural sample rate (in hertz) for this voice.
*
* Generated from protobuf field int32 natural_sample_rate_hertz = 4;
*/
- private $natural_sample_rate_hertz = 0;
+ protected $natural_sample_rate_hertz = 0;
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/VoiceCloneParams.php b/TextToSpeech/src/V1/VoiceCloneParams.php
index dcdf28485990..83d52d421f52 100644
--- a/TextToSpeech/src/V1/VoiceCloneParams.php
+++ b/TextToSpeech/src/V1/VoiceCloneParams.php
@@ -20,7 +20,7 @@ class VoiceCloneParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string voice_cloning_key = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $voice_cloning_key = '';
+ protected $voice_cloning_key = '';
/**
* Constructor.
diff --git a/TextToSpeech/src/V1/VoiceSelectionParams.php b/TextToSpeech/src/V1/VoiceSelectionParams.php
index 2075fbe1535a..5ccf9c11db9b 100644
--- a/TextToSpeech/src/V1/VoiceSelectionParams.php
+++ b/TextToSpeech/src/V1/VoiceSelectionParams.php
@@ -30,7 +30,7 @@ class VoiceSelectionParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string language_code = 1 [(.google.api.field_behavior) = REQUIRED];
*/
- private $language_code = '';
+ protected $language_code = '';
/**
* The name of the voice. If both the name and the gender are not set,
* the service will choose a voice based on the other parameters such as
@@ -38,7 +38,7 @@ class VoiceSelectionParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field string name = 2;
*/
- private $name = '';
+ protected $name = '';
/**
* The preferred gender of the voice. If not set, the service will
* choose a voice based on the other parameters such as language_code and
@@ -48,7 +48,7 @@ class VoiceSelectionParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.texttospeech.v1.SsmlVoiceGender ssml_gender = 3;
*/
- private $ssml_gender = 0;
+ protected $ssml_gender = 0;
/**
* The configuration for a custom voice. If [CustomVoiceParams.model] is set,
* the service will choose the custom voice matching the specified
@@ -56,7 +56,7 @@ class VoiceSelectionParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.texttospeech.v1.CustomVoiceParams custom_voice = 4;
*/
- private $custom_voice = null;
+ protected $custom_voice = null;
/**
* Optional. The configuration for a voice clone. If
* [VoiceCloneParams.voice_clone_key] is set, the service will choose the
@@ -64,7 +64,7 @@ class VoiceSelectionParams extends \Google\Protobuf\Internal\Message
*
* Generated from protobuf field .google.cloud.texttospeech.v1.VoiceCloneParams voice_clone = 5 [(.google.api.field_behavior) = OPTIONAL];
*/
- private $voice_clone = null;
+ protected $voice_clone = null;
/**
* Constructor.
diff --git a/TextToSpeech/tests/System/V1/TextToSpeechSmokeTest.php b/TextToSpeech/tests/System/V1/TextToSpeechSmokeTest.php
deleted file mode 100644
index 53f5c3e1d588..000000000000
--- a/TextToSpeech/tests/System/V1/TextToSpeechSmokeTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-setText($text);
- $languageCode = 'en-US';
- $voice = new VoiceSelectionParams();
- $voice->setLanguageCode($languageCode);
- $audioEncoding = AudioEncoding::MP3;
- $audioConfig = new AudioConfig();
- $audioConfig->setAudioEncoding($audioEncoding);
- $textToSpeechClient->synthesizeSpeech($input, $voice, $audioConfig);
- }
-}
diff --git a/TextToSpeech/tests/System/bootstrap.php b/TextToSpeech/tests/System/bootstrap.php
deleted file mode 100644
index 30d98dd46349..000000000000
--- a/TextToSpeech/tests/System/bootstrap.php
+++ /dev/null
@@ -1,10 +0,0 @@
-getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
+ return $this->getMockBuilder(CredentialsWrapper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
}
/** @return TextToSpeechClient */
@@ -102,12 +104,15 @@ public function listVoicesExceptionTest()
$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);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
$request = new ListVoicesRequest();
try {
@@ -153,10 +158,7 @@ public function streamingSynthesizeTest()
$bidi->write($request);
$responses = [];
$responses[] = $bidi->read();
- $bidi->writeAll([
- $request2,
- $request3,
- ]);
+ $bidi->writeAll([$request2, $request3]);
foreach ($bidi->closeWriteAndReadAll() as $response) {
$responses[] = $response;
}
@@ -194,12 +196,15 @@ public function streamingSynthesizeExceptionTest()
$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);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->setStreamingStatus($status);
$this->assertTrue($transport->isExhausted());
$bidi = $gapicClient->streamingSynthesize();
@@ -269,12 +274,15 @@ public function synthesizeSpeechExceptionTest()
$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);
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
$transport->addResponse(null, $status);
// Mock request
$input = new SynthesisInput();
diff --git a/TextToSpeech/tests/Unit/V1/Client/TextToSpeechLongAudioSynthesizeClientTest.php b/TextToSpeech/tests/Unit/V1/Client/TextToSpeechLongAudioSynthesizeClientTest.php
index 6ad2ea41bb10..609624e4be2d 100644
--- a/TextToSpeech/tests/Unit/V1/Client/TextToSpeechLongAudioSynthesizeClientTest.php
+++ b/TextToSpeech/tests/Unit/V1/Client/TextToSpeechLongAudioSynthesizeClientTest.php
@@ -1,6 +1,6 @@
getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
+ return $this->getMockBuilder(CredentialsWrapper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
}
/** @return TextToSpeechLongAudioSynthesizeClient */
@@ -101,9 +103,7 @@ public function synthesizeLongAudioTest()
$audioConfig = new AudioConfig();
$audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;
$audioConfig->setAudioEncoding($audioConfigAudioEncoding);
- $request = (new SynthesizeLongAudioRequest())
- ->setInput($input)
- ->setAudioConfig($audioConfig);
+ $request = (new SynthesizeLongAudioRequest())->setInput($input)->setAudioConfig($audioConfig);
$response = $gapicClient->synthesizeLongAudio($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -113,7 +113,10 @@ public function synthesizeLongAudioTest()
$this->assertSame(0, count($operationsRequestsEmpty));
$actualApiFuncCall = $apiRequests[0]->getFuncCall();
$actualApiRequestObject = $apiRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio', $actualApiFuncCall);
+ $this->assertSame(
+ '/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio',
+ $actualApiFuncCall
+ );
$actualValue = $actualApiRequestObject->getInput();
$this->assertProtobufEquals($input, $actualValue);
$actualValue = $actualApiRequestObject->getAudioConfig();
@@ -161,21 +164,22 @@ public function synthesizeLongAudioExceptionTest()
$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);
+ $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);
- $request = (new SynthesizeLongAudioRequest())
- ->setInput($input)
- ->setAudioConfig($audioConfig);
+ $request = (new SynthesizeLongAudioRequest())->setInput($input)->setAudioConfig($audioConfig);
$response = $gapicClient->synthesizeLongAudio($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -232,9 +236,7 @@ public function synthesizeLongAudioAsyncTest()
$audioConfig = new AudioConfig();
$audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;
$audioConfig->setAudioEncoding($audioConfigAudioEncoding);
- $request = (new SynthesizeLongAudioRequest())
- ->setInput($input)
- ->setAudioConfig($audioConfig);
+ $request = (new SynthesizeLongAudioRequest())->setInput($input)->setAudioConfig($audioConfig);
$response = $gapicClient->synthesizeLongAudioAsync($request)->wait();
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
@@ -244,7 +246,10 @@ public function synthesizeLongAudioAsyncTest()
$this->assertSame(0, count($operationsRequestsEmpty));
$actualApiFuncCall = $apiRequests[0]->getFuncCall();
$actualApiRequestObject = $apiRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio', $actualApiFuncCall);
+ $this->assertSame(
+ '/google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize/SynthesizeLongAudio',
+ $actualApiFuncCall
+ );
$actualValue = $actualApiRequestObject->getInput();
$this->assertProtobufEquals($input, $actualValue);
$actualValue = $actualApiRequestObject->getAudioConfig();
diff --git a/TextToSpeech/tests/Unit/V1/TextToSpeechClientTest.php b/TextToSpeech/tests/Unit/V1/TextToSpeechClientTest.php
deleted file mode 100644
index 7b53cfef4a1f..000000000000
--- a/TextToSpeech/tests/Unit/V1/TextToSpeechClientTest.php
+++ /dev/null
@@ -1,291 +0,0 @@
-getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock();
- }
-
- /** @return TextToSpeechClient */
- private function createClient(array $options = [])
- {
- $options += [
- 'credentials' => $this->createCredentials(),
- ];
- return new TextToSpeechClient($options);
- }
-
- /** @test */
- public function listVoicesTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $expectedResponse = new ListVoicesResponse();
- $transport->addResponse($expectedResponse);
- $response = $gapicClient->listVoices();
- $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/ListVoices', $actualFuncCall);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function listVoicesExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $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);
- $transport->addResponse(null, $status);
- try {
- $gapicClient->listVoices();
- // If the $gapicClient 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 stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function streamingSynthesizeTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $audioContent = '16';
- $expectedResponse = new StreamingSynthesizeResponse();
- $expectedResponse->setAudioContent($audioContent);
- $transport->addResponse($expectedResponse);
- $audioContent2 = '-61';
- $expectedResponse2 = new StreamingSynthesizeResponse();
- $expectedResponse2->setAudioContent($audioContent2);
- $transport->addResponse($expectedResponse2);
- $audioContent3 = '-60';
- $expectedResponse3 = new StreamingSynthesizeResponse();
- $expectedResponse3->setAudioContent($audioContent3);
- $transport->addResponse($expectedResponse3);
- // Mock request
- $request = new StreamingSynthesizeRequest();
- $request2 = new StreamingSynthesizeRequest();
- $request3 = new StreamingSynthesizeRequest();
- $bidi = $gapicClient->streamingSynthesize();
- $this->assertInstanceOf(BidiStream::class, $bidi);
- $bidi->write($request);
- $responses = [];
- $responses[] = $bidi->read();
- $bidi->writeAll([
- $request2,
- $request3,
- ]);
- foreach ($bidi->closeWriteAndReadAll() as $response) {
- $responses[] = $response;
- }
-
- $expectedResponses = [];
- $expectedResponses[] = $expectedResponse;
- $expectedResponses[] = $expectedResponse2;
- $expectedResponses[] = $expectedResponse3;
- $this->assertEquals($expectedResponses, $responses);
- $createStreamRequests = $transport->popReceivedCalls();
- $this->assertSame(1, count($createStreamRequests));
- $streamFuncCall = $createStreamRequests[0]->getFuncCall();
- $streamRequestObject = $createStreamRequests[0]->getRequestObject();
- $this->assertSame('/google.cloud.texttospeech.v1.TextToSpeech/StreamingSynthesize', $streamFuncCall);
- $this->assertNull($streamRequestObject);
- $callObjects = $transport->popCallObjects();
- $this->assertSame(1, count($callObjects));
- $bidiCall = $callObjects[0];
- $writeRequests = $bidiCall->popReceivedCalls();
- $expectedRequests = [];
- $expectedRequests[] = $request;
- $expectedRequests[] = $request2;
- $expectedRequests[] = $request3;
- $this->assertEquals($expectedRequests, $writeRequests);
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function streamingSynthesizeExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $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);
- $transport->setStreamingStatus($status);
- $this->assertTrue($transport->isExhausted());
- $bidi = $gapicClient->streamingSynthesize();
- $results = $bidi->closeWriteAndReadAll();
- try {
- iterator_to_array($results);
- // If the close stream 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 stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-
- /** @test */
- public function synthesizeSpeechTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- // Mock response
- $audioContent = '16';
- $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);
- $response = $gapicClient->synthesizeSpeech($input, $voice, $audioConfig);
- $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());
- }
-
- /** @test */
- public function synthesizeSpeechExceptionTest()
- {
- $transport = $this->createTransport();
- $gapicClient = $this->createClient([
- 'transport' => $transport,
- ]);
- $this->assertTrue($transport->isExhausted());
- $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);
- $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);
- try {
- $gapicClient->synthesizeSpeech($input, $voice, $audioConfig);
- // If the $gapicClient 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 stub is exhausted
- $transport->popReceivedCalls();
- $this->assertTrue($transport->isExhausted());
- }
-}
diff --git a/TextToSpeech/tests/Unit/V1/TextToSpeechLongAudioSynthesizeClientTest.php b/TextToSpeech/tests/Unit/V1/TextToSpeechLongAudioSynthesizeClientTest.php
deleted file mode 100644
index c691205c1191..000000000000
--- a/TextToSpeech/tests/Unit/V1/TextToSpeechLongAudioSynthesizeClientTest.php
+++ /dev/null
@@ -1,193 +0,0 @@
-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());
- }
-}