Skip to content

Commit

Permalink
Added support for Windows ARM64 (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt200-ok authored Jan 16, 2025
1 parent 00f1e38 commit 3736ace
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ body:
- Web (WASM)
- Linux (x86_64)
- macOS (x86_64, arm64)
- Windows (x86_64)
- Windows (x86_64, arm64)
- Raspberry Pi
validations:
required: true
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/c-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ jobs:
strategy:
matrix:
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64]

make_file: ["Unix Makefiles"]
include:
- machine: pv-windows-arm64
make_file: "MinGW Makefiles"
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Create build directory
run: cmake -B ./build
run: cmake -G "${{ matrix.make_file }}" -B ./build

- name: Build micdemo
run: cmake --build ./build --target cobra_demo_mic
Expand Down Expand Up @@ -109,6 +112,7 @@ jobs:
strategy:
matrix:
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64]
make_file: ["Unix Makefiles"]
include:
- machine: rpi3-32
platform: raspberry-pi
Expand All @@ -125,14 +129,18 @@ jobs:
- machine: rpi5-64
platform: raspberry-pi
arch: cortex-a76-aarch64
- machine: pv-windows-arm64
platform: windows
arch: arm64
make_file: "MinGW Makefiles"

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Create build directory
run: cmake -B ./build
run: cmake -G "${{ matrix.make_file }}" -B ./build

- name: Build filedemo
run: cmake --build ./build --target cobra_demo_file
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

strategy:
matrix:
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64]
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64]

steps:
- uses: actions/checkout@v3
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/nodejs-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,26 @@ jobs:
- name: Machine state after
working-directory: res/scripts
run: bash machine-state.sh

perf-windows-arm64:
runs-on: ${{ matrix.machine }}

strategy:
fail-fast: false
matrix:
machine: [pv-windows-arm64]
include:
- machine: pv-windows-arm64
num_test_iterations: 50

steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: yarn install

- name: Test
run: yarn test perf.test.ts --access_key=${{secrets.PV_VALID_ACCESS_KEY}} --num_test_iterations=${{matrix.num_test_iterations}} --proc_performance_threshold_sec=0.005
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

strategy:
matrix:
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64]
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

strategy:
matrix:
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64]
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64]

steps:
- uses: actions/checkout@v3
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/python-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,27 @@ jobs:
- name: Machine state after
working-directory: res/scripts
run: bash machine-state.sh

perf-windows-arm64:
runs-on: ${{ matrix.machine }}

strategy:
fail-fast: false
matrix:
machine: [pv-windows-arm64]
include:
- machine: pv-windows-arm64
num_test_iterations: 100
performance_threshold_sec: 0.006

steps:
- uses: actions/checkout@v3

- name: Pre-build dependencies
run: python3 -m pip install --upgrade pip

- name: Install dependencies
run: pip3 install -r requirements.txt

- name: Test
run: python3 test_cobra_perf.py ${{secrets.PV_VALID_ACCESS_KEY}} ${{matrix.num_test_iterations}} ${{matrix.performance_threshold_sec}}
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
strategy:
fail-fast: false
matrix:
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64]
machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions binding/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Cobra is an on-device streaming voice activity detection engine. Cobra is:
- Private; All voice processing runs locally.
- Accurate [[1]](https://picovoice.ai/docs/benchmark/vad/#results)
- Cross-Platform:
- Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64)
- Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64, arm64)
- Android and iOS
- Chrome, Safari, Firefox, and Edge
- Raspberry Pi (3, 4, 5)

## Compatibility

- Node.js 16+
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5).
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5).

## Installation

Expand Down
2 changes: 1 addition & 1 deletion binding/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@picovoice/cobra-node",
"version": "2.0.2",
"version": "2.0.3",
"description": "Picovoice Cobra Node.js binding",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
Expand Down
10 changes: 7 additions & 3 deletions binding/nodejs/src/platforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ SYSTEM_TO_LIBRARY_PATH.set(
`${SYSTEM_WINDOWS}/${X86_64}`,
`${PLATFORM_WINDOWS}/amd64/pv_cobra.node`
);
SYSTEM_TO_LIBRARY_PATH.set(
`${SYSTEM_WINDOWS}/${ARM_64}`,
`${PLATFORM_WINDOWS}/arm64/pv_cobra.node`
);

