Socket
Socket
Sign inDemoInstall

voice-rss

Package Overview
Dependencies
148
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    voice-rss

An API wrappers for the Voice RSS Text-To-Speech API


Version published
Maintainers
1
Install size
4.53 MB
Created

Readme

Source

An API wrapper for the Voice RSS Text-To-Speech API

npm npm bundle size npm

The Voice RSS Text-To-Speech API creates a high quality audio stream with a very simple implementation. This npm module is a wrapper for this API to make it easy to implement in your Node or JavaScript projects.

Table of contents:

Quickstart

Before you begin

  1. Setup an API key

Installing the client library

// npm
npm install voice-rss --save-dev

// yarn
yarn add voice-rss --dev

Initiate the client library

// Imports the Voice RSS client library: es6 import (alternative 1)
import VoiceRSSWebApi from './voice-rss-api';

// Imports the Voice RSS client library: require (alternative 2)
const VoiceRSSWebApi = require('./voice-rss-api');

// Instantiates the client
const VoiceRSS = new VoiceRSSWebApi();
VoiceRSS.setApiKey('API_KEY');

// Instantiates the client with an api key
const VoiceRSS = new VoiceRSSWebApi('API_KEY');

Using the client library

Here are three examples of how to use the client library

// callback implementation
// the second argument is the options
// see "Default options" section below for available options and for setting options all at once
// see "Setting options" section below to set options one by one
VoiceRSS.getAudio('Hello World', {}, (err, audio) => {
    if (err) console.error(err);
    else new Audio(audio).play();
});

// promise implementation
// you can pass the options as the second argument, as in the callback implementation
VoiceRSS.getAudio('Hello World')
    .then(audio => new Audio(audio).play())
    .catch(error => console.log(error));

// async/await implementation
// you can pass the options as the second argument, as in the callback implementation
(async () => {
    const audio = await VoiceRSS.getAudio('Hello World');
    
    // play the audio
    new Audio(audio).play();
    
    // OR console log the audio (base64 encoding)
    console.log(audio);
})();
Setting options
VoiceRSS.setApiKey('API_KEY');
VoiceRSS.setLanguage('en-us');
VoiceRSS.setSpeechRate(0);
VoiceRSS.setAudioCodec('auto');
VoiceRSS.setAudioFormat('44khz_16bit_stereo');
VoiceRSS.setSSML(false);
VoiceRSS.setB64(false);
Getting options
VoiceRSS.getApiKey();
VoiceRSS.getLanguage();
VoiceRSS.getSpeechRate();
VoiceRSS.getAudioCodec();
VoiceRSS.getAudioFormat();
VoiceRSS.getSSML();
VoiceRSS.getB64();
Default options
const options = {
    hl: 'en-us',
    r: 0,
    c: 'mp3',
    f: '44khz_16bit_stereo',
    ssml: false,
    b64: false,
};
Available options

All of the available options can be found in the official documentation

Versioning

This library follows Semantic Versioning.

Contributing

Contributions welcome! See the Contributing Guide.

License

MIT

See LICENSE

To Do

  • 100% test coverage
  • Implement typescript
  • Minimize bundle size

Keywords

FAQs

Last updated on 24 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc