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

polly-s3

v0.0.2

Published

polly-s3 - A library which uses AWS Polly to render text to speech to audio files in an S3 bucket.

Downloads

1

Readme

polly-s3

Overview

polly-s3 is a node.js module which renders text-to-speech using AWS Polly and saves it to an audio file in an S3 bucket.

You can use this module to render Polly speech on-the-fly for use in voice applications. If the S3 bucket has a public access policy, the rendered speech will be available at an HTTPS URL, suitable for use in an Alexa skill.

So far it has mostly been used in AWS Lambda functions - an understanding of how to run code in an AWS context will come in handy while using this module.

Install

npm install polly-s3

Usage

⚠ Configuration

polly-s3 requires some configuration to be set before it will work properly.

The name of an S3 bucket to hold rendered speech files needs to be set in either an environment variable named AWS_S3_DEFAULT_BUCKET or passed in an options object to new PollyS3(), e.g new PollyS3({ s3Bucket : 'someBucketName' }).

polly-s3 also needs to use an AWS IAM role which has rights to both use Polly and write to the specified S3 bucket. If running on AWS Lambda, you can create this IAM role and assign it to the Lambda function. If running elsewhere, you'll need to provide credentials using one of the methods described in the AWS SDK for JavaScript docs.

Similarly, the AWS region needs to be set. Information about that is also in the AWS SDK for JavaScript docs.

If you need to pass any options to the constructors for the Polly or S3 SDKs, you can pass a combined options object to the polly-s3 constructor; this object will be passed on to the Polly and S3 constructors.

Example

var PollyS3 = require('polly-s3');

var p = new PollyS3();

var sentence = "Is this thing on?";

p.renderSentence( sentence, null, function( err, url ){
    if( err ) throw(err);
    console.log( "Rendered speech is at URL:", url );
});

API

renderSentence( sentence, voice, callback )

Render some speech.

Parameters:

  • sentence: the sentence to render. Can be plain text or SSML.
  • voice: the Polly voice ID to use for this sentence. Can be null; defaults to 'Brian'.

describeVoices( language, callback )

List Polly voices for a given language.

Returns data as described in the AWS Polly docs.

Parameters:

  • language: the language which voices to list, e.g. en-US. Can be a single string or an array, e.g. [ 'en-GB', 'en-US', 'en-AU', 'en-IN', 'en-GB-WLS' ] for all English voices.

randomVoice( language, callback )

Fetch description for one voice, chosen at random from all in a given language.

Returns data as described in the AWS Polly docs.

Parameters:

  • language: the language which voices to list, e.g. en-US. Can be a single string or an array, e.g. [ 'en-GB', 'en-US', 'en-AU', 'en-IN', 'en-GB-WLS' ] for all English voices.

Author

Henry Cooke [email protected] http://github.com/prehensile

License

  • MIT : http://opensource.org/licenses/MIT

TODO

Security / privacy

  • Implement expiry dates / sweep for old audio files in the S3 bucket and delete them
  • Implement signed S3 one-time URLs as an option

Polly features

  • Lexicons
  • Different audio file formats (currently hardcoded to MP3)