ricky0123 / vad

Voice activity detector (VAD) for the browser with a simple API
https://www.vad.ricky0123.com
Other
901 stars 143 forks source link

I face a problem to run this in my project. #132

Open piyuxx opened 3 months ago

piyuxx commented 3 months ago

I used react, gatsby, typescript and this is the way i implemented \ import { useMicVAD } from "@ricky0123/vad-react"; const a= useMicVAD({ startOnLoad: true, stream, onSpeechStart, onSpeechEnd, positiveSpeechThreshold: 0.6, negativeSpeechThreshold: 0.6 - 0.15, }); and when i log a.userSpeaking it's always false .and here's log { "listening": false, "errored": { "message": "The user aborted a request." }, "loading": false, "userSpeaking": false }

JunJD commented 3 months ago

我也遇到了同样的问题

joooonis commented 2 months ago

use useState instead

const [isSpeaking, setIsSpeaking] = useState(false);
const { loading } = useMicVAD({
  onSpeechStart: () => {
    // do something when speech start
    setIsSpeaking(true);
  },
  onSpeechEnd: audio => {
    // do something when speech start
    setIsSpeaking(false);
  },
});