Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/web-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ jobs:
with:
node-version: lts/*

- name: Pre-build dependencies
run: npm install yarn

- name: Run Binding Linter
run: yarn && yarn lint
working-directory: binding/web
9 changes: 6 additions & 3 deletions .github/workflows/web-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

strategy:
matrix:
node-version: [ 18.x, 20.x, 22.x ]
node-version: [ 18.x, 20.x, 22.x, 24.x ]

steps:
- uses: actions/checkout@v3
Expand All @@ -35,8 +35,11 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn
# ************** REMOVE AFTER RELEASE ********************
- name: Build Web SDK
run: yarn && yarn copywasm && yarn build
working-directory: binding/web
# ********************************************************

- name: Install dependencies
run: yarn install
6 changes: 2 additions & 4 deletions .github/workflows/web-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
strategy:
matrix:
node-version: [ lts/* ]
device: [ cpu:1 ]
include:
- node-version: lts/*
num_test_iterations: 10
Expand All @@ -39,9 +40,6 @@ jobs:
with:
node-version: lts/*

- name: Pre-build dependencies
run: npm install yarn

- name: Install dependencies
run: yarn install

Expand All @@ -55,4 +53,4 @@ jobs:
run: yarn setup-test

- name: Test
run: yarn test-perf --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},NUM_TEST_ITERATIONS=${{matrix.num_test_iterations}},PROC_PERFORMANCE_THRESHOLD_SEC=${{matrix.proc_performance_threshold_sec}}
run: yarn test-perf --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},DEVICE=${{matrix.device}},NUM_TEST_ITERATIONS=${{matrix.num_test_iterations}},PROC_PERFORMANCE_THRESHOLD_SEC=${{matrix.proc_performance_threshold_sec}}
8 changes: 3 additions & 5 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:

strategy:
matrix:
node-version: [ 18.x, 20.x, 22.x ]
device: [ cpu, cpu:1 ]
node-version: [ 18.x, 20.x, 22.x, 24.x ]

steps:
- uses: actions/checkout@v3
Expand All @@ -39,9 +40,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn

- name: Install dependencies
run: yarn install

Expand All @@ -55,4 +53,4 @@ jobs:
run: yarn setup-test

- name: Test
run: yarn test --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}}
run: yarn test --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}},DEVICE=${{matrix.device}}
19 changes: 19 additions & 0 deletions binding/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,30 @@ voice assistants. Orca is:
- Firefox
- Safari

## Requirements

Orca Web Binding uses [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer)
for processing speaker diarization.

Include the following headers in the response to enable the use of `SharedArrayBuffers`:

```
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
```

Refer to our [Web demo](../../demo/web) for an example on creating a server with the corresponding response headers.

Browsers that lack support for `SharedArrayBuffers` or required headers will fall back to using standard `ArrayBuffers`,
which disables multithreaded performance.

### Restrictions

IndexedDB is required to use `Orca` in a worker thread. Browsers without IndexedDB support
(i.e. Firefox Incognito Mode) should use `Orca` in the main thread.

Multi-threading is only enabled for `Orca` when using on a web worker.

## Installation

### Package
Expand Down
8 changes: 8 additions & 0 deletions binding/web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ export default defineConfig({
video: false,
screenshotOnRunFailure: false,
},
setupNodeEvents(on) {
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push('--enable-features=SharedArrayBuffer');
}
return launchOptions;
});
},
});
6 changes: 3 additions & 3 deletions binding/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Orca Text-to-Speech engine for web browsers (via WebAssembly)",
"author": "Picovoice Inc",
"license": "Apache-2.0",
"version": "1.2.1",
"version": "2.0.0",
"keywords": [
"orca",
"web",
Expand All @@ -29,8 +29,8 @@
"format": "prettier --write \"**/*.{js,ts,json}\"",
"copywasm": "node scripts/copy_wasm.js",
"setup-test": "node scripts/setup_test.js && npx pvbase64 -i ./test/orca_params_en_male.pv -o ./test/orca_params_en_male.js && npx pvbase64 -i ./test/orca_params_en_female.pv -o ./test/orca_params_en_female.js",
"test": "cypress run --spec test/orca.test.ts",
"test-perf": "cypress run --spec test/orca_perf.test.ts"
"test": "cypress run --spec test/orca.test.ts --browser chrome",
"test-perf": "cypress run --spec test/orca_perf.test.ts --browser chrome"
},
"dependencies": {
"@picovoice/web-utils": "=1.4.3"
Expand Down
2 changes: 1 addition & 1 deletion binding/web/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
exclude: '**/node_modules/**',
}),
base64({
include: ['./**/*.wasm', './**/*.txt'],
include: ['./src/lib/*.wasm', './src/lib/*.txt'],
})
],
};
4 changes: 2 additions & 2 deletions binding/web/scripts/copy_wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const fs = require("fs");
const { join, extname } = require("path");

const wasmFiles = [
"pv_orca.wasm",
"pv_orca.js",
"pv_orca_simd.wasm",
"pv_orca_simd.js",
"pv_orca_pthread.wasm",
"pv_orca_pthread.js",
]

console.log("Copying the WASM model...");
Expand Down
14 changes: 8 additions & 6 deletions binding/web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Orca, OrcaStream } from './orca';
import { OrcaWorker, OrcaStreamWorker } from './orca_worker';

import {
OrcaOptions,
OrcaModel,
OrcaSynthesizeParams,
OrcaPhoneme,
Expand All @@ -20,24 +21,25 @@ import {

import * as OrcaErrors from './orca_errors';

import orcaWasm from './lib/pv_orca.wasm';
import orcaWasmLib from './lib/pv_orca.txt';
import orcaWasmSimd from './lib/pv_orca_simd.wasm';
import orcaWasmSimdLib from './lib/pv_orca_simd.txt';
import orcaWasmPThread from './lib/pv_orca_pthread.wasm';
import orcaWasmPThreadLib from './lib/pv_orca_pthread.txt';

Orca.setWasm(orcaWasm);
Orca.setWasmLib(orcaWasmLib);
Orca.setWasmSimd(orcaWasmSimd);
Orca.setWasmSimdLib(orcaWasmSimdLib);
OrcaWorker.setWasm(orcaWasm);
OrcaWorker.setWasmLib(orcaWasmLib);
Orca.setWasmPThread(orcaWasmPThread);
Orca.setWasmPThreadLib(orcaWasmPThreadLib);
OrcaWorker.setWasmSimd(orcaWasmSimd);
OrcaWorker.setWasmSimdLib(orcaWasmSimdLib);
OrcaWorker.setWasmPThread(orcaWasmPThread);
OrcaWorker.setWasmPThreadLib(orcaWasmPThreadLib);

export {
Orca,
OrcaStream,
OrcaErrors,
OrcaOptions,
OrcaModel,
OrcaSynthesizeParams,
OrcaPhoneme,
Expand Down
Loading