# asr-answering

> Utility Hooks for Earudite

Latest version **4.1.7** (published 2022-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install asr-answering
pnpm add asr-answering
yarn add asr-answering
bun add asr-answering
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.7 |
| Published | 2022-03-19 |
| First published | 2021-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 15 |
| Unpacked size | 90.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mshivam2409 |
| Maintainers | mshivam |

## Links

- npm: https://www.npmjs.com/package/asr-answering
- Repository: https://github.com/Mshivam2409/asr-answering
- Homepage: https://github.com/Mshivam2409/asr-answering#readme
- Issues: https://github.com/Mshivam2409/asr-answering/issues
- npm.io page: https://npm.io/package/asr-answering

## Dependencies (15)

- [use-sound](https://npm.io/package/use-sound.md) ^4.0.1
- [seedrandom](https://npm.io/package/seedrandom.md) ^3.0.5
- [@tensorflow/tfjs](https://npm.io/package/@tensorflow/tfjs.md) ^3.11.0
- [use-countdown-hook](https://npm.io/package/use-countdown-hook.md) ^2.1.0
- [react-countdown-hook](https://npm.io/package/react-countdown-hook.md) ^1.1.1
- [react-media-recorder](https://npm.io/package/react-media-recorder.md) ^1.6.3
- [@tensorflow/tfjs-core](https://npm.io/package/@tensorflow/tfjs-core.md) ^3.11.0
- [@tensorflow/tfjs-data](https://npm.io/package/@tensorflow/tfjs-data.md) ^3.11.0
- [@tensorflow/tfjs-layers](https://npm.io/package/@tensorflow/tfjs-layers.md) ^3.11.0
- [react-speech-recognition](https://npm.io/package/react-speech-recognition.md) ^3.9.0
- [voice-activity-detection](https://npm.io/package/voice-activity-detection.md) ^0.0.5
- [@tensorflow/tfjs-backend-webgl](https://npm.io/package/@tensorflow/tfjs-backend-webgl.md) ^3.11.0
- [@types/react-speech-recognition](https://npm.io/package/@types/react-speech-recognition.md) ^3.6.1
- [@types/voice-activity-detection](https://npm.io/package/@types/voice-activity-detection.md) ^0.0.2
- [@tensorflow-models/speech-commands](https://npm.io/package/@tensorflow-models/speech-commands.md) ^0.5.4

## Recent versions

- 4.1.7 (latest) — 2022-03-19
- 4.1.6 — 2022-03-16
- 4.1.5 — 2022-03-16
- 4.1.4 — 2022-03-16
- 4.1.3 — 2022-03-16
- 4.1.2 — 2022-03-16
- 4.1.0 — 2022-03-16
- 4.0.3 — 2022-03-16
- 4.0.2 — 2022-03-16
- 4.0.1 — 2022-03-16
- 4.0.0 — 2022-03-13
- 3.0.0 — 2022-03-13
- 1.1.2 — 2022-02-19
- 1.1.1 — 2022-02-19
- 1.1.0 — 2022-02-06
- … 6 more at https://npm.io/package/asr-answering/versions

## README

# asr-answering

> Utility Hooks for Earudite

[![NPM](https://img.shields.io/npm/v/asr-answering.svg)](https://www.npmjs.com/package/asr-answering) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save asr-answering
```

## Usage

```tsx
import React, { useState } from 'react'

import { useOnlineAnswering } from 'asr-answering'

const App = () => {
  const [ready, setReady] = useState(false)
  const [buzzin, setBuzzin] = useState(false)
  const [finalanswer, setAnswer] = useState('')
  const [src, setSrc] = useState('')
  const {
    initialize,
    startListening,
    stopListening,
    listening,
    recordingState,
    timeLeft,
    voiceState,
    volume,
    answer,
    permissions,
    error,
    errormsg
  } = useOnlineAnswering({
    audio: {
      buzzin:
        'https://assets.mixkit.co/sfx/download/mixkit-game-show-wrong-answer-buzz-950.wav',
      buzzout:
        'https://assets.mixkit.co/sfx/download/mixkit-game-show-wrong-answer-buzz-950.wav'
    },
    onAudioData: () => {},
    timeout: 10000,
    isReady: ready,
    onComplete: async (answer, blob) => {
      setAnswer(answer)
      setBuzzin(false)
      setSrc(URL.createObjectURL(blob))
      console.log(answer, blob)
    },
    onBuzzin: () => {
      setBuzzin(true)
      console.log('Buzzed In')
    },
    gameTime: 9000000
    ASRthreshold: 0.8
  })

  return (
    <div className='App'>
      <header className='App-header'>
        <p>{`ASR is ${ready ? 'ready' : 'not ready'} to use.`}</p>
        <p>
          Press Enable to enable ASR. <br /> Press listen to start listening,
          speak go, then you will buzz in, speak your answer, then speak stop.
          <br />
          You must wait around 3-4s after saying stop to allow time for
          processing.
          <br /> Press stop to turn off ASR.
          <br />
          You can listen to recorded audio after processing ends.
        </p>
        <p>{`Mic permission is ${permissions.Mic}`}</p>
        <p>{`Browser Supports ASR : ${permissions.ASR}`}</p>
        <p>{`Volume is ${volume}`}</p>
        <p>{`Speaking :  ${voiceState}`}</p>

        <button
          onClick={async () => {
            await initialize()

            setReady(true)
          }}
        >
          ENABLE
        </button>
        <button
          onClick={() => {
            startListening()
          }}
        >
          LISTEN
        </button>
        <button
          onClick={() => {
            stopListening()
          }}
        >
          STOP
        </button>

        <p>{` ${buzzin ? 'Buzzed In' : 'Not Buzzed In'}.`}</p>
        <p>{`Answer is ${finalanswer}.`}</p>
        {src !== '' && <audio controls src={src} />}
      </header>
    </div>
  )
}

export default App
```

## License

MIT © [Mshivam2409](https://github.com/Mshivam2409)

---
_Source: https://npm.io/package/asr-answering · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