function absoluteLibraryPath(libraryPath: string): string {
return path.resolve(__dirname, LIBRARY_PATH_PREFIX, libraryPath);
Expand Down Expand Up @@ -127,7 +131,7 @@ export function getPlatform(): string {
return PLATFORM_MAC;
}

if (system === SYSTEM_WINDOWS && arch === X86_64) {
if (system === SYSTEM_WINDOWS && (arch === X86_64 || arch === ARM_64)) {
return PLATFORM_WINDOWS;
}

Expand Down Expand Up @@ -175,9 +179,9 @@ export function getSystemLibraryPath(): string {
}
break;
case SYSTEM_WINDOWS:
if (arch === X86_64) {
if (arch === X86_64 || arch == ARM_64) {
return absoluteLibraryPath(
SYSTEM_TO_LIBRARY_PATH.get(`${SYSTEM_WINDOWS}/${X86_64}`)
SYSTEM_TO_LIBRARY_PATH.get(`${SYSTEM_WINDOWS}/${arch}`)
);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion binding/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Cobra is a highly accurate and lightweight voice activity detection (VAD) engine
## Compatibility

- Python 3.8+
- Runs on Linux (x86_64), macOS (x86_64), Windows (x86_64), and Raspberry Pi (3, 4, 5).
- Runs on Linux (x86_64), macOS (x86_64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5).

## Installation

Expand Down
5 changes: 4 additions & 1 deletion binding/python/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def pv_library_path(relative):
relative,
'lib/raspberry-pi/%s/libpv_cobra.so' % _PV_MACHINE)
elif _PV_SYSTEM == 'Windows':
return os.path.join(os.path.dirname(__file__), relative, 'lib/windows/amd64/libpv_cobra.dll')
if platform.machine().lower() == 'amd64':
return os.path.join(os.path.dirname(__file__), relative, 'lib/windows/amd64/libpv_cobra.dll')
elif platform.machine().lower() == 'arm64':
return os.path.join(os.path.dirname(__file__), relative, 'lib/windows/arm64/libpv_cobra.dll')

raise NotImplementedError('Unsupported platform.')
1 change: 0 additions & 1 deletion binding/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
numpy
3 changes: 2 additions & 1 deletion binding/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
include pvcobra/lib/mac/arm64/libpv_cobra.dylib
recursive-include pvcobra/lib/raspberry-pi *
include pvcobra/lib/windows/amd64/libpv_cobra.dll
include pvcobra/lib/windows/arm64/libpv_cobra.dll
"""

with open(os.path.join(os.path.dirname(__file__), 'MANIFEST.in'), 'w') as f:
Expand All @@ -55,7 +56,7 @@

setuptools.setup(
name="pvcobra",
version="2.0.3",
version="2.0.4",
author="Picovoice",
author_email="[email protected]",
description="Cobra voice activity detection (VAD) engine",
Expand Down
12 changes: 6 additions & 6 deletions binding/python/test_cobra.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

import sys
import unittest

import numpy as np
import math

from _cobra import Cobra, CobraError
from _util import *
Expand All @@ -33,15 +32,16 @@ def test_process(self):
self._cobra.sample_rate)

num_frames = len(audio) // self._cobra.frame_length
probs = np.zeros(num_frames, dtype=float)
probs = [0.0] * num_frames
for i in range(num_frames):
frame = audio[i * self._cobra.frame_length:(i + 1) * self._cobra.frame_length]
probs[i] = self._cobra.process(frame)

labels = np.zeros(num_frames, dtype=int)
labels[10:28] = 1
labels = [0] * num_frames
labels[10:28] = [1] * 18

loss = -np.sum(labels * np.log(probs) + (1 - labels) * np.log(1 - probs)) / num_frames
loss = sum([label * math.log(prob) + (1 - label) * math.log(1 - prob)
for label, prob in zip(labels, probs)]) / num_frames
self.assertLess(loss, 0.1)

def test_version(self):
Expand Down
4 changes: 2 additions & 2 deletions demo/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Cobra is an on-device voice activity detection engine. Cobra is:
- Private; All voice processing runs locally.
- Accurate [[1]](https://picovoice.ai/docs/benchmark/vad/#results)
- Cross-Platform:
- Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64)
- Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64, arm64)
- Android and iOS
- Chrome, Safari, Firefox, and Edge
- Raspberry Pi (3, 4, 5)

## Compatibility

- Node.js 16+
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5).
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5).

## Installation

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/cobra-node-demo",
"version": "2.0.2",
"version": "2.0.3",
"description": "Picovoice Cobra Node.js file-based and microphone demos",
"scripts": {
"file": "node file.js",
Expand All @@ -16,8 +16,8 @@
"author": "Picovoice Inc.",
"license": "Apache-2.0",
"dependencies": {
"@picovoice/cobra-node": "=2.0.2",
"@picovoice/pvrecorder-node": "~1.2.3",
"@picovoice/cobra-node": "=2.0.3",
"@picovoice/pvrecorder-node": "~1.2.5",
"commander": "^6.1.0",
"readline": "^1.3.0",
"wavefile": "^11.0.0"
Expand Down
16 changes: 8 additions & 8 deletions demo/nodejs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# yarn lockfile v1


"@picovoice/cobra-node@=2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@picovoice/cobra-node/-/cobra-node-2.0.2.tgz#a6322984eaf7557d649686c670a9f774af6650da"
integrity sha512-KSE1rOFLYAlAJfGbor1QtqU7ijp4yG6BPTbp5wsNaevO7XDmz7PU+ko/o0V2DCtXOcePwJMMsjmc4Zfr1YFVIw==
"@picovoice/cobra-node@=2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@picovoice/cobra-node/-/cobra-node-2.0.3.tgz#3062a06ed6051e8d7d016eb03de577a420918316"
integrity sha512-fgLTBiLcP4OgmMmU7XFLCfDH7Ki9I+kJAKK2JTQsI/M884t49Qp0RaLfuEGB+pNl4Qo/5U4LsN/UU3uL8brOmA==

"@picovoice/pvrecorder-node@~1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@picovoice/pvrecorder-node/-/pvrecorder-node-1.2.3.tgz#d0cb1d1ab82fbd2e914fda4e19b1dd0022609b48"
integrity sha512-6QOODFyGDgfWZI1NeXwMxylgaxJ+c5aVbvpDMGMen287eCajp/LDnxy3J1bZHceHsW3ilk/d4rCRLyifqcr24Q==
"@picovoice/pvrecorder-node@~1.2.5":
version "1.2.5"
resolved "https://registry.yarnpkg.com/@picovoice/pvrecorder-node/-/pvrecorder-node-1.2.5.tgz#a47e11d347979ef0f1b083657ff69dd9bd2efe5c"
integrity sha512-bnid5oInf22JRdrZ75z8ooewOza0whYI9w/oSQSZbkDvddylPPrY6x+1L1qIyf5Tb8ZtzKQL+aQ9m8SazgRHFg==

commander@^6.1.0:
version "6.2.1"
Expand Down
2 changes: 1 addition & 1 deletion demo/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Cobra is a highly accurate and lightweight voice activity detection (VAD) engine
## Compatibility

- Python 3.8+
- Runs on Linux (x86_64), macOS (x86_64 and arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5).
- Runs on Linux (x86_64), macOS (x86_64 and arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5).

## AccessKey

Expand Down
4 changes: 2 additions & 2 deletions demo/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pvcobra==2.0.3
pvrecorder==1.2.2
pvcobra==2.0.4
pvrecorder==1.2.4
4 changes: 2 additions & 2 deletions demo/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@

setuptools.setup(
name="pvcobrademo",
version="2.0.3",
version="2.0.4",
author="Picovoice",
author_email="[email protected]",
description="Cobra voice activity detection (VAD) engine demos.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Picovoice/cobra",
packages=["pvcobrademo"],
install_requires=["pvcobra==2.0.3", "pvrecorder==1.2.2"],
install_requires=["pvcobra==2.0.4", "pvrecorder==1.2.4"],
include_package_data=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
Binary file added lib/node/windows/arm64/pv_cobra.node
Binary file not shown.
Binary file added lib/windows/arm64/libpv_cobra.dll
Binary file not shown.
1 change: 0 additions & 1 deletion res/.lint/spell-check/dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ logf
LPWSTR
Makefiles
micdemo
numpy
picovoice
podfile
Prefs
Expand Down

0 comments on commit 3736ace

Please sign in to comment.