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

simple-tts

v0.1.3

Published

simple TTS API via espeak

Downloads

2

Readme

intro

what's this for?

Wrote this module to expose a simple API for speech generation from a given text. The adopted approach is to make use of the espeak TTS engine. Espeak is small, free and the results are crude, but supports many languages (run espeak --voices to chec k the ones available in your machine) and is enough for some scenarios. Later on I may offer alternative engines support (you want to help out?).

why not use X instead?

You can use browser APIs for Chrome, Safari and such, if available. You can also use third-party web services for TTS. The point here is that you keep the dependency on your side, at the server level. Currently espeak can be run in browsers but that's heavy on CPU and memory - using this approach you request the text's speech and get back an encoded mp3/ogg of the generated audio sample.

helping out

I'm by no means an expert in TTS usage. Feel free to contribute with optimizations, sample usages of alternate engines and/or pull requests of changes to make this work in additional OSs. I've marked this linux-only because I didn't have the chance to try it out in different environments and because I figured out loads of servers run a debian-like flavour of linux anyway.


for direct node usage

install in node (notice that npm install invokes apt-get to install both the espeak TTS engine and the lame and vorbis-tools audio encoders)

npm install simple-tts

use in node

var speak = require('simple-tts');

// usage case 1 - writes the binary audio sample to the response stream (for returning it in an HTTP handler)
response.writeHead(200, {'Content-Type': 'audio/ogg'});
speak('hello world', {format:'ogg', stream:response});

// usage case 2 - creates the file /tmp/hello_world.mp3 in your OS (for caching or other purposes, the filename extension is automatically appended to the give filename)
speak('hello world', {format:'mp3', filename:'/tmp/hello_world'});

for checking the server and js examples

install and run (for demo and serving via HTTP)

sudo apt-get install espeak lame vorbis-tools

git clone [email protected]:JosePedroDias/simple-tts.git

cd simple-tts

node simple-tts-server &

demo

go to http://127.0.0.1:8888

use as a remote service

    <script type="text/javascript" src="http://SERVER_NAME:SERVER_PORT/js/simple-tts-client.js"></script>

    <script type="text/javascript">
        speak('Hello world!', onDone: function() {
            speak('Comme vas tu?', {lang:'fr'});
        });
    </script>

Documentation:

see API.md