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

13 lines
421 B
JavaScript
Raw Normal View History

2023-10-09 17:22:48 +00:00
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