vocalfusion.io

1.1.12 • Public • Published

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 ytraj0660@gmail.com.


License

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

Package Sidebar

Install

npm i vocalfusion.io

Weekly Downloads

2

Version

1.1.12

License

MIT

Unpacked Size

13.7 kB

Total Files

4

Last publish

Collaborators

  • _tharunraj.06