Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Samples: update writing bytes to mp3 files to be async
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Taylor committed Mar 24, 2018
1 parent d18510c commit e235bf3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions samples/synthesize.js
Expand Up @@ -36,10 +36,10 @@ function synthesizeText(text, outputFile) {

client
.synthesizeSpeech(request)
.then(results => {
.then(async results => {
const audioContent = results[0].audioContent;

fs.writeFileSync(outputFile, audioContent, 'binary');
await fs.writeFile(outputFile, audioContent, 'binary');
console.log(`Audio content written to file: ${outputFile}`);
})
.catch(err => {
Expand Down Expand Up @@ -69,10 +69,10 @@ function synthesizeSsml(ssml, outputFile) {

client
.synthesizeSpeech(request)
.then(results => {
.then(async results => {
const audioContent = results[0].audioContent;

fs.writeFileSync(outputFile, audioContent, 'binary');
await fs.writeFile(outputFile, audioContent, 'binary');
console.log(`Audio content written to file: ${outputFile}`);
})
.catch(err => {
Expand Down Expand Up @@ -102,10 +102,10 @@ function synthesizeTextFile(textFile, outputFile) {

client
.synthesizeSpeech(request)
.then(results => {
.then(async results => {
const audioContent = results[0].audioContent;

fs.writeFileSync(outputFile, audioContent, 'binary');
await fs.writeFile(outputFile, audioContent, 'binary');
console.log(`Audio content written to file: ${outputFile}`);
})
.catch(err => {
Expand Down Expand Up @@ -135,10 +135,10 @@ function synthesizeSsmlFile(ssmlFile, outputFile) {

client
.synthesizeSpeech(request)
.then(results => {
.then(async results => {
const audioContent = results[0].audioContent;

fs.writeFileSync(outputFile, audioContent, 'binary');
await fs.writeFile(outputFile, audioContent, 'binary');
console.log(`Audio content written to file: ${outputFile}`);
})
.catch(err => {
Expand Down

0 comments on commit e235bf3

Please sign in to comment.