-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AudioWorklet issue with Vite. #9
Comments
Thanks for the kind words! I have used it in a react project with success so far by using You can try thisas a custom hook to get started export function useVAD(args: Partial<RealTimeVADOptions>) {
const [vadRunning, setVadRunning] = useState<boolean>(false)
const [vad, setVAD] = useState<MicVAD | null>(null)
const pauseVAD = () => {
vad?.pause()
setVadRunning(false)
}
const startVAD = () => {
vad?.start()
setVadRunning(true)
}
useEffect(() => {
;(async () => {
const myvad = await MicVAD.new(args)
setVAD(myvad)
myvad.start()
setVadRunning(true)
})()
return function cleanUp() {
pauseVAD()
}
}, [])
return {
vadRunning,
pauseVAD,
startVAD,
}
} I definitely won't guarantee it's bug free, but it has been working so far for me. |
To clarify about serving the onnx/wasm/worklet files, basically you have to
I'm not familiar with vite, but maybe there are analogous plugins to the ones I use in the webpack config snippet in the README. |
Gonna close this for now. Let me know if you have any further issues. FYI here's now a package |
Adding some info for others that come across this thread. Use the plugin mentioned above with config like this: vite.config.ts:
|
This should be added as suggestion in the documentation, that would be very helpful... |
It's very useful, thank you! |
@ricky0123 Users can manually copy files such as models to DevServer and specify the path. The experience is good. |
I have added it to the document and made some adjustments: |
Hi @xiaoqiang1999 I had not considered that, but yeah, it might not be a bad idea. This seems to be the single biggest source of frustration for users. Thanks for the suggestion! |
Hi @ricky0123 vite.config.ts:
|
Hi @Louise-Huang can you look in browser devtools in the network tab and see where the site is trying to get these files? |
Hi @ricky0123 I added all the comments mentioned in issue #128 that should be added, and it works for me! |
This is a really cool project. Massive respect.
I'm trying to add this to a Vite/React project but I'm getting a
DOMException: The user aborted a request.
Error whenever I run the code. Any help or advice would be massively appreciated. I think it's something to do with the audio worklet in real-time-vad.ts but don't know enough about this to diagnose.
The text was updated successfully, but these errors were encountered: