Skip to content

Commit

Permalink
Python release with RPI5 support (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrrostam authored Jan 31, 2024
1 parent 2f859c6 commit ed51fe3
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/python-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

strategy:
matrix:
machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, jetson, beaglebone]
machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, jetson, beaglebone]
include:
- machine: rpi2
platform: raspberry-pi
Expand All @@ -77,6 +77,8 @@ jobs:
platform: raspberry-pi
- machine: rpi4-64
platform: raspberry-pi
- machine: rpi5-64
platform: raspberry-pi
- machine: jetson
platform: jetson
- machine: beaglebone
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

strategy:
matrix:
machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, jetson, beaglebone]
machine: [rpi2, rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, jetson, beaglebone]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion demo/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ similar to Alexa and Google. But it entirely runs 100% on-device. Picovoice is

## Compatibility

* Python 3.5+
* Python 3.7+
* Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), Raspberry Pi (all variants), NVIDIA Jetson (Nano), and BeagleBone.

## Installation
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 @@
picovoice==3.0.1
pvrecorder==1.2.1
picovoice==3.0.2
pvrecorder==1.2.2
8 changes: 4 additions & 4 deletions demo/python/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2020-2023 Picovoice Inc.
# Copyright 2020-2024 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 Down Expand Up @@ -39,15 +39,15 @@

setuptools.setup(
name="picovoicedemo",
version="3.0.1",
version="3.0.2",
author="Picovoice Inc.",
author_email="[email protected]",
description="Picovoice demos.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Picovoice/picovoice",
packages=["picovoicedemo"],
install_requires=["picovoice==3.0.1", "pvrecorder==1.2.1"],
install_requires=["picovoice==3.0.2", "pvrecorder==1.2.2"],
include_package_data=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand All @@ -63,6 +63,6 @@
'picovoice_demo_mic=picovoicedemo.picovoice_demo_mic:main',
],
),
python_requires='>=3.5',
python_requires='>=3.7',
keywords="wake word, voice control, speech recognition, voice recognition, natural language understanding",
)
2 changes: 1 addition & 1 deletion sdk/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ similar to Alexa and Google. But it entirely runs 100% on-device. Picovoice is

## Compatibility

* Python 3.5+
* Python 3.7+
* Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), Raspberry Pi (all variants), NVIDIA Jetson (Nano), and BeagleBone.

## Installation
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
parameterized
pvporcupine==3.0.1
pvrhino==3.0.1
pvporcupine==3.0.2
pvrhino==3.0.2
setuptools
6 changes: 3 additions & 3 deletions sdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@

setuptools.setup(
name="picovoice",
version="3.0.1",
version="3.0.2",
author="Picovoice Inc.",
author_email="[email protected]",
description="Picovoice is an end-to-end platform for building voice products on your terms.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Picovoice/picovoice",
packages=["picovoice"],
install_requires=["pvporcupine==3.0.1", "pvrhino==3.0.1"],
install_requires=["pvporcupine==3.0.2", "pvrhino==3.0.2"],
include_package_data=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand All @@ -51,6 +51,6 @@
"Programming Language :: Python :: 3",
"Topic :: Multimedia :: Sound/Audio :: Speech"
],
python_requires='>=3.5',
python_requires='>=3.7',
keywords="wake word, voice control, speech recognition, voice recognition, natural language understanding",
)
41 changes: 30 additions & 11 deletions sdk/python/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ def _pv_linux_machine(machine):
elif machine in ['armv7l', 'armv6l']:
arch_info = ''
else:
raise NotImplementedError("Unsupported CPU architecture: '%s'" % machine)
raise NotImplementedError(
"Unsupported CPU architecture: '%s'" % machine)

cpu_info = ''
try:
cpu_info = subprocess.check_output(['cat', '/proc/cpuinfo']).decode()
cpu_part_list = [x for x in cpu_info.split('\n') if 'CPU part' in x]
cpu_part = cpu_part_list[0].split(' ')[-1].lower()
except Exception as error:
raise RuntimeError("Failed to identify the CPU with '%s'\nCPU info: %s" % (error, cpu_info))
raise RuntimeError(
"Failed to identify the CPU with '%s'\nCPU info: %s" % (error, cpu_info))

if '0xb76' == cpu_part:
return 'arm11' + arch_info
Expand All @@ -48,6 +50,8 @@ def _pv_linux_machine(machine):
return 'cortex-a57' + arch_info
elif '0xd08' == cpu_part:
return 'cortex-a72' + arch_info
elif "0xd0b" == cpu_part:
return "cortex-a76" + arch_info
elif '0xc08' == cpu_part:
return 'beaglebone' + arch_info
elif machine == 'armv7l':
Expand All @@ -74,7 +78,15 @@ def _pv_platform():

_PV_SYSTEM, _PV_MACHINE = _pv_platform()

_RASPBERRY_PI_MACHINES = {'arm11', 'cortex-a7', 'cortex-a53', 'cortex-a72', 'cortex-a53-aarch64', 'cortex-a72-aarch64'}
_RASPBERRY_PI_MACHINES = {
"arm11",
"cortex-a7",
"cortex-a53",
"cortex-a72",
"cortex-a76",
"cortex-a53-aarch64",
"cortex-a72-aarch64",
"cortex-a76-aarch64"}
_JETSON_MACHINES = {'cortex-a57-aarch64'}


Expand Down Expand Up @@ -109,7 +121,8 @@ def __append_language(s, language):
def context_path(context, language):
system = platform.system()

contexts_root = __append_language('../../resources/rhino/resources/contexts', language)
contexts_root = __append_language(
'../../resources/rhino/resources/contexts', language)

if system == 'Darwin':
return os.path.join(os.path.dirname(__file__), contexts_root, 'mac', '%s_mac.rhn' % context)
Expand All @@ -119,13 +132,16 @@ def context_path(context, language):
else:
cpu_info = ''
try:
cpu_info = subprocess.check_output(['cat', '/proc/cpuinfo']).decode()
cpu_part_list = [x for x in cpu_info.split('\n') if 'CPU part' in x]
cpu_info = subprocess.check_output(
['cat', '/proc/cpuinfo']).decode()
cpu_part_list = [x for x in cpu_info.split(
'\n') if 'CPU part' in x]
cpu_part = cpu_part_list[0].split(' ')[-1].lower()
except Exception as error:
raise RuntimeError("Failed to identify the CPU with '%s'\nCPU info: %s" % (error, cpu_info))
raise RuntimeError(
"Failed to identify the CPU with '%s'\nCPU info: %s" % (error, cpu_info))

if '0xb76' == cpu_part or '0xc07' == cpu_part or '0xd03' == cpu_part or '0xd08' == cpu_part:
if cpu_part in ('0xb76', '0xc07', '0xd03', '0xd08', '0xd0b'):
return os.path.join(os.path.dirname(__file__),
contexts_root, 'raspberry-pi', '%s_raspberry-pi.rhn' % context)
elif '0xd07' == cpu_part:
Expand All @@ -146,7 +162,8 @@ def pv_keyword_paths_by_language(language):
keyword_files_root = __append_language('resources/keyword_files', language)
relative = '../../resources/porcupine'
keyword_files_dir = \
os.path.join(os.path.dirname(__file__), relative, keyword_files_root, pv_keyword_files_subdir())
os.path.join(os.path.dirname(__file__), relative,
keyword_files_root, pv_keyword_files_subdir())

res = dict()
for x in os.listdir(keyword_files_dir):
Expand All @@ -162,13 +179,15 @@ def pv_rhino_model_path_by_language(language):


def pv_porcupine_model_path_by_language(language):
model_path_subdir = __append_language('lib/common/porcupine_params', language)
model_path_subdir = __append_language(
'lib/common/porcupine_params', language)
model_path_subdir = '%s.pv' % model_path_subdir
return os.path.join(os.path.dirname(__file__), '../../resources/porcupine', model_path_subdir)


def load_test_data():
data_file_path = os.path.join(os.path.dirname(__file__), "../../resources/.test/test_data.json")
data_file_path = os.path.join(os.path.dirname(
__file__), "../../resources/.test/test_data.json")
with open(data_file_path, encoding="utf8") as data_file:
json_test_data = data_file.read()
test_data = json.loads(json_test_data)['tests']
Expand Down

0 comments on commit ed51fe3

Please sign in to comment.