Skip to content

saqqdy/grace-recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A composition api for SpeechRecognition

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published