From ce39c2ef70b75bda13fde63335fd6810480d606d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:13:49 -0700 Subject: [PATCH] feat: Add low latency journey option to proto (#7740) feat: Add CustomPronunciationParams for upcoming feature work PiperOrigin-RevId: 684229364 Source-Link: https://github.com/googleapis/googleapis/commit/10b8dc3b54c9a609dcfda8060b8c4c734a942e8c Source-Link: https://github.com/googleapis/googleapis-gen/commit/deaa9f319f1c6c19a9d36ea233ae307566b60c09 Copy-Tag: eyJwIjoiVGV4dFRvU3BlZWNoLy5Pd2xCb3QueWFtbCIsImgiOiJkZWFhOWYzMTlmMWM2YzE5YTlkMzZlYTIzM2FlMzA3NTY2YjYwYzA5In0= --- TextToSpeech/metadata/V1/CloudTts.php | Bin 3799 -> 4560 bytes TextToSpeech/src/V1/AdvancedVoiceOptions.php | 81 ++++++++ .../src/V1/CustomPronunciationParams.php | 177 ++++++++++++++++++ .../PhoneticEncoding.php | 66 +++++++ TextToSpeech/src/V1/CustomPronunciations.php | 67 +++++++ .../src/V1/Gapic/TextToSpeechGapicClient.php | 9 + TextToSpeech/src/V1/SynthesisInput.php | 80 ++++++++ .../src/V1/SynthesizeSpeechRequest.php | 44 +++++ 8 files changed, 524 insertions(+) create mode 100644 TextToSpeech/src/V1/AdvancedVoiceOptions.php create mode 100644 TextToSpeech/src/V1/CustomPronunciationParams.php create mode 100644 TextToSpeech/src/V1/CustomPronunciationParams/PhoneticEncoding.php create mode 100644 TextToSpeech/src/V1/CustomPronunciations.php diff --git a/TextToSpeech/metadata/V1/CloudTts.php b/TextToSpeech/metadata/V1/CloudTts.php index a86c3cb37db2dccc4318e238459be291e9ab8c95..3125c7df3ed56a36b203843004a7237903f7e3ab 100644 GIT binary patch delta 690 zcmaJ;%SyvQ6m`;8?G;NMtEOtCrY?#U5jU=r8ch(}fY03!(r6-frgT!Jxad;1S`a@& z@DKC{+zEo9OSgW3=|gC>y1Q`hx#ym9o~5Vs-GdN*lpuSxnZ5rME|6PkA*MoEQKkqG>9iG;q=_rT* zPs3=rTU-nU@kDhYz+?vTpCmjFlBpN++K!PUT0U1;Gx8f`H@|IaIb+?>>TB@$r zJBF#m5tbnN8#*A{%2ogiY7~Y@+q9Yh9E?A#s&R;so`2;dNOXBle}~9%0b)Iy&E`Xy vk(JdTrr9paH=`Z9e2W@~k>we@2NQOyn_fLGhMI-<>y4|SHwE3_M3m?k9Sh^o delta 45 zcmV+|0Mh@^Bi9|U!U6=!7YZzqODwbU0*3(t=>e1B1nC4KKnf0%`wJeECkPO;j|f2t Dhyf3l diff --git a/TextToSpeech/src/V1/AdvancedVoiceOptions.php b/TextToSpeech/src/V1/AdvancedVoiceOptions.php new file mode 100644 index 000000000000..ed664e1ba685 --- /dev/null +++ b/TextToSpeech/src/V1/AdvancedVoiceOptions.php @@ -0,0 +1,81 @@ +google.cloud.texttospeech.v1.AdvancedVoiceOptions + */ +class AdvancedVoiceOptions extends \Google\Protobuf\Internal\Message +{ + /** + * Only for Journey voices. If false, the synthesis will be context aware + * and have higher latency. + * + * Generated from protobuf field optional bool low_latency_journey_synthesis = 1; + */ + private $low_latency_journey_synthesis = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $low_latency_journey_synthesis + * Only for Journey voices. If false, the synthesis will be context aware + * and have higher latency. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Texttospeech\V1\CloudTts::initOnce(); + parent::__construct($data); + } + + /** + * Only for Journey voices. If false, the synthesis will be context aware + * and have higher latency. + * + * Generated from protobuf field optional bool low_latency_journey_synthesis = 1; + * @return bool + */ + public function getLowLatencyJourneySynthesis() + { + return isset($this->low_latency_journey_synthesis) ? $this->low_latency_journey_synthesis : false; + } + + public function hasLowLatencyJourneySynthesis() + { + return isset($this->low_latency_journey_synthesis); + } + + public function clearLowLatencyJourneySynthesis() + { + unset($this->low_latency_journey_synthesis); + } + + /** + * Only for Journey voices. If false, the synthesis will be context aware + * and have higher latency. + * + * Generated from protobuf field optional bool low_latency_journey_synthesis = 1; + * @param bool $var + * @return $this + */ + public function setLowLatencyJourneySynthesis($var) + { + GPBUtil::checkBool($var); + $this->low_latency_journey_synthesis = $var; + + return $this; + } + +} + diff --git a/TextToSpeech/src/V1/CustomPronunciationParams.php b/TextToSpeech/src/V1/CustomPronunciationParams.php new file mode 100644 index 000000000000..b7ae33a3dadf --- /dev/null +++ b/TextToSpeech/src/V1/CustomPronunciationParams.php @@ -0,0 +1,177 @@ +google.cloud.texttospeech.v1.CustomPronunciationParams + */ +class CustomPronunciationParams extends \Google\Protobuf\Internal\Message +{ + /** + * The phrase to which the customization will be applied. + * The phrase can be multiple words (in the case of proper nouns etc), but + * should not span to a whole sentence. + * + * Generated from protobuf field optional string phrase = 1; + */ + private $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; + /** + * 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; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $phrase + * The phrase to which the customization will be applied. + * The phrase can be multiple words (in the case of proper nouns etc), but + * should not span to a whole sentence. + * @type int $phonetic_encoding + * The phonetic encoding of the phrase. + * @type string $pronunciation + * The pronunciation of the phrase. This must be in the phonetic encoding + * specified above. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Texttospeech\V1\CloudTts::initOnce(); + parent::__construct($data); + } + + /** + * The phrase to which the customization will be applied. + * The phrase can be multiple words (in the case of proper nouns etc), but + * should not span to a whole sentence. + * + * Generated from protobuf field optional string phrase = 1; + * @return string + */ + public function getPhrase() + { + return isset($this->phrase) ? $this->phrase : ''; + } + + public function hasPhrase() + { + return isset($this->phrase); + } + + public function clearPhrase() + { + unset($this->phrase); + } + + /** + * The phrase to which the customization will be applied. + * The phrase can be multiple words (in the case of proper nouns etc), but + * should not span to a whole sentence. + * + * Generated from protobuf field optional string phrase = 1; + * @param string $var + * @return $this + */ + public function setPhrase($var) + { + GPBUtil::checkString($var, True); + $this->phrase = $var; + + return $this; + } + + /** + * The phonetic encoding of the phrase. + * + * Generated from protobuf field optional .google.cloud.texttospeech.v1.CustomPronunciationParams.PhoneticEncoding phonetic_encoding = 2; + * @return int + */ + public function getPhoneticEncoding() + { + return isset($this->phonetic_encoding) ? $this->phonetic_encoding : 0; + } + + public function hasPhoneticEncoding() + { + return isset($this->phonetic_encoding); + } + + public function clearPhoneticEncoding() + { + unset($this->phonetic_encoding); + } + + /** + * The phonetic encoding of the phrase. + * + * Generated from protobuf field optional .google.cloud.texttospeech.v1.CustomPronunciationParams.PhoneticEncoding phonetic_encoding = 2; + * @param int $var + * @return $this + */ + public function setPhoneticEncoding($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\TextToSpeech\V1\CustomPronunciationParams\PhoneticEncoding::class); + $this->phonetic_encoding = $var; + + return $this; + } + + /** + * The pronunciation of the phrase. This must be in the phonetic encoding + * specified above. + * + * Generated from protobuf field optional string pronunciation = 3; + * @return string + */ + public function getPronunciation() + { + return isset($this->pronunciation) ? $this->pronunciation : ''; + } + + public function hasPronunciation() + { + return isset($this->pronunciation); + } + + public function clearPronunciation() + { + unset($this->pronunciation); + } + + /** + * The pronunciation of the phrase. This must be in the phonetic encoding + * specified above. + * + * Generated from protobuf field optional string pronunciation = 3; + * @param string $var + * @return $this + */ + public function setPronunciation($var) + { + GPBUtil::checkString($var, True); + $this->pronunciation = $var; + + return $this; + } + +} + diff --git a/TextToSpeech/src/V1/CustomPronunciationParams/PhoneticEncoding.php b/TextToSpeech/src/V1/CustomPronunciationParams/PhoneticEncoding.php new file mode 100644 index 000000000000..d7631a1efee4 --- /dev/null +++ b/TextToSpeech/src/V1/CustomPronunciationParams/PhoneticEncoding.php @@ -0,0 +1,66 @@ +google.cloud.texttospeech.v1.CustomPronunciationParams.PhoneticEncoding + */ +class PhoneticEncoding +{ + /** + * Not specified. + * + * Generated from protobuf enum PHONETIC_ENCODING_UNSPECIFIED = 0; + */ + const PHONETIC_ENCODING_UNSPECIFIED = 0; + /** + * IPA. (e.g. apple -> ˈæpəl ) + * https://en.wikipedia.org/wiki/International_Phonetic_Alphabet + * + * Generated from protobuf enum PHONETIC_ENCODING_IPA = 1; + */ + const PHONETIC_ENCODING_IPA = 1; + /** + * X-SAMPA (e.g. apple -> "{p@l" ) + * https://en.wikipedia.org/wiki/X-SAMPA + * + * Generated from protobuf enum PHONETIC_ENCODING_X_SAMPA = 2; + */ + const PHONETIC_ENCODING_X_SAMPA = 2; + + private static $valueToName = [ + self::PHONETIC_ENCODING_UNSPECIFIED => 'PHONETIC_ENCODING_UNSPECIFIED', + self::PHONETIC_ENCODING_IPA => 'PHONETIC_ENCODING_IPA', + self::PHONETIC_ENCODING_X_SAMPA => 'PHONETIC_ENCODING_X_SAMPA', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// 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/CustomPronunciations.php b/TextToSpeech/src/V1/CustomPronunciations.php new file mode 100644 index 000000000000..fffc75dae4d1 --- /dev/null +++ b/TextToSpeech/src/V1/CustomPronunciations.php @@ -0,0 +1,67 @@ +google.cloud.texttospeech.v1.CustomPronunciations + */ +class CustomPronunciations extends \Google\Protobuf\Internal\Message +{ + /** + * The pronunciation customizations to be applied. + * + * Generated from protobuf field repeated .google.cloud.texttospeech.v1.CustomPronunciationParams pronunciations = 1; + */ + private $pronunciations; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\TextToSpeech\V1\CustomPronunciationParams>|\Google\Protobuf\Internal\RepeatedField $pronunciations + * The pronunciation customizations to be applied. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Texttospeech\V1\CloudTts::initOnce(); + parent::__construct($data); + } + + /** + * The pronunciation customizations to be applied. + * + * Generated from protobuf field repeated .google.cloud.texttospeech.v1.CustomPronunciationParams pronunciations = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPronunciations() + { + return $this->pronunciations; + } + + /** + * The pronunciation customizations to be applied. + * + * Generated from protobuf field repeated .google.cloud.texttospeech.v1.CustomPronunciationParams pronunciations = 1; + * @param array<\Google\Cloud\TextToSpeech\V1\CustomPronunciationParams>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPronunciations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\TextToSpeech\V1\CustomPronunciationParams::class); + $this->pronunciations = $arr; + + return $this; + } + +} + diff --git a/TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php b/TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php index ec3eccecb963..04752180f014 100644 --- a/TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php +++ b/TextToSpeech/src/V1/Gapic/TextToSpeechGapicClient.php @@ -33,6 +33,7 @@ use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\TextToSpeech\V1\AdvancedVoiceOptions; use Google\Cloud\TextToSpeech\V1\AudioConfig; use Google\Cloud\TextToSpeech\V1\ListVoicesRequest; use Google\Cloud\TextToSpeech\V1\ListVoicesResponse; @@ -407,6 +408,8 @@ public function streamingSynthesize(array $optionalArgs = []) * @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 @@ -427,6 +430,12 @@ public function synthesizeSpeech( $request->setInput($input); $request->setVoice($voice); $request->setAudioConfig($audioConfig); + if (isset($optionalArgs['advancedVoiceOptions'])) { + $request->setAdvancedVoiceOptions( + $optionalArgs['advancedVoiceOptions'] + ); + } + return $this->startCall( 'SynthesizeSpeech', SynthesizeSpeechResponse::class, diff --git a/TextToSpeech/src/V1/SynthesisInput.php b/TextToSpeech/src/V1/SynthesisInput.php index 4e8f0065c3c2..8c54e52eaaff 100644 --- a/TextToSpeech/src/V1/SynthesisInput.php +++ b/TextToSpeech/src/V1/SynthesisInput.php @@ -18,6 +18,21 @@ */ class SynthesisInput extends \Google\Protobuf\Internal\Message { + /** + * Optional. The pronunciation customizations to be applied to the input. If + * this is set, the input will be synthesized using the given pronunciation + * customizations. + * The initial support will be for EFIGS (English, French, + * Italian, German, Spanish) languages, as provided in + * VoiceSelectionParams. Journey and Instant Clone voices are + * not supported yet. + * In order to customize the pronunciation of a phrase, there must be an exact + * match of the phrase in the input types. If using SSML, the phrase must not + * be inside a phoneme tag (entirely or partially). + * + * Generated from protobuf field .google.cloud.texttospeech.v1.CustomPronunciations custom_pronunciations = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $custom_pronunciations = null; protected $input_source; /** @@ -34,6 +49,17 @@ class SynthesisInput extends \Google\Protobuf\Internal\Message * [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. For * more information, see * [SSML](https://cloud.google.com/text-to-speech/docs/ssml). + * @type \Google\Cloud\TextToSpeech\V1\CustomPronunciations $custom_pronunciations + * Optional. The pronunciation customizations to be applied to the input. If + * this is set, the input will be synthesized using the given pronunciation + * customizations. + * The initial support will be for EFIGS (English, French, + * Italian, German, Spanish) languages, as provided in + * VoiceSelectionParams. Journey and Instant Clone voices are + * not supported yet. + * In order to customize the pronunciation of a phrase, there must be an exact + * match of the phrase in the input types. If using SSML, the phrase must not + * be inside a phoneme tag (entirely or partially). * } */ public function __construct($data = NULL) { @@ -111,6 +137,60 @@ public function setSsml($var) return $this; } + /** + * Optional. The pronunciation customizations to be applied to the input. If + * this is set, the input will be synthesized using the given pronunciation + * customizations. + * The initial support will be for EFIGS (English, French, + * Italian, German, Spanish) languages, as provided in + * VoiceSelectionParams. Journey and Instant Clone voices are + * not supported yet. + * In order to customize the pronunciation of a phrase, there must be an exact + * match of the phrase in the input types. If using SSML, the phrase must not + * be inside a phoneme tag (entirely or partially). + * + * Generated from protobuf field .google.cloud.texttospeech.v1.CustomPronunciations custom_pronunciations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\TextToSpeech\V1\CustomPronunciations|null + */ + public function getCustomPronunciations() + { + return $this->custom_pronunciations; + } + + public function hasCustomPronunciations() + { + return isset($this->custom_pronunciations); + } + + public function clearCustomPronunciations() + { + unset($this->custom_pronunciations); + } + + /** + * Optional. The pronunciation customizations to be applied to the input. If + * this is set, the input will be synthesized using the given pronunciation + * customizations. + * The initial support will be for EFIGS (English, French, + * Italian, German, Spanish) languages, as provided in + * VoiceSelectionParams. Journey and Instant Clone voices are + * not supported yet. + * In order to customize the pronunciation of a phrase, there must be an exact + * match of the phrase in the input types. If using SSML, the phrase must not + * be inside a phoneme tag (entirely or partially). + * + * Generated from protobuf field .google.cloud.texttospeech.v1.CustomPronunciations custom_pronunciations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\TextToSpeech\V1\CustomPronunciations $var + * @return $this + */ + public function setCustomPronunciations($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\CustomPronunciations::class); + $this->custom_pronunciations = $var; + + return $this; + } + /** * @return string */ diff --git a/TextToSpeech/src/V1/SynthesizeSpeechRequest.php b/TextToSpeech/src/V1/SynthesizeSpeechRequest.php index b9e1a310aea4..706d3b0e9cb4 100644 --- a/TextToSpeech/src/V1/SynthesizeSpeechRequest.php +++ b/TextToSpeech/src/V1/SynthesizeSpeechRequest.php @@ -33,6 +33,12 @@ class SynthesizeSpeechRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.cloud.texttospeech.v1.AudioConfig audio_config = 3 [(.google.api.field_behavior) = REQUIRED]; */ private $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; /** * @param \Google\Cloud\TextToSpeech\V1\SynthesisInput $input Required. The Synthesizer requires either plain text or SSML as input. @@ -63,6 +69,8 @@ public static function build(\Google\Cloud\TextToSpeech\V1\SynthesisInput $input * Required. The desired voice of the synthesized audio. * @type \Google\Cloud\TextToSpeech\V1\AudioConfig $audio_config * Required. The configuration of the synthesized audio. + * @type \Google\Cloud\TextToSpeech\V1\AdvancedVoiceOptions $advanced_voice_options + * Advanced voice options. * } */ public function __construct($data = NULL) { @@ -178,5 +186,41 @@ public function setAudioConfig($var) return $this; } + /** + * Advanced voice options. + * + * Generated from protobuf field optional .google.cloud.texttospeech.v1.AdvancedVoiceOptions advanced_voice_options = 8; + * @return \Google\Cloud\TextToSpeech\V1\AdvancedVoiceOptions|null + */ + public function getAdvancedVoiceOptions() + { + return $this->advanced_voice_options; + } + + public function hasAdvancedVoiceOptions() + { + return isset($this->advanced_voice_options); + } + + public function clearAdvancedVoiceOptions() + { + unset($this->advanced_voice_options); + } + + /** + * Advanced voice options. + * + * Generated from protobuf field optional .google.cloud.texttospeech.v1.AdvancedVoiceOptions advanced_voice_options = 8; + * @param \Google\Cloud\TextToSpeech\V1\AdvancedVoiceOptions $var + * @return $this + */ + public function setAdvancedVoiceOptions($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\TextToSpeech\V1\AdvancedVoiceOptions::class); + $this->advanced_voice_options = $var; + + return $this; + } + }