
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Basic implementating to help altering between ongoing SpeechRecognition and intermittant SpeechSynthesis
Source: https://github.com/janmarques/discussion
Package: https://www.npmjs.com/package/discussion
When working with SpeechRecognition and SpeechSynthesis, it is important that you don't synthesise while you are recognizing.
This package helps keep this in check.
It will continually be SpeechRecognizing and passing those results to the onRecognitionResult
callback.
But whenever you want to Synthesise something, you can do this using the synthesize
method. The Recognition gets disabled and after the synthesis is done, it gets restarted.
Install with npm i discussion
We need to have a bit of hacky stuff to ensure that in the recognition callback, we can access all the properties and the DOM from your own class.
That is why we pass a factory method to create the SpeechRecognition rather than have the package do it itself.
Example:
// in the header somewhere
public CT = window.SpeechRecognition || webkitSpeechRecognition;
// in the constructor
this.discussion = new Discussion(() => new this.CT(), this.language.code, this.language.code);
this.discussion.onRecognitionResult = (x) => {
// do something with result
};
// in the initializer (eg ngOnInit or whenever your page is loaded)
this.discussion.initialize();
// after user consent, enable the Recognition
this.discussion.enableRecognition();
// anywhere in your code
this.discussion.synthesize("hello world");
FAQs
Basic implementating to help altering between ongoing SpeechRecognition and intermittant SpeechSynthesis
The npm package discussion receives a total of 3 weekly downloads. As such, discussion popularity was classified as not popular.
We found that discussion 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.