Giter Site home page Giter Site logo

untemps / react-vocal Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 3.0 1.6 MB

React component and hook to initiate a SpeechRecognition session

Home Page: https://untemps.github.io/react-vocal

License: MIT License

JavaScript 97.92% HTML 2.08%
speech-to-text speechrecognition speech web-speech-api react reactjs component hook javascript

react-vocal's Issues

Export isSupported getter

A isSupported is used internally to detect if the Web Speech API is available.
For some use cases, it can be useful to import it directly from the package.

Inconsistency in event signatures between result and other events makes it hard to wrap multiple events together

Current situation

All event signatures but result give the SpeechRecognition event as a first parameter to any installed handler. result, on the other hand, returns a partial result as a first parameter, and the event as a second parameter.

This makes it hard to remember the API, and hard to use a general event handler for all events (like we do in my UI toolkit so we can debounce all events from the wrapper).

Proposed change

I'd like to propose that all events returned by the SpeechRecognitionWrapper have the underlying event as the first parameter, since it's the richest source of information and the most useful for low-level use of the API.

Note that I don't mind that the Vocal component returns the computed result first.

Add section in README to explain how to handle partial supports

On iOS 14.5, SpeechRecognition API is supported but not all related APIs, like SpeechGrammarList or navigator.persmissions.
The lack of SpeechGrammarList is handled by @untemps/vocal but navigator.persmissions is not.
We should add a section to explain the developer should check for this particular case by himself.

Handle continuous sessions

TODO: Add specifications


Please pay attention to Sidnioulz's comments below:

Shouldn't this be memoized? What would be the performance impact if I ran, say, 5 commands in a row?

Originally posted by @Sidnioulz in #58 (comment)

Correct me if I'm wrong, but I should be able to completely change the commands in use without suspending the speech recognition session, right?
I'm thinking of assisted typing use cases where I want to provide matching commands based on the current field / table cell.

Originally posted by @Sidnioulz in #58 (comment)

Make the use of commands optional

Fuse.js increases your bundle size by > 50% judging on its unpacked size and your current package's unpacked size. That's quite big. I think it (and therefore commands) should be optional. You can set it as a peer dependency with a peerDependenciesMeta section to achieve that, should you want to.

Originally posted by @Sidnioulz in #58 (comment)

Replace util function by @untemps/utils

The component uses internal util function to check if a value is a function.
The @untemps/utils package contains such a function. We can replace the internal one by the one included in the external package.

The returned result isn't the most confident one, and isn't complete if interimResults / continuous are used

Current situation

  • The result event returns only the first alternative of the result
  • If the result is split (continuous mode or interimResults mode), only the first bit is sent

Proposed change

  • All result bits are aggregated
  • For each result, the most confident match is used instead of the first (occasionally, the first match is the second-most confident instead of most confident)

I think the performance cost is negligible when continuous and interimResults are false (we just loop over a small ~10 items array), but this makes the wrapper useful in more cases including the one I need to support in my UI library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.