Skip to content

Commit fa6f3a4

Browse files
authored
Revert "chore: upgrade texttospeech samples to new surface (#1880)" (#1902)
This reverts commit 18c6872.
1 parent 18c6872 commit fa6f3a4

9 files changed

+17
-54
lines changed

texttospeech/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"require": {
3-
"google/cloud-text-to-speech": "^1.7"
3+
"google/cloud-text-to-speech": "^1.0.0"
44
}
55
}

texttospeech/quickstart.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
// Imports the Cloud Client Library
2323
use Google\Cloud\TextToSpeech\V1\AudioConfig;
2424
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
25-
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
2625
use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
2726
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
28-
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
27+
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
2928
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
3029

3130
// instantiates a client
@@ -51,11 +50,7 @@
5150

5251
// perform text-to-speech request on the text input with selected voice
5352
// parameters and audio file type
54-
$request = (new SynthesizeSpeechRequest())
55-
->setInput($synthesisInputText)
56-
->setVoice($voice)
57-
->setAudioConfig($audioConfig);
58-
$response = $client->synthesizeSpeech($request);
53+
$response = $client->synthesizeSpeech($synthesisInputText, $voice, $audioConfig);
5954
$audioContent = $response->getAudioContent();
6055

6156
// the response's audioContent is binary

texttospeech/src/list_voices.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@
2424
namespace Google\Cloud\Samples\TextToSpeech;
2525

2626
// [START tts_list_voices]
27-
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
28-
use Google\Cloud\TextToSpeech\V1\ListVoicesRequest;
27+
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
2928

3029
function list_voices(): void
3130
{
3231
// create client object
3332
$client = new TextToSpeechClient();
3433

3534
// perform list voices request
36-
$request = (new ListVoicesRequest());
37-
$response = $client->listVoices($request);
35+
$response = $client->listVoices();
3836
$voices = $response->getVoices();
3937

4038
foreach ($voices as $voice) {

texttospeech/src/synthesize_ssml.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
// [START tts_synthesize_ssml]
2727
use Google\Cloud\TextToSpeech\V1\AudioConfig;
2828
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
29-
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
3029
use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
3130
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
32-
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
31+
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
3332
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
3433

3534
/**
@@ -51,12 +50,8 @@ function synthesize_ssml(string $ssml): void
5150

5251
$audioConfig = (new AudioConfig())
5352
->setAudioEncoding(AudioEncoding::MP3);
54-
$request = (new SynthesizeSpeechRequest())
55-
->setInput($input_text)
56-
->setVoice($voice)
57-
->setAudioConfig($audioConfig);
5853

59-
$response = $client->synthesizeSpeech($request);
54+
$response = $client->synthesizeSpeech($input_text, $voice, $audioConfig);
6055
$audioContent = $response->getAudioContent();
6156

6257
file_put_contents('output.mp3', $audioContent);

texttospeech/src/synthesize_ssml_file.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
// [START tts_synthesize_ssml_file]
2727
use Google\Cloud\TextToSpeech\V1\AudioConfig;
2828
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
29-
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
3029
use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
3130
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
32-
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
31+
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
3332
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
3433

3534
/**
@@ -53,12 +52,8 @@ function synthesize_ssml_file(string $path): void
5352

5453
$audioConfig = (new AudioConfig())
5554
->setAudioEncoding(AudioEncoding::MP3);
56-
$request = (new SynthesizeSpeechRequest())
57-
->setInput($input_text)
58-
->setVoice($voice)
59-
->setAudioConfig($audioConfig);
6055

61-
$response = $client->synthesizeSpeech($request);
56+
$response = $client->synthesizeSpeech($input_text, $voice, $audioConfig);
6257
$audioContent = $response->getAudioContent();
6358

6459
file_put_contents('output.mp3', $audioContent);

texttospeech/src/synthesize_text.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
// [START tts_synthesize_text]
2727
use Google\Cloud\TextToSpeech\V1\AudioConfig;
2828
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
29-
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
3029
use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
3130
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
32-
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
31+
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
3332
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
3433

3534
/**
@@ -51,12 +50,8 @@ function synthesize_text(string $text): void
5150

5251
$audioConfig = (new AudioConfig())
5352
->setAudioEncoding(AudioEncoding::MP3);
54-
$request = (new SynthesizeSpeechRequest())
55-
->setInput($input_text)
56-
->setVoice($voice)
57-
->setAudioConfig($audioConfig);
5853

59-
$response = $client->synthesizeSpeech($request);
54+
$response = $client->synthesizeSpeech($input_text, $voice, $audioConfig);
6055
$audioContent = $response->getAudioContent();
6156

6257
file_put_contents('output.mp3', $audioContent);

texttospeech/src/synthesize_text_effects_profile.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
// [START tts_synthesize_text_audio_profile]
2727
use Google\Cloud\TextToSpeech\V1\AudioConfig;
2828
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
29-
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
3029
use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
3130
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
32-
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
31+
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
3332
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
3433

3534
/**
@@ -54,12 +53,8 @@ function synthesize_text_effects_profile(string $text, string $effectsProfileId)
5453
$audioConfig = (new AudioConfig())
5554
->setAudioEncoding(AudioEncoding::MP3)
5655
->setEffectsProfileId(array($effectsProfileId));
57-
$request = (new SynthesizeSpeechRequest())
58-
->setInput($inputText)
59-
->setVoice($voice)
60-
->setAudioConfig($audioConfig);
6156

62-
$response = $client->synthesizeSpeech($request);
57+
$response = $client->synthesizeSpeech($inputText, $voice, $audioConfig);
6358
$audioContent = $response->getAudioContent();
6459

6560
file_put_contents('output.mp3', $audioContent);

texttospeech/src/synthesize_text_effects_profile_file.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
// [START tts_synthesize_text_audio_profile_file]
2727
use Google\Cloud\TextToSpeech\V1\AudioConfig;
2828
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
29-
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
3029
use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
3130
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
32-
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
31+
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
3332
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
3433

3534
/**
@@ -55,12 +54,8 @@ function synthesize_text_effects_profile_file(string $path, string $effectsProfi
5554
$audioConfig = (new AudioConfig())
5655
->setAudioEncoding(AudioEncoding::MP3)
5756
->setEffectsProfileId(array($effectsProfileId));
58-
$request = (new SynthesizeSpeechRequest())
59-
->setInput($inputText)
60-
->setVoice($voice)
61-
->setAudioConfig($audioConfig);
6257

63-
$response = $client->synthesizeSpeech($request);
58+
$response = $client->synthesizeSpeech($inputText, $voice, $audioConfig);
6459
$audioContent = $response->getAudioContent();
6560

6661
file_put_contents('output.mp3', $audioContent);

texttospeech/src/synthesize_text_file.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
// [START tts_synthesize_text_file]
2727
use Google\Cloud\TextToSpeech\V1\AudioConfig;
2828
use Google\Cloud\TextToSpeech\V1\AudioEncoding;
29-
use Google\Cloud\TextToSpeech\V1\Client\TextToSpeechClient;
3029
use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
3130
use Google\Cloud\TextToSpeech\V1\SynthesisInput;
32-
use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest;
31+
use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
3332
use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
3433

3534
/**
@@ -53,12 +52,8 @@ function synthesize_text_file(string $path): void
5352

5453
$audioConfig = (new AudioConfig())
5554
->setAudioEncoding(AudioEncoding::MP3);
56-
$request = (new SynthesizeSpeechRequest())
57-
->setInput($input_text)
58-
->setVoice($voice)
59-
->setAudioConfig($audioConfig);
6055

61-
$response = $client->synthesizeSpeech($request);
56+
$response = $client->synthesizeSpeech($input_text, $voice, $audioConfig);
6257
$audioContent = $response->getAudioContent();
6358

6459
file_put_contents('output.mp3', $audioContent);

0 commit comments

Comments
 (0)