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: README.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,11 @@
7
7
8
8
This package aims to provide an accurate, user-friendly voice activity detector (VAD) that runs in the browser. By using this package, you can prompt the user for microphone permissions, start recording audio, send segments of audio with speech to your server for processing, or show a certain animation or indicator when the user is speaking. Note that I have decided [discontinue node support](#important-update-about-node-support---oct-2024) in order to focus on the browser use case.
9
9
10
-
* See a live [demo](https://www.vad.ricky0123.com)
11
-
* Join us on [Discord](https://discord.gg/4WPeGEaSpF)!
12
-
* Browse the [documentation](https://docs.vad.ricky0123.com/), the source code of which is located in the ./docs directory
13
-
* If you would like to contribute, I have started writing some documentation on how to get started hacking on these packages [here](https://docs.vad.ricky0123.com/developer-guide/hacking/). If you have any questions, you can open an issue here or leave a message on Discord.
14
-
* Please fill out this [survey](https://uaux2a2ppfv.typeform.com/to/iJG2gCQv) to let me know what you are building with these packages and how you are using them!
10
+
- See a live [demo](https://www.vad.ricky0123.com)
11
+
- Join us on [Discord](https://discord.gg/4WPeGEaSpF)!
12
+
- Browse the [documentation](https://docs.vad.ricky0123.com/), the source code of which is located in the ./docs directory
13
+
- If you would like to contribute, I have started writing some documentation on how to get started hacking on these packages [here](https://docs.vad.ricky0123.com/developer-guide/hacking/). If you have any questions, you can open an issue here or leave a message on Discord.
14
+
- Please fill out this [survey](https://uaux2a2ppfv.typeform.com/to/iJG2gCQv) to let me know what you are building with these packages and how you are using them!
15
15
16
16
Under the hood, these packages run [Silero VAD](https://github.com/snakers4/silero-vad)[[1]](#1) using [ONNX Runtime Web](https://github.com/microsoft/onnxruntime/tree/main/js/web) / [ONNX Runtime Node.js](https://github.com/microsoft/onnxruntime/tree/main/js/node). Thanks a lot to those folks for making this possible.
17
17
@@ -33,8 +33,8 @@ I am going to wind down support for `ricky0123/vad-node`, the voice activity det
33
33
To use the VAD via a script tag in the browser, include the following script tags:
@@ -25,6 +29,7 @@ The VAD can be used via script tags as follows:
25
29
## NPM
26
30
27
31
If you are managing your dependencies with NPM, install @ricky0123/vad-web with a command like
32
+
28
33
```bash linenums="1"
29
34
npm i @ricky0123/vad-web
30
35
```
@@ -55,6 +60,7 @@ Then, make sure these files are available under the paths you specified:
55
60
4.**Important for newer versions of onnxruntime-web**: Also serve the `.mjs` files that come distributed with `onnxruntime-web` (under `onnxWASMBasePath`). These JavaScript bindings are required for proper initialization of the WebAssembly modules.
56
61
57
62
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):
63
+
58
64
```js linenums="1"
59
65
constCopyPlugin=require("copy-webpack-plugin")
60
66
@@ -84,33 +90,35 @@ module.exports = {
84
90
Note that you will need to install `copy-webpack-plugin` in order for the webpack config snippet above to work (`npm i -D copy-webpack-plugin` if using npm).
85
91
86
92
### If you use Vite, refer to the following configuration:
@@ -124,10 +132,10 @@ The "desc" path can be adjusted by itself, but you need to configure the modelUR
124
132
125
133
There are a number of files that the VAD loads from the browser when it is invoked - the worklet file, the onnx (model weights/architecture) file, and various files that onnxruntime needs. As the configuration associated with serving these files correctly has made it difficult for some people to get started with using the package, I decided to try a new approach to this.
126
134
127
-
There are now exactly two configuration parameters that control where VAD looks for these files.
135
+
There are now exactly two configuration parameters that control where VAD looks for these files.
128
136
129
-
*`baseAssetPath` - the base path under which VAD looks for the worklet file and onnx files. The worklet file name is `vad.worklet.bundle.min.js`. Therefore, if you have set `baseAssetPath` to `example.com`, it will try to load the worklet file from `example.com/vad.worklet.bundle.min.js`. Similarly, it uses this same base path to look for `silero_vad_legacy.onnx` or `silero_vad_v5.onnx`.
130
-
*`onnxWASMBasePath` - the base path under which VAD looks for wasm files needed for onnxruntime.
137
+
-`baseAssetPath` - the base path under which VAD looks for the worklet file and onnx files. The worklet file name is `vad.worklet.bundle.min.js`. Therefore, if you have set `baseAssetPath` to `example.com`, it will try to load the worklet file from `example.com/vad.worklet.bundle.min.js`. Similarly, it uses this same base path to look for `silero_vad_legacy.onnx` or `silero_vad_v5.onnx`.
138
+
-`onnxWASMBasePath` - the base path under which VAD looks for wasm files needed for onnxruntime.
131
139
132
140
By default, these are both set to the appropriate CDN paths. In other words, unless you have overridden these options, the worklet/onnx/wasm files will be loaded from a CDN. If you want to serve these files yourself, you have to specifiy those options yourself and make sure that you have made the files available at the correct location. Hopefully, this both makes it easy to get started with the package and also clears up any ambiguity about where the files are supposed to be.
0 commit comments