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

vocalfusion.io

v1.1.12

Published

A lightweight Text-to-Speech library.

Downloads

981

Readme

VocalFusion.io

A comprehensive library suite leveraging Web APIs for Text-to-Speech (TTS) and Speech-To-Text (STT) functionalities. Easily integrate voice synthesis and speech recognition into your web projects with options for customization and seamless browser compatibility.


Installation

Install the package via npm:

npm install vocalfusion.io

Features

| Feature | Description | Status | |----------------------|--------------------------------------------------------------------------|--------------| | Customizable | Adjust the rate, pitch, and voice of speech synthesis (TTS). | ✅ Complete | | Promise-Based | Intuitive API design with success and error handling via Promises. | ✅ Complete | | Browser-Friendly | Designed to work seamlessly with modern web browsers. | ✅ Complete | | Lightweight | No external dependencies, uses native Web APIs (TTS & STT). | ✅ Complete | | Error Handling | Provides detailed error messages for invalid or missing inputs. | ✅ Complete |


Usage

Importing the Library

ES Module

import { TTS, STT } from "./node_modules/vocalfusion.io/dist/index.esm.js";

// TTS Example
TTS.speak("Hello, World!")
  .then(() => console.log("Speech completed"))
  .catch(console.error);

// STT Example
const speech = new STT({ lang: "en-US", continuous: true });
speech.start();
speech.onResult((transcript) => {
  console.log("Recognized speech:", transcript);
});
speech.onError((err) => console.error("Error:", err));

CommonJS

const { TTS, STT } = require("./node_modules/vocalfusion.io/dist/index.cjs.js");

// TTS Example
TTS.speak("Hello, World!")
  .then(() => console.log("Speech completed"))
  .catch(console.error);

// STT Example
const speech = new STT({ lang: "en-US", continuous: true });
speech.start();
speech.onResult((transcript) => {
  console.log("Recognized speech:", transcript);
});
speech.onError((err) => console.error("Error:", err));

TTS Options

| Parameter | Type | Default | Description | |-----------|----------|---------|-----------------------------------------------| | text | string | null | The text to be spoken. | | rate | number | 1 | The speech rate (range: 0.1 to 10). | | pitch | number | 1 | The pitch of the voice (range: 0 to 2). | | voice | string | null | The name of the voice to use (optional). |


STT Options

| Parameter | Type | Default | Description | |------------------|-----------|------------|------------------------------------------------------------| | lang | string | en-US | The language for speech recognition. | | interimResults | boolean | true | Enable or disable interim results during recognition. | | continuous | boolean | false | Set whether recognition continues after each phrase. |


Examples

TTS Examples

Speak Text with Default Settings

TTS.speak("Hello, how are you?")
  .then(() => console.log("Speech completed"))
  .catch(console.error);

Speak Text with Custom Settings

TTS.speak("Custom settings example.", {
  rate: 1.5,
  pitch: 2,
  voice: "Google UK English Male"
})
  .then(() => console.log("Speech completed"))
  .catch(console.error);

Retrieve Available Voices

TTS.getVoices()
  .then((voices) => console.log("Available voices:", voices))
  .catch(console.error);

STT Examples

Start Speech Recognition

const speech = new STT({ lang: "en-US", continuous: true });
speech.start();
speech.onResult((transcript) => {
  console.log("Recognized speech:", transcript);
});
speech.onError((err) => console.error("Error:", err));

Restart on Recognition End

speech.onEnd(() => {
  console.log("Recognition ended. Restarting...");
  speech.start();
});

Stop Speech Recognition

speech.stop();
speech.onEnd(() => {
  console.log("Speech recognition stopped.");
});

Browser Compatibility

| Browser | Supported | Notes | |------------------------|-----------------|--------------------------------------------| | Chrome | ✅ Yes | Full support. | | Firefox | ✅ Yes | Full support. | | Safari | ✅ Yes | Full support (macOS/iOS). | | Edge | ✅ Yes | Full support. | | Internet Explorer | ❌ No | Not supported. |

For more details, visit Can I Use - SpeechSynthesis and Can I Use - SpeechRecognition.


Contributing

We welcome contributions! To contribute:

For questions or suggestions, feel free to email us at [email protected].


License

This project is licensed under the MIT License. See the LICENSE file for details.