# use pnpm
$ pnpm install grace-recognition
# use npm
$ npm install grace-recognition --save
# use yarn
$ yarn add grace-recognition
- 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>')
- 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>
Please open an issue here.