googleapis / google-cloud-node

Google Cloud Client Library for Node.js
https://cloud.google.com/nodejs
Apache License 2.0
2.91k stars 592 forks source link

Support for audioEncoding as a number suddenly dropped #3526

Closed Masadow closed 1 year ago

Masadow commented 2 years ago

Hi, we realized that using name in voice (which is fine according to typescript typings) is no longer working and has been dropped yesterday.

It broke our production environment without prior notice. Changing it to ssmlGender works but does not produce the same voice.

We also changed audioEncoding from number to string as a safety measure as it's no longer documented.

Old request :

const request = {
  request: {
    audioConfig: {
      audioEncoding: 2
    },
    input: {
      ssml: '<speak><par><media xml:id="backgroundAudio" end="text0.end+3.0s" ><audio src="https://ector-v3-dev.s3-eu-west-1.amazonaws.com/music/corporate-achievement.mp3" soundLevel="-12dB" /></media><media xml:id="text0">blahblah</media></par></speak>'
    },
    voice: {
      languageCode: 'fr-FR',
      name: 'fr-FR-Wavenet-A'
    }
  }
}

New request :

const request = {
  request: {
    audioConfig: {
      audioEncoding: 'MP3'
    },
    input: {
      ssml: '<speak><par><media xml:id="backgroundAudio" end="text0.end+3.0s" ><audio src="https://ector-v3-dev.s3-eu-west-1.amazonaws.com/music/corporate-achievement.mp3" soundLevel="-12dB" /></media><media xml:id="text0">blahblah</media></par></speak>'
    },
    voice: {
      languageCode: 'fr-FR',
      ssmlGender: 'FEMALE'
    }
  }
}
yil532 commented 1 year ago

Yes, thanks for the notice. For more information, here is the documentation and code sample in Node: https://cloud.google.com/text-to-speech/docs/libraries#client-libraries-usage-nodejs/. The key points you mentioned have been included here.