-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [TextToSpeech] add LRS API (#5680)
* 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
1 parent
d03de88
commit 7ebae6c
Showing
19 changed files
with
1,305 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
TextToSpeech/samples/V1/TextToSpeechLongAudioSynthesizeClient/synthesize_long_audio.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.