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

mespeak

v2.0.2

Published

Text to speech synthesizer

Downloads

123

Readme

mespeak

A CommonJS wrapper over Norbert Landsteiner mespeak text-to-speech library. Works in browserify. More

Example

Here is a simple example showing how to use mespeak:

var meSpeak = require("mespeak")

//Select english/american voice
meSpeak.loadVoice(require("mespeak/voices/en/en-us.json"))

//Play a sound
meSpeak.speak("hello world")

It also works in node.js too (though audio playback is unsupported):

var meSpeak = require("mespeak")
meSpeak.loadVoice(require("mespeak/voices/en/en-us.json"))
process.stdout.write(meSpeak.speak("hello world", {rawdata: "buffer"}))

Install

npm install mespeak

API

The API is identical to that on Landsteiner's web page

var meSpeak = require("mespeak")

meSpeak.speak(str[, options])

Says a string.

  • str is a string to say
  • options is a list of options to pass to the speech synthesizer. For more info, see here.

The options argument takes the following parameters:

  • amplitude: How loud the voice will be (default: 100)
  • pitch: The voice pitch (default: 50)
  • speed: The speed at which to talk (words per minute) (default: 175)
  • voice: Which voice to use (default: last voice loaded or defaultVoice, see below)
  • wordgap: Additional gap between words in 10 ms units (default: 0)
  • volume: volume relative to the global volume (number, 0..1, default: 1) Note: the relative volume has no effect on the export using option 'rawdata'.
  • rawdata: do not play, return data only. The type of the returned data is derived from the value (case-insensitive) of 'rawdata':
    • buffer: A node.js buffer containing a wav file
    • 'base64': returns a base64-encoded string.
    • 'mime': returns a base64-encoded data-url (including the MIME-header). (synonyms: 'data-url', 'data-uri', 'dataurl', 'datauri')
    • 'array': returns a plain Array object with uint 8 bit data.
    • default (any other value): returns the generated wav-file as an ArrayBuffer (8-bit unsigned).

Note: The value of 'rawdata' must evaluate to boolean 'true' in order to be recognized.

meSpeak.loadConfig(json | url[, callback])

Loads a configuration for mespeak. By default uses mespeak/mespeak_config.json There are two forms.

  • json Synchronously loads a configuration JSON object. This can be done using require("filename.json")

The other option is to load the config asynchronously via http:

  • url is the url of the config file
  • callback is called once the config is loaded

meSpeak.isConfigLoaded()

Checks if mespeak is configured

meSpeak.loadVoice(json | url[, callback] )

Loads a voice for mespeak. You can either specify a url and a callback, or a JSON object. A list of voices are included in the voices/ directory. For example, to load an english voice you can do:

meSpeak.loadVoice(require("mespeak/voices/en/en-us.json"))`

The other form is the same as in meSpeak.loadConfig and takes two arguments:

  • url which is the url of the voice to load
  • callback which is an optional callback-handler. The callback will receive two arguments:
    • a boolean flag for success
    • either the id of the voice, or a reason for errors ('network error', 'data error', 'file error')

meSpeak.setDefaultVoice(str)

Sets the default voice to use. The default voice is always the the last voice loaded.

meSpeak.isVoiceLoaded()

Checks if a voice is loaded

meSpeak.getDefaultVoice()

Returns the default voice.

meSpeak.setVolume(volume)

Sets the volume of playback globally.

  • volume is the volume represented as a float

This update happens immediately and is applied relatively

meSpeak.getVolume()

Returns playback volume.

meSpeak.play(stream[, relativeVolume])

Plays a sound. You can use this to cache previously generated voices and play them back at run time by setting the

  • stream is a sound to play
  • relativeVolume is the relative loudness of the sound

meSpeak.resetQueue()

Clears playback queue, stops all currently playing sounds.

meSpeak.canPlay()

Checks if mespeak can play a sound.

Credits

(c) 2011-2013 Norbert Landsteiner. GPL License

NPM entry currently maintained by Mikola Lysenko