natural-language-api-google/utils/listVoice.js

13 lines
421 B
JavaScript

const textToSpeech = require('@google-cloud/text-to-speech')
const listVoice = async (languageCode) => {
const client = new textToSpeech.TextToSpeechClient()
const [result] = await client.listVoices({ languageCode })
const voices = result.voices
return voices.map(({ name, ssmlGender, languageCodes }) => { return { name, ssmlGender, languageCodes: languageCodes[0] } })
}
module.exports = listVoice