Skip to content

Commit

Permalink
fix: move region tag to encompass catch (#320)
Browse files Browse the repository at this point in the history
* fix: move region tag to encompass catch

* fix: refactor to adhere to sample policies

* fix: revert weird lowercases

* fix: another stupid lowercase

Co-authored-by: Benjamin E. Coe <bencoe@google.com>
  • Loading branch information
leahecole and bcoe authored Dec 30, 2019
1 parent 63f14d9 commit 7d45732
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions texttospeech/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,40 @@

'use strict';

// [START tts_quickstart]
// Imports the Google Cloud client library
const textToSpeech = require('@google-cloud/text-to-speech');
function main(
){
// [START tts_quickstart]
// Imports the Google Cloud client library
const textToSpeech = require('@google-cloud/text-to-speech');

// Import other required libraries
const fs = require('fs');
const util = require('util');
async function main() {
// Import other required libraries
const fs = require('fs');
const util = require('util');
// Creates a client
const client = new textToSpeech.TextToSpeechClient();
async function quickStart() {

// The text to synthesize
const text = 'Hello, world!';
// The text to synthesize
const text = 'hello, world!';

// Construct the request
const request = {
input: {text: text},
// Select the language and SSML Voice Gender (optional)
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
// Select the type of audio encoding
audioConfig: {audioEncoding: 'MP3'},
};
// Construct the request
const request = {
input: {text: text},
// Select the language and SSML voice gender (optional)
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
// select the type of audio encoding
audioConfig: {audioEncoding: 'MP3'},
};

// Performs the Text-to-Speech request
const [response] = await client.synthesizeSpeech(request);
// Write the binary audio content to a local file
const writeFile = util.promisify(fs.writeFile);
await writeFile('output.mp3', response.audioContent, 'binary');
console.log('Audio content written to file: output.mp3');
// Performs the text-to-speech request
const [response] = await client.synthesizeSpeech(request);
// Write the binary audio content to a local file
const writeFile = util.promisify(fs.writeFile);
await writeFile('output.mp3', response.audioContent, 'binary');
console.log('Audio content written to file: output.mp3');
}
quickStart();
// [END tts_quickstart]
}
// [END tts_quickstart]
main().catch(console.error);

main(...process.argv.slice(2));

0 comments on commit 7d45732

Please sign in to comment.