An API wrapper for the Voice RSS Text-To-Speech API
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
- 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
import VoiceRSSWebApi from './voice-rss-api';
const VoiceRSSWebApi = require('./voice-rss-api');
const VoiceRSS = new VoiceRSSWebApi();
VoiceRSS.setApiKey('API_KEY');
const VoiceRSS = new VoiceRSSWebApi('API_KEY');
Using the client library
Here are three examples of how to use the client library
VoiceRSS.getAudio('Hello World', {}, (err, audio) => {
if (err) console.error(err);
else new Audio(audio).play();
});
VoiceRSS.getAudio('Hello World')
.then(audio => new Audio(audio).play())
.catch(error => console.log(error));
(async () => {
const audio = await VoiceRSS.getAudio('Hello World');
new Audio(audio).play();
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