17 Copyright 2020-2022 Picovoice Inc.
19 You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
20 file accompanying this source.
22 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
23 an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
24 specific language governing permissions and limitations under the License.
39 LANGUAGE_CODE_TO_NAME = {
48 script_dir = os.path.dirname(os.path.abspath(__file__))
49 repo_dir = os.path.join(script_dir,
'../..')
51 for header_file_path
in header_file_folders:
52 header_file = os.path.join(header_file_path,
'pv_params.h')
53 with open(os.path.join(script_dir, header_file),
'w')
as f_out:
56 for language, keywords
in ppn_files.items():
58 ppn_dir = os.path.join(repo_dir,
'resources/keyword_files/cortexm')
60 ppn_dir = os.path.join(repo_dir, f
'resources/keyword_files_{language}/cortexm')
62 f_out.write(f
'#if defined(__PV_LANGUAGE_{LANGUAGE_CODE_TO_NAME[language].upper()}__)\n\n')
63 for index, keyword
in enumerate(keywords):
64 keyword_file_path = os.path.join(ppn_dir, keyword +
'_cortexm.ppn')
66 f_out.write(f
'// Wake-word = {keyword}\n')
68 f_out.write(
'static const uint8_t DEFAULT_KEYWORD_ARRAY[] '
69 '__attribute__ ((aligned (16))) = {\n')
72 f
'static const uint8_t {keyword.upper()}_KEYWORD_ARRAY[] '
73 '__attribute__ ((aligned (16))) = {\n')
74 f_out.write(
'\n'.join(ppn_c_array))
77 f_out.write(f
'#endif\n\n')
85 with open(ppn_file_path,
'rb')
as f:
88 array = [
'0x%s' % z.hex()
for z
in struct.unpack(
'%dc' % len(array), array)]
92 if len(row) >= line_width:
93 row = row.rsplit(
', ', maxsplit=1)[0] +
','
95 row =
' ' * indent + last_x
96 if row !=
' ' * indent:
100 if row !=
' ' * indent:
106 if __name__ ==
'__main__':
108 'en': (
'porcupine',
'picovoice',
'bumblebee',
'alexa',),
109 'de': (
'hey computer',),
110 'es': (
'hola computadora',),
111 'fr': (
'salut ordinateur',)
114 'stm32h747/stm32h747i-disco/CM7/Inc/',
115 'stm32f469/stm32f469i-disco/Inc/',
116 'stm32f769/stm32f769i-disco/Inc/',
117 'stm32f411/stm32f411e-disco/Inc/',
118 'stm32f407/stm32f407g-disc1/Inc/',
119 'stm32h735/stm32h735g-dk/Inc/',
120 'imxrt1050/imxrt1050-evkb/inc',