
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@lephenix47/speech-to-text-utility
Advanced tools
Introducing the @lephenix47/speech-to-text-utility
library, a powerful and flexible solution designed for JavaScript and TypeScript developers looking to integrate speech recognition features into their projects. Built with simplicity and extensibility in mind, this library harnesses the power of the browser's Web Speech API to transcribe real-time audio inputs with ease.
To begin, you'll need to import the library into your project:
import { SpeechToText } from '@lephenix47/speech-to-text-utility';
From here, you can personalize the speech recognition behavior to fit your application's demands. Some notable methods worth mentioning include setting the language, enabling interim results, limiting the number of alternatives, toggling continual recognition, and configuring event callbacks.
Example:
const speechToText = new SpeechToText();
speechToText
.setLanguage('en-US')
.setInterimResults(true)
.setMaxAlternatives(5)
.setContinuous(true)
.setOnResult((sentence, isFinal) => {
if (isFinal) {
console.log(`Received Final Result: "${sentence}"`);
} else {
console.log(`Received Intermediate Result: "${sentence}"`);
}
});
Ready to embark on recognizing speech? Trigger the speech recognition engine with the startRecognition() method.
speechToText.startRecognition();
Should you ever decide to halt the recognition midway, rely on the handy stopRecognition() method.
speechToText.stopRecognition();
Method | Description | Return Value |
setLanguage(language: string) | Sets the language for the speech recognition. | SpeechToText |
setInterimResults(bool: bool) | Determines if interim results are included in the recognition. | SpeechToText |
setMaxAlternatives(num: number) | Limits the number of recognition alternatives offered. | SpeechToText |
setContinuous(bool: bool) | Switches on or off the continuous speech recognition mode. | SpeechToText |
setOnResult(fn: Function) | Registers a callback function invoked whenever a speech recognition result occurs. | SpeechToText |
setOnEnd(fn: Function) | Subscribes to the speech recognition ending event. | SpeechToText |
setOnError(fn: Function) | Signs up for the speech recognition error event. | SpeechToText |
setOnStart(fn: Function) | Hooks into the speech recognition initialization event. | SpeechToText |
setOnAudioStart(fn: Function) | Captures the audio capturing commencement event. | SpeechToText |
setOnSoundStart(fn: Function) | Monitors the audio's sonic occurrences triggering the fn callback. | SpeechToText |
setOnSoundEnd(fn: Function) | Observes the conclusion of auditory happenings invoking the fn callback. | SpeechToText |
setOnSpeechStart(fn: Function) | Seizes the moment when vocalizations ignite the fn callback. | SpeechToText |
setOnSpeechEnd(fn: Function) | Records the culmination of verbal articulations summoning the fn callback. | SpeechToText |
setOnNoMatch(fn: Function) | Documents the absence of a match incited by the fn callback. | SpeechToText |
startRecognition() | Commences speech recognition processing. | Promise<void> |
stopRecognition() | Terminates ongoing speech recognition activity. | Promise<void> |
get maxAlternatives() | Retrieves the maximum number of recognition alternatives. | number |
get continuous() | Obtains the status of continuous speech recognition. | boolean |
Integrating speech recognition into your projects has never been simpler, courtesy of the @lephenix47/speech-to-text-utility
library. Benefit from hassle-free integration, robustness, and extensive customizability today! Should you require any assistance or contribute, head over to GitHub and join the community.
Don't hesitate to leave a star rating or review to express appreciation for this open-source endeavor. Happy coding!
FAQs
description
We found that @lephenix47/speech-to-text-utility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.