npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aws-polly-voices

v1.21.0

Published

Helper module to get AWS polly voices in an idiomatic way

Downloads

49

Readme

AWS Polly Voices

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

travis build codecov coverage version downloads style quality license

Getting Started

Prerequisites

node -v
node: >= v10.23.1

Installing

Using npm

npm install --save aws-polly-voices
npm i aws-polly-voices

Using Yarn

yarn add aws-polly-voices

How to use

Importing with Commonjs style

const Voices = require('aws-polly-voices')
const voices = new Voices()

Importing with ES6 modules style

import Voices from 'aws-polly-voices'
const voices = new Voices()

Examples

With SINGLE VoiceId

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

With MULTIPLE VoiceId

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

Full API reference

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().female()

// by voice id
const vitoria = voices.byId('Vitoria')

// reseting the filter
voices.reset()
const portuguese = voices.portuguese().male()

// Helpers for specific language
const english = voices.english()
const portuguese = voices.portuguese()
const dutch = voices.dutch()
const russian = voices.russian()
const german = voices.german()
const polish = voices.polish()
const italian = voices.italian()
const turkish = voices.turkish()
const spanish = voices.spanish()
const welsh = voices.welsh()
const icelandic = voices.icelandic()
const japanese = voices.japanese()
const norwegian = voices.norwegian()
const swedish = voices.swedish()
const french = voices.french()
const danish = voices.danish()
const arabic = voices.arabic()

// Helpers for specific language and country
const american = voice.american()
const americanSpanish = voice.americanSpanish()
const brazilian = voice.brazilian()
const europeanPortuguese = voice.europeanPortuguese()
const british = voices.british()
const mexican = voices.mexican()
const indianEnglish = voices.indian()
const canadianFrench = voices.canadianFrench()
const castilian = voices.castilian()
const welshEnglish = voices.welshEnglish()

Running the tests

To run the tests, go to the terminal and enter:

  • All tests: npm run test
  • Watch: npm run test:watch

TODO

  • [x] 100% unit test coverage
  • [x] Documentation (this file)
  • [x] CI/CD with sematinc-release integrating with Travis, Github and NPM registry
  • [ ] Add support for Typescript
  • [x] Implement a helper for Portugal Portuguese
  • [x] Implement a helper for Welsh English
  • [x] Implement a helper for Spanish
  • [x] Implement a helper for US Spanish
  • [x] Implement a helper for Castilian Spanish
  • [x] Implement a helper for Mexican Spanish
  • [x] Implement a helper for Icelandic
  • [x] Implement a helper for Arabic
  • [ ] Implement a helper for Chinese Mandarin
  • [x] Implement a helper for Welsh
  • [x] Implement a helper for Swedish
  • [x] Implement a helper for Indian English
  • [x] Implement a helper for Canadian French
  • [ ] Implement a helper for Australian English
  • [ ] Implement a helper for Romanian
  • [x] Implement a helper for Turkish
  • [x] Implement a helper for French
  • [x] Implement a helper for Danish
  • [x] Implement a helper for Japanese
  • [x] Implement a helper for Norwegian
  • [ ] Implement a helper for Korean
  • [x] Implement a helper for Italian

Contributing

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.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.