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.
Install the package via npm:
npm install vocalfusion.io
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 |
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));
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));
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). |
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. |
TTS.speak("Hello, how are you?")
.then(() => console.log("Speech completed"))
.catch(console.error);
TTS.speak("Custom settings example.", {
rate: 1.5,
pitch: 2,
voice: "Google UK English Male"
})
.then(() => console.log("Speech completed"))
.catch(console.error);
TTS.getVoices()
.then((voices) => console.log("Available voices:", voices))
.catch(console.error);
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));
speech.onEnd(() => {
console.log("Recognition ended. Restarting...");
speech.start();
});
speech.stop();
speech.onEnd(() => {
console.log("Speech recognition stopped.");
});
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.
We welcome contributions! To contribute:
For questions or suggestions, feel free to email us at ytraj0660@gmail.com
.
This project is licensed under the MIT License. See the LICENSE file for details.