A lightweight library to get the VoiceID programmatically without install or call the heavyweight aws-sdk for nodejs. https://docs.aws.amazon.com/polly/latest/dg/voicelist.html
node -v
node: v6.0.0
npm install --save aws-polly-voices
yarn add aws-polly-voices
const Voices = require('aws-polly-voices')
const voices = new Voices()
import Voices from 'aws-polly-voices'
const voices = new Voices()
const Voices = require('aws-polly-voices')
const voices = new Voices()
const brazilianFemaleVoice = voices.brazilian().female()
// Returns the array with the voice(s) data.
// Depending on the selected language this array can have more than one element.
const voiceData = brazilianFemaleVoice.val
console.log(voiceData)
/**
[{
Gender: 'Female',
Name: 'Vitória',
LanguageName: 'Brazilian Portuguese',
Id: 'Vitoria',
LanguageCode: 'pt-BR'
}]
*/
// Get the VoiceId.
// If there is only one element in voiceData array then it will return that voiceId.
// Otherwise it will return a random voiceId based on the criteria (chained methods and/or filters).
// See the next example for clarity.
const voiceId = brazilianFemaleVoice.id // Vitoria
const Voices = require('aws-polly-voices')
const voices = new Voices()
const englishMaleVoices = voices.english().male()
const voiceData = englishMaleVoices.val
console.log(voiceData)
/**
[{
Gender: 'Male',
Name: 'Matthew',
LanguageName: 'US English',
Id: 'Matthew',
LanguageCode: 'en-US'
},
{
Gender: 'Male',
Name: 'Justin',
LanguageName: 'US English',
Id: 'Justin',
LanguageCode: 'en-US'
}]
*/
const voiceId = englishMaleVoices.id // random value: [Matthew, Justin]
const matthew = voiceData[0].Id // Matthew
const justin = voiceData[1].Id // Justin
Most of the methods are chainable.
const Voices = require('aws-polly-voices')
const voices = new Voices()
// available languages by name
// this parameter can be: ['Gender', 'Name', 'LanguageName', 'Id', 'LanguageCode']
// defaults to: LanguageName
const allLanguages = voices.languages()
// available Voice Id
const allVoicesId = voices.languages('Id')
// by language: english
const english = voices.english() || voices.byLang('english')
// by language code: nl-NL
const dutch = voices.dutch() || voice.byLangCode('nl-NL')
// by gender: male || female
const portuguese = voices.portuguese().male() || voices.brazilian().male()
// by voice id
const vitoria = voices.byId('Vitoria')
// reseting the filter
const portuguese = voices.portuguese().male()
voices.reset()
const dutch = voices.dutch().female()
To run the tests, go to the terminal and enter npm run test
- 100% unit test coverage
- Documentation (this file)
- CI/CD with
sematinc-release
integrating withTravis
,Github
andNPM registry
- Add missing helper methods to other languages/nationalities. E.g.: french, italian, spanish and so on
If you want to collaborate, please feel free. I appreciate any help :)
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Cleber Gasparoto - Profile
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.