Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (config.voiceName) {
let voiceName = (config.voiceNameType === 'msg') ? helper.getByString(data, config.voiceName) : config.voiceName;
parameters.voice.voice = voiceName;
}
if (config.ssmlGender) {
let ssmlGender = (config.ssmlGenderType === 'msg') ? helper.getByString(data, config.ssmlGender) : config.ssmlGender;
parameters.voice.ssmlGender = ssmlGender;
}
if (input.match(//ig)) parameters.input.ssml = input;
else parameters.input.text = input;
const texttospeech = require('@google-cloud/text-to-speech');
let client = new texttospeech.v1beta1.TextToSpeechClient({credentials: node.auth.cred});
let res = { audioContent: [] }
client.synthesizeSpeech(parameters)
.then((results) => {
res.audioContent = (results[0] && results[0].audioContent) ? results[0].audioContent : [];
if (!config.getVoices) return 1;
else return client.listVoices({languageCode: parameters.voice.languageCode = languageCode})
})
.then((voices) => {
if (voices !== 1 && voices[0] && voices[0].voices) {
res.voices = (voices[0] && voices[0].voices) ? voices[0].voices : [];
}
helper.setByString(data, config.output || 'payload', res);
return node.send(data);
}).catch((err) => {