Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0 node #690

Merged
merged 17 commits into from
Oct 25, 2023
3 changes: 0 additions & 3 deletions .github/workflows/nodejs-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
with:
node-version: lts/*

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

- name: Run Binding Linter
run: yarn && yarn lint
working-directory: sdk/nodejs
28 changes: 25 additions & 3 deletions .github/workflows/nodejs-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x]
include:
- os: ubuntu-latest
platform: linux
Expand All @@ -46,8 +46,17 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn
- name: Local Porcupine dependency
run: yarn && yarn build
working-directory: resources/porcupine/binding/nodejs

- name: Local Rhino dependency
run: yarn && yarn build
working-directory: resources/rhino/binding/nodejs

- name: Local dependency
run: yarn && yarn build
working-directory: sdk/nodejs

- name: Install dependencies
run: yarn install
Expand All @@ -63,6 +72,7 @@ jobs:
runs-on: ${{ matrix.machine }}

strategy:
fail-fast: false
matrix:
machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, jetson, beaglebone]
include:
Expand All @@ -89,6 +99,18 @@ jobs:
- name: Pre-build dependencies
run: npm install --global yarn

- name: Local Porcupine dependency
run: yarn && yarn build && rm -rf node_modules
working-directory: resources/porcupine/binding/nodejs

- name: Local Rhino dependency
run: yarn && yarn build && rm -rf node_modules
working-directory: resources/rhino/binding/nodejs

- name: Local dependency
run: yarn && yarn build && rm -rf node_modules
working-directory: sdk/nodejs

- name: Install dependencies
run: yarn install

Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -54,19 +54,17 @@ jobs:
run: yarn && yarn build
working-directory: resources/rhino/binding/nodejs

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

- name: Install dependencies
run: yarn install

- name: Test
run: yarn test --access_key=${{secrets.PV_VALID_ACCESS_KEY}}
run: yarn test --access_key=${{secrets.PV_VALID_ACCESS_KEY}}

build-self-hosted:
runs-on: ${{ matrix.machine }}

strategy:
fail-fast: false
matrix:
machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, jetson, beaglebone]

Expand All @@ -76,16 +74,13 @@ jobs:
submodules: recursive

- name: Local Porcupine dependency
run: yarn && yarn build
run: yarn && yarn build && rm -rf node_modules
working-directory: resources/porcupine/binding/nodejs

- name: Local Rhino dependency
run: yarn && yarn build
run: yarn && yarn build && rm -rf node_modules
working-directory: resources/rhino/binding/nodejs

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

- name: Install dependencies
run: yarn install

Expand Down
6 changes: 3 additions & 3 deletions demo/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@picovoice/picovoice-node-demo",
"version": "2.2.2",
"version": "3.0.0",
"description": "Picovoice SDK for NodeJS file-based and microphone demos",
"scripts": {
"file": "node file.js",
Expand All @@ -16,7 +16,7 @@
"author": "Picovoice Inc.",
"license": "Apache-2.0",
"dependencies": {
"@picovoice/picovoice-node": "2.2.1",
"@picovoice/picovoice-node": "file:../../sdk/nodejs",
"@picovoice/pvrecorder-node": "1.2.1",
"commander": "^6.1.0",
"wavefile": "^11.0.0"
Expand All @@ -29,7 +29,7 @@
"directory": "demo/nodejs"
},
"engines": {
"node": ">=12.0.0"
"node": ">=16.0.0"
},
"cpu": [
"!ia32",
Expand Down
22 changes: 8 additions & 14 deletions demo/nodejs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,22 @@
# yarn lockfile v1


"@picovoice/[email protected]":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@picovoice/picovoice-node/-/picovoice-node-2.2.1.tgz#62052b18ae276d3fa9467239221182d1755e4165"
integrity sha512-Ml9tFlJGrep4Dqvk07Nu3JCpCWkJSRmE/bKbO2c1meWRltOwqP//W78R/QiC30zv763nWGKGPwXh95Lvm7YYkA==
"@picovoice/picovoice-node@file:../../sdk/nodejs":
version "3.0.0"
dependencies:
"@picovoice/porcupine-node" "=2.2.1"
"@picovoice/rhino-node" "=2.2.1"
"@picovoice/porcupine-node" "file:../../../../../.cache/yarn/v6/npm-@picovoice-picovoice-node-3.0.0-5840f3c4-e246-4354-b070-bc9a5847b11d-1697586335625/node_modules/resources/porcupine/binding/nodejs"
"@picovoice/rhino-node" "file:../../../../../.cache/yarn/v6/npm-@picovoice-picovoice-node-3.0.0-5840f3c4-e246-4354-b070-bc9a5847b11d-1697586335625/node_modules/resources/rhino/binding/nodejs"

"@picovoice/porcupine-node@=2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@picovoice/porcupine-node/-/porcupine-node-2.2.1.tgz#5055d87c0b7e3039c8835fceb972dde4ea2c27ae"
integrity sha512-+sc3uY2ZdZabUW7kYZ2wDezg2CZYy729Xy387fMuNw8fa2aoHuU9pcpaUR2KfLDRC+s2hbWdAqnxjCuSvt/NYw==
"@picovoice/porcupine-node@file:../../resources/porcupine/binding/nodejs":
version "3.0.0"

"@picovoice/[email protected]":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@picovoice/pvrecorder-node/-/pvrecorder-node-1.2.1.tgz#8e112ecc7a4836aa4fa92d62ac7942d8a2366db8"
integrity sha512-7TtRMh04PSVn542Oq1v/MGLFuNPdUrrv+f7qbCGOWRc8y6ox+FATigdQqLRbRey4kZWf40dNHQFdVPCk5ZcXnQ==

"@picovoice/rhino-node@=2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@picovoice/rhino-node/-/rhino-node-2.2.1.tgz#83c420736d54314c7a842845096873be8c65fb0e"
integrity sha512-Alh3FrfWxzu4k2rrkls1YZGZVuKHfXiRtXJXh5IBDosvSgBFKYQ/eCclTw/reSr03Cl7BmZaBmISmGIoU1Hwqg==
"@picovoice/rhino-node@file:../../resources/rhino/binding/nodejs":
version "3.0.0"

commander@^6.1.0:
version "6.2.1"
Expand Down
10 changes: 4 additions & 6 deletions sdk/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@picovoice/picovoice-node",
"version": "2.2.1",
"version": "3.0.0",
"description": "Picovoice SDK for NodeJS",
"main": "dist/index.js",
"types": "dist/index.d.js",
Expand Down Expand Up @@ -39,8 +39,8 @@
"lint": "eslint . --ext .js,.ts"
},
"dependencies": {
"@picovoice/porcupine-node": "=2.2.1",
"@picovoice/rhino-node": "=2.2.1"
"@picovoice/porcupine-node": "file:../../resources/porcupine/binding/nodejs",
"@picovoice/rhino-node": "file:../../resources/rhino/binding/nodejs"
},
"devDependencies": {
"@types/jest": "^27.4.1",
Expand All @@ -50,16 +50,14 @@
"eslint": "^8.13.0",
"eslint-plugin-jest": "^27.1.6",
"jest": "^27.5.1",
"mkdirp": "^1.0.4",
"ncp": "^2.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"ts-jest": "^27.1.3",
"typescript": "^4.6.2",
"wavefile": "^11.0.0"
},
"engines": {
"node": ">=12.0.0"
"node": ">=16.0.0"
},
"cpu": [
"!ia32",
Expand Down
16 changes: 8 additions & 8 deletions sdk/nodejs/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import PvStatus from './pv_status_t';
export class PicovoiceError extends Error {}

export class PicovoiceOutOfMemoryError extends PicovoiceError {}
export class PicovoiceIoError extends PicovoiceError {}
export class PicovoiceIOError extends PicovoiceError {}
export class PicovoiceInvalidArgumentError extends PicovoiceError {}
export class PicovoiceStopIterationError extends PicovoiceError {}
export class PicovoiceKeyError extends PicovoiceError {}
export class PicovoiceInvalidStateError extends PicovoiceError {}
export class PicovoiceRuntimeError extends PicovoiceError {}
export class PicovoiceActivationError extends PicovoiceError {}
export class PicovoiceActivationLimitReached extends PicovoiceError {}
export class PicovoiceActivationThrottled extends PicovoiceError {}
export class PicovoiceActivationRefused extends PicovoiceError {}
export class PicovoiceActivationLimitReachedError extends PicovoiceError {}
export class PicovoiceActivationThrottledError extends PicovoiceError {}
export class PicovoiceActivationRefusedError extends PicovoiceError {}

export function pvStatusToException(
pvStatus: PvStatus,
Expand All @@ -34,7 +34,7 @@ export function pvStatusToException(
case PvStatus.OUT_OF_MEMORY:
throw new PicovoiceOutOfMemoryError(errorMessage);
case PvStatus.IO_ERROR:
throw new PicovoiceIoError(errorMessage);
throw new PicovoiceIOError(errorMessage);
case PvStatus.INVALID_ARGUMENT:
throw new PicovoiceInvalidArgumentError(errorMessage);
case PvStatus.STOP_ITERATION:
Expand All @@ -48,11 +48,11 @@ export function pvStatusToException(
case PvStatus.ACTIVATION_ERROR:
throw new PicovoiceActivationError(errorMessage);
case PvStatus.ACTIVATION_LIMIT_REACHED:
throw new PicovoiceActivationLimitReached(errorMessage);
throw new PicovoiceActivationLimitReachedError(errorMessage);
case PvStatus.ACTIVATION_THROTTLED:
throw new PicovoiceActivationThrottled(errorMessage);
throw new PicovoiceActivationThrottledError(errorMessage);
case PvStatus.ACTIVATION_REFUSED:
throw new PicovoiceActivationRefused(errorMessage);
throw new PicovoiceActivationRefusedError(errorMessage);
default:
// eslint-disable-next-line no-console
console.warn(`Unmapped error code: ${pvStatus}`);
Expand Down
5 changes: 3 additions & 2 deletions sdk/nodejs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2020-2022 Picovoice Inc.
// Copyright 2020-2023 Picovoice Inc.
//
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
// file accompanying this source.
Expand All @@ -12,5 +12,6 @@

import Picovoice from './picovoice';
import { getInt16Frames, checkWaveFile } from './wave_util';
import * as PicovoiceErrors from './errors';

export { Picovoice, getInt16Frames, checkWaveFile };
export { Picovoice, getInt16Frames, checkWaveFile, PicovoiceErrors };
Loading