17 log = logging.getLogger(
'RHN')
18 log.setLevel(logging.WARNING)
22 if machine ==
'x86_64':
24 elif machine ==
'aarch64':
25 arch_info =
'-' + machine
26 elif machine
in [
'armv7l',
'armv6l']:
29 raise NotImplementedError(
"Unsupported CPU architecture: '%s'" % machine)
33 cpu_info = subprocess.check_output([
'cat',
'/proc/cpuinfo']).decode()
34 cpu_part_list = [x
for x
in cpu_info.split(
'\n')
if 'CPU part' in x]
35 cpu_part = cpu_part_list[0].split(
' ')[-1].lower()
36 except Exception
as error:
37 raise RuntimeError(
"Failed to identify the CPU with '%s'\nCPU info: %s" % (error, cpu_info))
39 if '0xb76' == cpu_part:
41 elif '0xc07' == cpu_part:
43 elif '0xd03' == cpu_part:
44 return 'cortex-a53' + arch_info
45 elif '0xd07' == cpu_part:
46 return 'cortex-a57' + arch_info
47 elif '0xd08' == cpu_part:
48 return 'cortex-a72' + arch_info
49 elif '0xc08' == cpu_part:
51 elif machine ==
'armv7l':
53 'WARNING: Please be advised that this device (CPU part = %s) is not officially supported by Picovoice. '
54 'Falling back to the armv6-based (Raspberry Pi Zero) library. This is not tested nor optimal.' % cpu_part)
57 raise NotImplementedError(
"Unsupported CPU: '%s'." % cpu_part)
61 pv_system = platform.system()
62 if pv_system
not in {
'Darwin',
'Linux',
'Windows'}:
63 raise ValueError(
"Unsupported system '%s'." % pv_system)
65 if pv_system ==
'Linux':
68 pv_machine = platform.machine()
70 return pv_system, pv_machine
75 _RASPBERRY_PI_MACHINES = {
'arm11',
'cortex-a7',
'cortex-a53',
'cortex-a72',
'cortex-a53-aarch64',
'cortex-a72-aarch64'}
76 _JETSON_MACHINES = {
'cortex-a57-aarch64'}
80 if _PV_SYSTEM ==
'Darwin':
81 if _PV_MACHINE ==
'x86_64':
82 return os.path.join(os.path.dirname(__file__), relative_path,
'lib/mac/x86_64/libpv_rhino.dylib')
83 elif _PV_MACHINE ==
'arm64':
84 return os.path.join(os.path.dirname(__file__), relative_path,
'lib/mac/arm64/libpv_rhino.dylib')
85 elif _PV_SYSTEM ==
'Linux':
86 if _PV_MACHINE ==
'x86_64':
87 return os.path.join(os.path.dirname(__file__), relative_path,
'lib/linux/x86_64/libpv_rhino.so')
88 elif _PV_MACHINE
in _JETSON_MACHINES:
90 os.path.dirname(__file__),
92 'lib/jetson/%s/libpv_rhino.so' % _PV_MACHINE)
93 elif _PV_MACHINE
in _RASPBERRY_PI_MACHINES:
95 os.path.dirname(__file__),
97 'lib/raspberry-pi/%s/libpv_rhino.so' % _PV_MACHINE)
98 elif _PV_MACHINE ==
'beaglebone':
99 return os.path.join(os.path.dirname(__file__), relative_path,
'lib/beaglebone/libpv_rhino.so')
100 elif _PV_SYSTEM ==
'Windows':
101 return os.path.join(os.path.dirname(__file__), relative_path,
'lib/windows/amd64/libpv_rhino.dll')
103 raise NotImplementedError(
"Unsupported platform ('%s', '%s').", _PV_SYSTEM, _PV_MACHINE)
107 return os.path.join(os.path.dirname(__file__), relative_path,
'lib/common/rhino_params.pv')