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

lmnt-node

v1.2.3

Published

Node.js client library for the LMNT API

Downloads

1,080

Readme

LMNT Node module

Overview

A Node.js module to provide convenient access to the LMNT API from applications written in Javascript.

For more on the LMNT API, see the documentation.

Usage

Create a Speech instance passing your API key to the constructor, and call any of the available API methods.

To obtain an API key, visit the LMNT Account page.

Sample code:

import Speech from 'lmnt-node';

// You can set the `LMNT_API_KEY` environment variable instead of passing in a string below.
const speech = new Speech('your-api-key-here');

// Fetch the list of available voices.
const voices = await speech.fetchVoices();
console.log(voices);

// Synthesize text to audio.
const synthesis = await speech.synthesize('Hello World.', 'lily', { format: 'mp3' });
console.log(synthesis.audio);

See the simple demo apps for more examples.

Next.js and Edge Runtime

This SDK is compatible with Next.js and the Edge Runtime. To use it in a Next.js project, you will need to add the following to your next.config.js file:

webpack: (config, { isServer }) => {
    // Only run this on the server
    if (isServer) {
      config.resolve.fallback = config.resolve.fallback || {};
      config.resolve.fallback.fs = false;
    }

    return config;
  },

The createVoice() method uses the fs module, which is not available in the Edge Runtime. While the SDK automatically disables this method in non-Node.js environments, this code snippet will prevent the build from failing when the fs module is not available.

Learn more about custom webpack configuration in Next.js here.

Release History

1.2.2 / Aug 1, 2024

  • add conversational option to streaming and non-streaming synthesis

1.2.1 / July 16, 2024

  • add language option to streaming synthesis

1.2.0 / May 15, 2024

  • add optional sample_rate and language parameters in synthesize
  • add optional baseUrl parameter to Speech constructor
  • fix incorrect type definitions for synthesis response

1.1.2 / Feb 15, 2024

  • enable client-specified format and sample_rate in streaming connection
  • read LMNT_API_KEY from environment if not explicitly specified

1.1.1 / Feb 14, 2024

  • support CommonJS modules in addition to ES modules
  • expose more types to TypeScript for better tooling support

1.1.0 / Jan 5, 2024

  • synthesizeStreaming will now return a buffer_empty boolean when extras are requested. This can be used to determine when the server has no more audio to send after the client has sent a flush message.

1.0.0 / Nov 16, 2023

  • Breaking changes - Please update your code to use the new behavior or pin to a previous version if preferred:
    • Default audio encoding format in synthesize is now mp3 (previously wav). Format can be specified by adding the format='wav' or format='mp3' option to the synthesize call.
    • fetchVoices now returns a list of voice dictionaries for simplicity of return values and ease of use. Previously it returned a dictionary with key voices which contained a dictionary of voice dictionaries keyed by their voice id.
    • synthesize no longer returns just the binary audio data. It instead always returns a dictionary with keys audio, durations (optional), and seed (optional).
  • Features:
    • Add ability to filter by starred and owner in fetchVoices.
    • Add ability to return durations and seed from synthesize.
    • Add fetchVoice method to fetch a single voice.
    • Add createVoice method to create a new voice.
    • Add updateVoice method to update an existing voice, including starring voices.
    • Add deleteVoice method to delete an existing voice.
    • Add synthesizeStreaming method to support full-duplex synthesis streaming.
    • Add fetchAccount method to fetch account information.

0.0.2 / Sep 20, 2023

  • Features:
    • Add optional length parameter specifying target speech duration.
    • Make streaming work with the Edge runtime.
    • Add TypeScript type definitions.
    • Add close method to StreamingSynthesisConnection class allowing explicit cleanup if desired.
  • Bug fixes:
    • End the streaming async iterator when the synthesis is finished.
    • Fix demo link in README.

0.0.1 / Sep 6, 2023

  • Initial release.