4.1.7 • Published 2 years ago
asr-answering v4.1.7
asr-answering
Utility Hooks for Earudite
Install
npm install --save asr-answering
Usage
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
3.0.0
2 years ago
4.1.7
2 years ago
4.1.4
2 years ago
4.1.3
2 years ago
4.1.6
2 years ago
4.1.5
2 years ago
4.1.0
2 years ago
4.0.1
2 years ago
4.0.0
2 years ago
4.1.2
2 years ago
4.0.3
2 years ago
4.0.2
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago