Skip to content

Commit 5a9ab70

Browse files
authored
bump version (#241)
1 parent 26ac722 commit 5a9ab70

File tree

8 files changed

+74
-48
lines changed

8 files changed

+74
-48
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
88
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.
99

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!
1515

1616
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.
1717

@@ -33,8 +33,8 @@ I am going to wind down support for `ricky0123/vad-node`, the voice activity det
3333
To use the VAD via a script tag in the browser, include the following script tags:
3434

3535
```html
36-
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/ort.js"></script>
37-
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.27/dist/bundle.min.js"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/ort.wasm.min.js"></script>
37+
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.29/dist/bundle.min.js"></script>
3838
<script>
3939
async function main() {
4040
const myvad = await vad.MicVAD.new({
@@ -44,8 +44,10 @@ To use the VAD via a script tag in the browser, include the following script tag
4444
onSpeechEnd: (audio) => {
4545
// do something with `audio` (Float32Array of audio samples at sample rate 16000)...
4646
},
47-
onnxWASMBasePath: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/",
48-
baseAssetPath: "https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.27/dist/",
47+
onnxWASMBasePath:
48+
"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/",
49+
baseAssetPath:
50+
"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.29/dist/",
4951
})
5052
myvad.start()
5153
}

docs/user-guide/browser.md

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
The `@ricky0123/vad-web` package aims to provide an accurate, user-friendly voice activity detector (VAD) that runs in the browser.
44

55
## Script tags quick start
6+
67
The VAD can be used via script tags as follows:
8+
79
```html linenums="1"
8-
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/ort.js"></script>
9-
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.27/dist/bundle.min.js"></script>
10+
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/ort.wasm.min.js"></script>
11+
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.29/dist/bundle.min.js"></script>
1012
<script>
1113
async function main() {
1214
const myvad = await vad.MicVAD.new({
1315
onSpeechEnd: (audio) => {
1416
// do something with `audio` (Float32Array of audio samples at sample rate 16000)...
1517
},
16-
onnxWASMBasePath: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/",
17-
baseAssetPath: "https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.27/dist/",
18+
onnxWASMBasePath:
19+
"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/",
20+
baseAssetPath:
21+
"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.29/dist/",
1822
})
1923
myvad.start()
2024
}
@@ -25,6 +29,7 @@ The VAD can be used via script tags as follows:
2529
## NPM
2630

2731
If you are managing your dependencies with NPM, install @ricky0123/vad-web with a command like
32+
2833
```bash linenums="1"
2934
npm i @ricky0123/vad-web
3035
```
@@ -55,6 +60,7 @@ Then, make sure these files are available under the paths you specified:
5560
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.
5661

5762
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+
5864
```js linenums="1"
5965
const CopyPlugin = require("copy-webpack-plugin")
6066

@@ -84,33 +90,35 @@ module.exports = {
8490
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).
8591

8692
### If you use Vite, refer to the following configuration:
93+
8794
```js linenums="1"
8895
export default defineConfig({
8996
plugins: [
9097
viteStaticCopy({
9198
targets: [
9299
{
93-
src: 'node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js',
94-
dest: './'
100+
src: "node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js",
101+
dest: "./",
95102
},
96103
{
97-
src: 'node_modules/@ricky0123/vad-web/dist/silero_vad_v5.onnx',
98-
dest: './'
104+
src: "node_modules/@ricky0123/vad-web/dist/silero_vad_v5.onnx",
105+
dest: "./",
99106
},
100107
{
101-
src: 'node_modules/@ricky0123/vad-web/dist/silero_vad_legacy.onnx',
102-
dest: './'
108+
src: "node_modules/@ricky0123/vad-web/dist/silero_vad_legacy.onnx",
109+
dest: "./",
103110
},
104111
{
105-
src: 'node_modules/onnxruntime-web/dist/*.wasm',
106-
dest: './'
112+
src: "node_modules/onnxruntime-web/dist/*.wasm",
113+
dest: "./",
107114
},
108115
{
109-
src: 'node_modules/onnxruntime-web/dist/*.mjs',
110-
dest: './'
111-
}
112-
]
113-
})],
116+
src: "node_modules/onnxruntime-web/dist/*.mjs",
117+
dest: "./",
118+
},
119+
],
120+
}),
121+
],
114122
})
115123
```
116124

@@ -124,10 +132,10 @@ The "desc" path can be adjusted by itself, but you need to configure the modelUR
124132

125133
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.
126134

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.
128136

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.
131139

132140
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.
133141

@@ -148,11 +156,11 @@ const myvad = await MicVAD.new({
148156
getStream: async () => {
149157
return await navigator.mediaDevices.getUserMedia({
150158
audio: {
151-
channelCount: 2, // Stereo instead of mono
152-
echoCancellation: false, // Disable echo cancellation
153-
autoGainControl: false, // Disable auto gain control
154-
noiseSuppression: false, // Disable noise suppression
155-
sampleRate: 48000, // Custom sample rate
159+
channelCount: 2, // Stereo instead of mono
160+
echoCancellation: false, // Disable echo cancellation
161+
autoGainControl: false, // Disable auto gain control
162+
noiseSuppression: false, // Disable noise suppression
163+
sampleRate: 48000, // Custom sample rate
156164
},
157165
})
158166
},
@@ -164,4 +172,5 @@ myvad.start()
164172
```
165173

166174
## API
175+
167176
`@ricky0123/vad-web` supports the [MicVAD](api.md#micvad) and [NonRealTimeVAD](api.md#nonrealtimevad) APIs.

examples/bundler/package-lock.json

Lines changed: 22 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/bundler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"author": "",
1313
"license": "ISC",
1414
"dependencies": {
15-
"@ricky0123/vad-web": "^0.0.27",
15+
"@ricky0123/vad-web": "^0.0.29",
1616
"d3-scale-chromatic": "^3.0.0",
1717
"onnxruntime-web": "^1.22.0"
1818
},

examples/script-tags/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"
1111
/>
1212
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/ort.js"></script>
13-
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.28/dist/bundle.min.js"></script>
13+
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.29/dist/bundle.min.js"></script>
1414
<script type="module">
1515
import { interpolateInferno } from "https://cdn.skypack.dev/d3-scale-chromatic@3"
1616

@@ -65,7 +65,7 @@
6565
document.body.style.setProperty("--indicator-color", indicatorColor)
6666
}
6767
}
68-
window.toggleVAD()
68+
// window.toggleVAD()
6969
document.getElementById("toggle_vad_button").disabled = false
7070
} catch (e) {
7171
console.error("Failed:", e)

packages/react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"react"
1414
],
1515
"homepage": "https://github.com/ricky0123/vad",
16-
"version": "0.0.34",
16+
"version": "0.0.35",
1717
"license": "ISC",
1818
"main": "dist/index.js",
1919
"devDependencies": {
2020
"@types/react": "18.0.28"
2121
},
2222
"dependencies": {
2323
"onnxruntime-web": "^1.17.0",
24-
"@ricky0123/vad-web": "0.0.28"
24+
"@ricky0123/vad-web": "0.0.29"
2525
},
2626
"peerDependencies": {
2727
"react": ">=16.8.0",

packages/web/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ scripts/
44
src/
55
test-site/
66
tests/
7+
test/
78
webpack.config.js
89
playwright.config.ts
910
tsconfig*

packages/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"offline-speech-recognition"
1313
],
1414
"homepage": "https://github.com/ricky0123/vad",
15-
"version": "0.0.28",
15+
"version": "0.0.29",
1616
"license": "ISC",
1717
"main": "dist/index.js",
1818
"unpkg": "dist/bundle.min.js",

0 commit comments

Comments
 (0)