@google-cloud/text-to-speech
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -124,2 +124,5 @@ "use strict"; | ||
const innerCallPromise = this.textToSpeechStub.then(stub => (...args) => { | ||
if (this._terminated) { | ||
return Promise.reject('The client has already been closed.'); | ||
} | ||
return stub[methodName].apply(stub, args); | ||
@@ -133,5 +136,2 @@ }, (err) => () => { | ||
this._innerApiCalls[methodName] = (argument, callOptions, callback) => { | ||
if (this._terminated) { | ||
return Promise.reject('The client has already been closed.'); | ||
} | ||
return apiCall(argument, callOptions, callback); | ||
@@ -138,0 +138,0 @@ }; |
@@ -124,2 +124,5 @@ "use strict"; | ||
const innerCallPromise = this.textToSpeechStub.then(stub => (...args) => { | ||
if (this._terminated) { | ||
return Promise.reject('The client has already been closed.'); | ||
} | ||
return stub[methodName].apply(stub, args); | ||
@@ -133,5 +136,2 @@ }, (err) => () => { | ||
this._innerApiCalls[methodName] = (argument, callOptions, callback) => { | ||
if (this._terminated) { | ||
return Promise.reject('The client has already been closed.'); | ||
} | ||
return apiCall(argument, callOptions, callback); | ||
@@ -138,0 +138,0 @@ }; |
@@ -7,2 +7,9 @@ # Changelog | ||
### [2.1.2](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.1.1...v2.1.2) (2020-01-03) | ||
### Bug Fixes | ||
* "client already closed" error fires earlier ([41b39bc](https://www.github.com/googleapis/nodejs-text-to-speech/commit/41b39bce3a598e6034a4b63c122b1ce89ddec5b5)) | ||
### [2.1.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.1.0...v2.1.1) (2019-12-30) | ||
@@ -9,0 +16,0 @@ |
{ | ||
"name": "@google-cloud/text-to-speech", | ||
"description": "Cloud Text-to-Speech API client for Node.js", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google LLC", |
@@ -58,31 +58,32 @@ [//]: # "This README.md file is auto-generated, all changes to this file will be lost." | ||
```javascript | ||
// Imports the Google Cloud client library | ||
const textToSpeech = require('@google-cloud/text-to-speech'); | ||
// 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(); | ||
@@ -89,0 +90,0 @@ ``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1194688
146