grace-recognition
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

grace-recognition

A composition api for SpeechSynthesis

NPM version Codacy Badge Test coverage npm download License

Sonar

Installing

# use pnpm
$ pnpm install grace-recognition

# use npm
$ npm install grace-recognition --save

# use yarn
$ yarn add grace-recognition

Usage

  1. Simple use:
export type RecognitionEventType =
  | 'start'
  | 'audiostart'
  | 'soundstart'
  | 'speechstart'
  | 'result'
  | 'speechend'
  | 'soundend'
  | 'audioend'
  | 'end'
  | 'error'
  | 'nomatch'

export interface RecognitionOptions {
  preferTouchEvent: boolean
  lang: 'zh-CN' | string
  interimResults: boolean
  maxAlternatives: number
  continuous: boolean
  onStatusChange?: (
    status: RecognitionEventType,
    event: Event | SpeechRecognitionEvent | SpeechRecognitionErrorEvent
  ) => void
}

import GraceRecognition from 'grace-recognition'

const recognition = new GraceRecognition({
  continuous: true,
  onStatusChange: (
    status: RecognitionEventType,
    event: Event | SpeechRecognitionEvent | SpeechRecognitionErrorEvent
  ) => {}
})

recognition.start('very good')
recognition.recognition('powered by saqqdy<https://github.com/saqqdy>')
  1. Using unpkg CDN:
<script src="https://unpkg.com/grace-recognition/1.0.0/dist/index.global.prod.js"></script>
<script>
  const recognition = new GraceRecognition()
</script>

Support & Issues

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i grace-recognition

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

60.5 kB

Total Files

11

Last publish

Collaborators

  • saqqdy