Skip to content

Commit f2d09ce

Browse files
committed
update documentation
1 parent 4cfb831 commit f2d09ce

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

docs/user-guide/browser.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,36 @@ The VAD can be used via script tags as follows:
2020
</script>
2121
```
2222

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
2526
```bash linenums="1"
2627
npm i @ricky0123/vad-web
2728
```
2829

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+
3036
```js linenums="1"
3137
import { MicVAD } from "@ricky0123/vad-web"
3238
const myvad = await MicVAD.new({
39+
baseAssetPath: "/", // or whatever you want
40+
onnxWASMBasePath: "/", // or whatever you want
3341
onSpeechEnd: (audio) => {
3442
// do something with `audio` (Float32Array of audio samples at sample rate 16000)...
3543
},
3644
})
3745
myvad.start()
3846
```
3947

40-
You will also need to
48+
Then, make sure these files are available under the paths you specified:
4149

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`)
4553

4654
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):
4755
```js linenums="1"
@@ -82,7 +90,11 @@ export default defineConfig({
8290
dest: './'
8391
},
8492
{
85-
src: 'node_modules/@ricky0123/vad-web/dist/silero_vad.onnx',
93+
src: 'node_modules/@ricky0123/vad-web/dist/silero_vad_v5.onnx',
94+
dest: './'
95+
},
96+
{
97+
src: 'node_modules/@ricky0123/vad-web/dist/silero_vad_legacy.onnx',
8698
dest: './'
8799
},
88100
{

0 commit comments

Comments
 (0)