Socket
Socket
Sign inDemoInstall

discussion

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discussion

Basic implementating to help altering between ongoing SpeechRecognition and intermittant SpeechSynthesis


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Source: https://github.com/janmarques/discussion

Package: https://www.npmjs.com/package/discussion

Discussion: combining SpeechRecognition and SpeechSynthesis

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.

How to use

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");

Keywords

FAQs

Package last updated on 05 Dec 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc