Skip to content

Commit

Permalink
feat: [TextToSpeech] add LRS API (#5680)
Browse files Browse the repository at this point in the history
* feat: add LRS API

PiperOrigin-RevId: 493606501

Source-Link: googleapis/googleapis@a1b5429

Source-Link: googleapis/googleapis-gen@ea4e780
Copy-Tag: eyJwIjoiVGV4dFRvU3BlZWNoLy5Pd2xCb3QueWFtbCIsImgiOiJlYTRlNzgwMmI3ZGE3ZGIzYTJmNDIyYTVkYmY0ZTNmNGY4YzYwNjdkIn0=

* 🦉 Updates from OwlBot post-processor

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

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Dec 9, 2022
1 parent d03de88 commit 7ebae6c
Show file tree
Hide file tree
Showing 19 changed files with 1,305 additions and 26 deletions.
49 changes: 49 additions & 0 deletions TextToSpeech/metadata/V1/CloudTtsLrs.php

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

Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
* Synthesizes speech synchronously: receive results after all text input
* has been processed.
*
* @param string $voiceLanguageCode The language (and potentially also the region) of the voice expressed as a
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag, e.g.
* "en-US". This should not include a script tag (e.g. use
* @param string $voiceLanguageCode The language (and potentially also the region) of the voice
* expressed as a [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt)
* language tag, e.g. "en-US". This should not include a script tag (e.g. use
* "cmn-cn" rather than "cmn-Hant-cn"), because the script will be inferred
* from the input provided in the SynthesisInput. The TTS service
* will use this parameter to help choose an appropriate voice. Note that
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

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

// [START texttospeech_v1_generated_TextToSpeechLongAudioSynthesize_SynthesizeLongAudio_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\TextToSpeech\V1\AudioConfig;
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
use Google\Cloud\TextToSpeech\V1\SynthesizeLongAudioResponse;
use Google\Cloud\TextToSpeech\V1\TextToSpeechLongAudioSynthesizeClient;
use Google\Rpc\Status;

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

// Prepare any non-scalar elements to be passed along with the request.
$input = new SynthesisInput();
$audioConfig = (new AudioConfig())
->setAudioEncoding($audioConfigAudioEncoding);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $textToSpeechLongAudioSynthesizeClient->synthesizeLongAudio($input, $audioConfig);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var SynthesizeLongAudioResponse $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$audioConfigAudioEncoding = AudioEncoding::AUDIO_ENCODING_UNSPECIFIED;

synthesize_long_audio_sample($audioConfigAudioEncoding);
}
// [END texttospeech_v1_generated_TextToSpeechLongAudioSynthesize_SynthesizeLongAudio_sync]
8 changes: 4 additions & 4 deletions TextToSpeech/src/V1/AudioConfig.php

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

3 changes: 2 additions & 1 deletion TextToSpeech/src/V1/AudioEncoding.php

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

Loading

0 comments on commit 7ebae6c

Please sign in to comment.