From 91fe917d1cac644656d88ff6b29866ecd193d3b6 Mon Sep 17 00:00:00 2001 From: Yash Sahu <54198301+yash30201@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:08:52 +0530 Subject: [PATCH] Revert "chore: upgrade texttospeech samples to new surface (#1880)" This reverts commit 18c687234b2c72b57ea7503fb4806df701308e26. --- texttospeech/composer.json | 2 +- texttospeech/quickstart.php | 9 ++------- texttospeech/src/list_voices.php | 6 ++---- texttospeech/src/synthesize_ssml.php | 9 ++------- texttospeech/src/synthesize_ssml_file.php | 9 ++------- texttospeech/src/synthesize_text.php | 9 ++------- texttospeech/src/synthesize_text_effects_profile.php | 9 ++------- .../src/synthesize_text_effects_profile_file.php | 9 ++------- texttospeech/src/synthesize_text_file.php | 9 ++------- 9 files changed, 17 insertions(+), 54 deletions(-) diff --git a/texttospeech/composer.json b/texttospeech/composer.json index 18aec934ff..bac8f0cb0b 100644 --- a/texttospeech/composer.json +++ b/texttospeech/composer.json @@ -1,5 +1,5 @@ { "require": { - "google/cloud-text-to-speech": "^1.7" + "google/cloud-text-to-speech": "^1.0.0" } } diff --git a/texttospeech/quickstart.php b/texttospeech/quickstart.php index 375781b657..cc9b75cb5e 100644 --- a/texttospeech/quickstart.php +++ b/texttospeech/quickstart.php @@ -22,10 +22,9 @@ // Imports the Cloud Client Library use Google\Cloud\TextToSpeech\V1\AudioConfig; use Google\Cloud\TextToSpeech\V1\AudioEncoding; -use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender; use Google\Cloud\TextToSpeech\V1\SynthesisInput; -use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest; +use Google\Cloud\TextToSpeech\V1\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams; // instantiates a client @@ -51,11 +50,7 @@ // perform text-to-speech request on the text input with selected voice // parameters and audio file type -$request = (new SynthesizeSpeechRequest()) - ->setInput($synthesisInputText) - ->setVoice($voice) - ->setAudioConfig($audioConfig); -$response = $client->synthesizeSpeech($request); +$response = $client->synthesizeSpeech($synthesisInputText, $voice, $audioConfig); $audioContent = $response->getAudioContent(); // the response's audioContent is binary diff --git a/texttospeech/src/list_voices.php b/texttospeech/src/list_voices.php index 9fdc773bac..8f2f014ecd 100644 --- a/texttospeech/src/list_voices.php +++ b/texttospeech/src/list_voices.php @@ -24,8 +24,7 @@ namespace Google\Cloud\Samples\TextToSpeech; // [START tts_list_voices] -use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient; -use Google\Cloud\TextToSpeech\V1\ListVoicesRequest; +use Google\Cloud\TextToSpeech\V1\TextToSpeechClient; function list_voices(): void { @@ -33,8 +32,7 @@ function list_voices(): void $client = new TextToSpeechClient(); // perform list voices request - $request = (new ListVoicesRequest()); - $response = $client->listVoices($request); + $response = $client->listVoices(); $voices = $response->getVoices(); foreach ($voices as $voice) { diff --git a/texttospeech/src/synthesize_ssml.php b/texttospeech/src/synthesize_ssml.php index 2b58b786f4..7a0fe4469f 100644 --- a/texttospeech/src/synthesize_ssml.php +++ b/texttospeech/src/synthesize_ssml.php @@ -26,10 +26,9 @@ // [START tts_synthesize_ssml] use Google\Cloud\TextToSpeech\V1\AudioConfig; use Google\Cloud\TextToSpeech\V1\AudioEncoding; -use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender; use Google\Cloud\TextToSpeech\V1\SynthesisInput; -use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest; +use Google\Cloud\TextToSpeech\V1\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams; /** @@ -51,12 +50,8 @@ function synthesize_ssml(string $ssml): void $audioConfig = (new AudioConfig()) ->setAudioEncoding(AudioEncoding::MP3); - $request = (new SynthesizeSpeechRequest()) - ->setInput($input_text) - ->setVoice($voice) - ->setAudioConfig($audioConfig); - $response = $client->synthesizeSpeech($request); + $response = $client->synthesizeSpeech($input_text, $voice, $audioConfig); $audioContent = $response->getAudioContent(); file_put_contents('output.mp3', $audioContent); diff --git a/texttospeech/src/synthesize_ssml_file.php b/texttospeech/src/synthesize_ssml_file.php index 0682429963..7ccd1e1290 100644 --- a/texttospeech/src/synthesize_ssml_file.php +++ b/texttospeech/src/synthesize_ssml_file.php @@ -26,10 +26,9 @@ // [START tts_synthesize_ssml_file] use Google\Cloud\TextToSpeech\V1\AudioConfig; use Google\Cloud\TextToSpeech\V1\AudioEncoding; -use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender; use Google\Cloud\TextToSpeech\V1\SynthesisInput; -use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest; +use Google\Cloud\TextToSpeech\V1\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams; /** @@ -53,12 +52,8 @@ function synthesize_ssml_file(string $path): void $audioConfig = (new AudioConfig()) ->setAudioEncoding(AudioEncoding::MP3); - $request = (new SynthesizeSpeechRequest()) - ->setInput($input_text) - ->setVoice($voice) - ->setAudioConfig($audioConfig); - $response = $client->synthesizeSpeech($request); + $response = $client->synthesizeSpeech($input_text, $voice, $audioConfig); $audioContent = $response->getAudioContent(); file_put_contents('output.mp3', $audioContent); diff --git a/texttospeech/src/synthesize_text.php b/texttospeech/src/synthesize_text.php index be27fdaf79..ff441cf9f2 100644 --- a/texttospeech/src/synthesize_text.php +++ b/texttospeech/src/synthesize_text.php @@ -26,10 +26,9 @@ // [START tts_synthesize_text] use Google\Cloud\TextToSpeech\V1\AudioConfig; use Google\Cloud\TextToSpeech\V1\AudioEncoding; -use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender; use Google\Cloud\TextToSpeech\V1\SynthesisInput; -use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest; +use Google\Cloud\TextToSpeech\V1\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams; /** @@ -51,12 +50,8 @@ function synthesize_text(string $text): void $audioConfig = (new AudioConfig()) ->setAudioEncoding(AudioEncoding::MP3); - $request = (new SynthesizeSpeechRequest()) - ->setInput($input_text) - ->setVoice($voice) - ->setAudioConfig($audioConfig); - $response = $client->synthesizeSpeech($request); + $response = $client->synthesizeSpeech($input_text, $voice, $audioConfig); $audioContent = $response->getAudioContent(); file_put_contents('output.mp3', $audioContent); diff --git a/texttospeech/src/synthesize_text_effects_profile.php b/texttospeech/src/synthesize_text_effects_profile.php index 2517961289..14acbf554c 100644 --- a/texttospeech/src/synthesize_text_effects_profile.php +++ b/texttospeech/src/synthesize_text_effects_profile.php @@ -26,10 +26,9 @@ // [START tts_synthesize_text_audio_profile] use Google\Cloud\TextToSpeech\V1\AudioConfig; use Google\Cloud\TextToSpeech\V1\AudioEncoding; -use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender; use Google\Cloud\TextToSpeech\V1\SynthesisInput; -use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest; +use Google\Cloud\TextToSpeech\V1\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams; /** @@ -54,12 +53,8 @@ function synthesize_text_effects_profile(string $text, string $effectsProfileId) $audioConfig = (new AudioConfig()) ->setAudioEncoding(AudioEncoding::MP3) ->setEffectsProfileId(array($effectsProfileId)); - $request = (new SynthesizeSpeechRequest()) - ->setInput($inputText) - ->setVoice($voice) - ->setAudioConfig($audioConfig); - $response = $client->synthesizeSpeech($request); + $response = $client->synthesizeSpeech($inputText, $voice, $audioConfig); $audioContent = $response->getAudioContent(); file_put_contents('output.mp3', $audioContent); diff --git a/texttospeech/src/synthesize_text_effects_profile_file.php b/texttospeech/src/synthesize_text_effects_profile_file.php index a437bcd4bd..80fe8033eb 100644 --- a/texttospeech/src/synthesize_text_effects_profile_file.php +++ b/texttospeech/src/synthesize_text_effects_profile_file.php @@ -26,10 +26,9 @@ // [START tts_synthesize_text_audio_profile_file] use Google\Cloud\TextToSpeech\V1\AudioConfig; use Google\Cloud\TextToSpeech\V1\AudioEncoding; -use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender; use Google\Cloud\TextToSpeech\V1\SynthesisInput; -use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest; +use Google\Cloud\TextToSpeech\V1\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams; /** @@ -55,12 +54,8 @@ function synthesize_text_effects_profile_file(string $path, string $effectsProfi $audioConfig = (new AudioConfig()) ->setAudioEncoding(AudioEncoding::MP3) ->setEffectsProfileId(array($effectsProfileId)); - $request = (new SynthesizeSpeechRequest()) - ->setInput($inputText) - ->setVoice($voice) - ->setAudioConfig($audioConfig); - $response = $client->synthesizeSpeech($request); + $response = $client->synthesizeSpeech($inputText, $voice, $audioConfig); $audioContent = $response->getAudioContent(); file_put_contents('output.mp3', $audioContent); diff --git a/texttospeech/src/synthesize_text_file.php b/texttospeech/src/synthesize_text_file.php index 91df4bae23..db7067f254 100644 --- a/texttospeech/src/synthesize_text_file.php +++ b/texttospeech/src/synthesize_text_file.php @@ -26,10 +26,9 @@ // [START tts_synthesize_text_file] use Google\Cloud\TextToSpeech\V1\AudioConfig; use Google\Cloud\TextToSpeech\V1\AudioEncoding; -use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender; use Google\Cloud\TextToSpeech\V1\SynthesisInput; -use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest; +use Google\Cloud\TextToSpeech\V1\TextToSpeechClient; use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams; /** @@ -53,12 +52,8 @@ function synthesize_text_file(string $path): void $audioConfig = (new AudioConfig()) ->setAudioEncoding(AudioEncoding::MP3); - $request = (new SynthesizeSpeechRequest()) - ->setInput($input_text) - ->setVoice($voice) - ->setAudioConfig($audioConfig); - $response = $client->synthesizeSpeech($request); + $response = $client->synthesizeSpeech($input_text, $voice, $audioConfig); $audioContent = $response->getAudioContent(); file_put_contents('output.mp3', $audioContent);