Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
albho committed Jan 11, 2024
1 parent 7866de0 commit 0cd6ed9
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 27 deletions.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Falcon is an on-device speaker diarization engine. Falcon is:
- Cross-Platform:
- Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64)
- Raspberry Pi (4, 3) and NVIDIA Jetson Nano
- Chrome, Safari, Firefox, and Edge

## Table of Contents

Expand All @@ -28,9 +29,11 @@ Falcon is an on-device speaker diarization engine. Falcon is:
- [Demos](#demos)
- [Python Demos](#python-demos)
- [C Demos](#c-demos)
- [Web Demos](#web-demos)
- [SDKs](#sdks)
- [Python](#python)
- [C](#c)
- [Web](#web)
- [Releases](#releases)
- [FAQ](#faq)

Expand Down Expand Up @@ -85,6 +88,24 @@ Run the demo:
./demo/c/build/falcon_demo -a ${ACCESS_KEY} -l ${LIBRARY_PATH} -m ${MODEL_PATH} ${AUDIO_PATH}
```

### Web Demos

From [demo/web](demo/web) run the following in the terminal:

```console
yarn
yarn start
```

(or)

```console
npm install
npm run start
```

Open `http://localhost:5000` in your browser to try the demo.

## SDKs

### Python
Expand Down Expand Up @@ -160,6 +181,42 @@ Finally, when done be sure to release resources acquired:
pv_falcon_delete(falcon);
```

### Web

Install the web SDK using yarn:

```console
yarn add @picovoice/falcon-web
```

or using npm:

```console
npm install --save @picovoice/falcon-web
```

Create an instance of the engine using `FalconWorker` and diarize an audio file:

```typescript
import { Falcon } from "@picovoice/falcon-web";
import falconParams from "${PATH_TO_BASE64_FALCON_PARAMS}";

function getAudioData(): Int16Array {
// ... function to get audio data
return new Int16Array();
}

const falcon = await FalconWorker.create(
"${ACCESS_KEY}",
{ base64: falconParams }
);

const { segments } = await falcon.process(getAudioData());
console.log(segments);
```

Replace `${ACCESS_KEY}` with yours obtained from [Picovoice Console](https://console.picovoice.ai/). Finally, when done release the resources using `falcon.release()`.

## Releases

### v1.0.0 — November 28th, 2023
Expand Down
6 changes: 4 additions & 2 deletions binding/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ Falcon is an on-device speaker diarization engine. Falcon is:
- Cross-Platform:
- Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64)
- Raspberry Pi (4, 3) and NVIDIA Jetson Nano
- Chrome, Safari, Firefox, and Edge

## Compatibility

- Python 3.7+
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), Raspberry Pi (4, 3), and NVIDIA Jetson Nano.
- Chrome / Edge
- Firefox
- Safari

### Restrictions

Expand Down
2 changes: 1 addition & 1 deletion binding/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"test-perf": "cypress run --spec test/falcon_perf.test.ts"
},
"dependencies": {
"@picovoice/web-utils": "=1.3.1"
"@picovoice/web-utils": "=1.3.2"
},
"devDependencies": {
"@babel/core": "^7.21.3",
Expand Down
8 changes: 4 additions & 4 deletions binding/web/src/falcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ export class Falcon {
const segments: FalconSegment[] = [];
for (let i = 0; i < numSegments; i++) {
const startSec = memoryBufferView.getFloat32(ptr, true);
ptr += Uint32Array.BYTES_PER_ELEMENT;
ptr += Float32Array.BYTES_PER_ELEMENT;
const endSec = memoryBufferView.getFloat32(ptr, true);
ptr += Uint32Array.BYTES_PER_ELEMENT;
ptr += Float32Array.BYTES_PER_ELEMENT;
const speakerTag = memoryBufferView.getInt32(ptr, true);
ptr += Uint32Array.BYTES_PER_ELEMENT;
ptr += Int32Array.BYTES_PER_ELEMENT;
segments.push({ startSec, endSec, speakerTag });
}

Expand Down Expand Up @@ -350,7 +350,7 @@ export class Falcon {
modelPath: string
): Promise<any> {
// A WebAssembly page has a constant size of 64KiB. -> 1MiB ~= 16 pages
const memory = new WebAssembly.Memory({ initial: 11500 });
const memory = new WebAssembly.Memory({ initial: 130 });

const memoryBufferUint8 = new Uint8Array(memory.buffer);

Expand Down
21 changes: 13 additions & 8 deletions binding/web/test/falcon_perf.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { Falcon, FalconWorker } from '../';

const ACCESS_KEY = Cypress.env('ACCESS_KEY');
const NUM_TEST_ITERATIONS = Number(Cypress.env('NUM_TEST_ITERATIONS'));
const INIT_PERFORMANCE_THRESHOLD_SEC = Number(
Cypress.env('INIT_PERFORMANCE_THRESHOLD_SEC')
);
const PROC_PERFORMANCE_THRESHOLD_SEC = Number(
Cypress.env('PROC_PERFORMANCE_THRESHOLD_SEC')
);
// const ACCESS_KEY = Cypress.env('ACCESS_KEY');
// const NUM_TEST_ITERATIONS = Number(Cypress.env('NUM_TEST_ITERATIONS'));
// const INIT_PERFORMANCE_THRESHOLD_SEC = Number(
// Cypress.env('INIT_PERFORMANCE_THRESHOLD_SEC')
// );
// const PROC_PERFORMANCE_THRESHOLD_SEC = Number(
// Cypress.env('PROC_PERFORMANCE_THRESHOLD_SEC')
// );

const ACCESS_KEY = 'mW3jTf9S6NUBzDHDpN/lNLNE9k8wk2ERjIKPGeX3tM62LzxFbdFtIQ==';
const NUM_TEST_ITERATIONS = 15;
const INIT_PERFORMANCE_THRESHOLD_SEC = 4.5;
const PROC_PERFORMANCE_THRESHOLD_SEC = 0.3;

async function testPerformance(
instance: typeof Falcon | typeof FalconWorker,
Expand Down
20 changes: 10 additions & 10 deletions binding/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1108,12 +1108,12 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@picovoice/web-utils@=1.3.1":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@picovoice/web-utils/-/web-utils-1.3.1.tgz#d417e98604a650b54a8e03669015ecf98c2383ec"
integrity sha512-jcDqdULtTm+yJrnHDjg64hARup+Z4wNkYuXHNx6EM8+qZkweBq9UA6XJrHAlUkPnlkso4JWjaIKhz3x8vZcd3g==
"@picovoice/web-utils@=1.3.2":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@picovoice/web-utils/-/web-utils-1.3.2.tgz#9fe0a798a1f016fa8d8c28e48537466aa2854ca3"
integrity sha512-jDZn+kxVUyzM84kGVmq9hU6N60K2VH3sDevpZSw4CNDx3ppSz9Biz7aPHs+i16ssYJCxJweiJ44XhI+5Lo5ZjQ==
dependencies:
commander "^9.2.0"
commander "^10.0.1"

"@rollup/plugin-babel@^6.0.3":
version "6.0.4"
Expand Down Expand Up @@ -1687,6 +1687,11 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"

commander@^10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06"
integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==

commander@^2.20.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
Expand All @@ -1697,11 +1702,6 @@ commander@^6.2.1:
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==

commander@^9.2.0:
version "9.5.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30"
integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==

common-tags@^1.8.0:
version "1.8.2"
resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.8.2.tgz#94ebb3c076d26032745fd54face7f688ef5ac9c6"
Expand Down
2 changes: 1 addition & 1 deletion demo/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Falcon",
"browser",
"voice ai",
"speech recognition"
"speaker diarization"
],
"author": "Picovoice Inc",
"license": "Apache-2.0",
Expand Down
14 changes: 13 additions & 1 deletion demo/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@picovoice/falcon-web@file:../../binding/web":
version "1.0.0"
dependencies:
"@picovoice/web-utils" "=1.3.1"
"@picovoice/web-utils" "=1.3.2"

"@picovoice/web-utils@=1.3.1":
version "1.3.1"
Expand All @@ -14,6 +14,13 @@
dependencies:
commander "^9.2.0"

"@picovoice/web-utils@=1.3.2":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@picovoice/web-utils/-/web-utils-1.3.2.tgz#9fe0a798a1f016fa8d8c28e48537466aa2854ca3"
integrity sha512-jDZn+kxVUyzM84kGVmq9hU6N60K2VH3sDevpZSw4CNDx3ppSz9Biz7aPHs+i16ssYJCxJweiJ44XhI+5Lo5ZjQ==
dependencies:
commander "^10.0.1"

"@picovoice/web-voice-processor@~4.0.8":
version "4.0.8"
resolved "https://registry.yarnpkg.com/@picovoice/web-voice-processor/-/web-voice-processor-4.0.8.tgz#95247a5393cac4d16490a53feb0f413c902ee5fa"
Expand Down Expand Up @@ -71,6 +78,11 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

commander@^10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06"
integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==

commander@^9.2.0:
version "9.5.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30"
Expand Down

0 comments on commit 0cd6ed9

Please sign in to comment.