You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-guide/browser.md
+20-8
Original file line number
Diff line number
Diff line change
@@ -20,28 +20,36 @@ The VAD can be used via script tags as follows:
20
20
</script>
21
21
```
22
22
23
-
## Bundling
24
-
To use the VAD in a frontend project managed by a bundler like Webpack, install @ricky0123/vad-web with a command like
23
+
## NPM
24
+
25
+
If you are managing your dependencies with NPM, install @ricky0123/vad-web with a command like
25
26
```bash linenums="1"
26
27
npm i @ricky0123/vad-web
27
28
```
28
29
29
-
and use an import like:
30
+
## Bundling
31
+
32
+
Bundling your project should not require any special configuration, because the onnx and other files will be loaded from the CDN by default.
33
+
34
+
However, if you want to serve the onnx, wasm, and worklet files yourself, you can do the following. First, use the `baseAssetPath` and `onnxWASMBasePath` options to control where the files are to be loaded from:
35
+
30
36
```js linenums="1"
31
37
import { MicVAD } from"@ricky0123/vad-web"
32
38
constmyvad=awaitMicVAD.new({
39
+
baseAssetPath:"/", // or whatever you want
40
+
onnxWASMBasePath:"/", // or whatever you want
33
41
onSpeechEnd: (audio) => {
34
42
// do something with `audio` (Float32Array of audio samples at sample rate 16000)...
35
43
},
36
44
})
37
45
myvad.start()
38
46
```
39
47
40
-
You will also need to
48
+
Then, make sure these files are available under the paths you specified:
41
49
42
-
1. serve the `silero_vad.onnx`file that comes distributed with `@ricky0123/vad-web`
43
-
2. serve the `vad.worklet.bundle.min.js` file that comes distributed with `@ricky0123/vad-web`
44
-
3. serve the wasm files that come distributed with the package `onnxruntime-web`
50
+
1. serve the `silero_vad_legacy.onnx`and `silero_vad_v5.onnx` files that come distributed with `@ricky0123/vad-web` (under `baseAssetPath`)
51
+
2. serve the `vad.worklet.bundle.min.js` file that comes distributed with `@ricky0123/vad-web` (under `baseAssetPath`)
52
+
3. serve the wasm files that come distributed with the package `onnxruntime-web` (under `onnxWASMBasePath`)
45
53
46
54
One way to accomplish this is to run a shell script that copies these files into your `dist` directory (or whatever you have named your output directory) during your build process - see the [build script](https://github.com/ricky0123/vad-site/blob/master/scripts/build.sh) for this website for an example. Or, if you are using Webpack 5, this can be acheived by adding the following to your webpack.config.js (other bundlers may have similar options/plugins):
0 commit comments