Skip to content

Revert "chore: upgrade texttospeech samples to new surface" #1902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion texttospeech/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/cloud-text-to-speech": "^1.7"
"google/cloud-text-to-speech": "^1.0.0"
}
}
9 changes: 2 additions & 7 deletions texttospeech/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions texttospeech/src/list_voices.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
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
{
// create client object
$client = new TextToSpeechClient();

// perform list voices request
$request = (new ListVoicesRequest());
$response = $client->listVoices($request);
$response = $client->listVoices();
$voices = $response->getVoices();

foreach ($voices as $voice) {
Expand Down
9 changes: 2 additions & 7 deletions texttospeech/src/synthesize_ssml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions texttospeech/src/synthesize_ssml_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions texttospeech/src/synthesize_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions texttospeech/src/synthesize_text_effects_profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions texttospeech/src/synthesize_text_effects_profile_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions texttospeech/src/synthesize_text_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand Down