Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
basic-speech-recognition-grammar
Advanced tools
When working with SpeechRecognition, you are given back a range of possibilities about word that the user said.
If your application works in the sense of "commands", meaning you know beforehand which words your are looking (listening) for, then this package could help you.
Install with npm i basic-speech-recognition-grammar
Import the tryFindNeedle method import { isLast, tryFindNeedle } from 'basic-speech-recognition-grammar';
In the onresult
handler of SpeechRecognition
, pass that whole event to tryFindNeedle
.
This will return a GrammarResult
, containing the status and possible result.
Example:
this.reco = new this.SpeechRecognition();
this.reco.continuous = false;
this.reco.interimResults = true;
this.reco.lang = this.language.code;
this.reco.maxAlternatives = 10;
this.reco.onresult = (x) => {
if (!isLast(x)) { return; }
var haystack = ["red", "blue", "green"];
var result = tryFindNeedle(x, haystack);
if (result.resultType == ResultType.RecognitionNotFinished) {
return;
}
if (result.resultType == ResultType.NoResult) {
this.sayOutLoud(this.language.notFound);
return;
}
if (result.resultType == ResultType.MultipleCandidates) {
this.sayOutLoud(this.language.foundMultiple + result.conflictingResults.join(", "));
return;
}
var heardCommand = result.result;
// do sth with result.
};
The possible words said are compared with the predefined haystack you provide.
This comparison is done using this project.
The comparison is purely based on the written similarity, not the auditive similarity.
It is considered a "match" if the similarity is 0.6 or higher. This is configurable in the tryFindNeedle() options.
Spaces and capitalization are ignored when comparing strings.
FAQs
Basic grammar system for SpeechRecognition
The npm package basic-speech-recognition-grammar receives a total of 1 weekly downloads. As such, basic-speech-recognition-grammar popularity was classified as not popular.
We found that basic-speech-recognition-grammar 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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.