blob: d9985c7b5d818eac0739b93545781038155285b6 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2021 Arm Limited. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#----------------------------------------------------------------------------
Kshitij Sisodiaaa4bcb12022-05-06 09:13:03 +010017# Append the API to use for this use case
18list(APPEND ${use_case}_API_LIST "kws")
alexander3c798932021-03-26 21:42:19 +000019
alexander3c798932021-03-26 21:42:19 +000020USER_OPTION(${use_case}_FILE_PATH "Directory with custom WAV input files, or path to a single WAV file, to use in the evaluation application."
21 ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
Isabella Gottardi2181d0a2021-04-07 09:27:38 +010022 PATH_OR_FILE)
alexander3c798932021-03-26 21:42:19 +000023
24USER_OPTION(${use_case}_LABELS_TXT_FILE "Labels' txt file for the chosen model."
Kshitij Sisodia76a15802021-12-24 11:05:11 +000025 ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/labels/micronet_kws_labels.txt
alexander3c798932021-03-26 21:42:19 +000026 FILEPATH)
27
28USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 16000."
29 16000
30 STRING)
31
32USER_OPTION(${use_case}_AUDIO_MONO "Specify if the audio needs to be converted to mono. Default is ON."
33 ON
34 BOOL)
35
36USER_OPTION(${use_case}_AUDIO_OFFSET "Specify the offset to start reading after this time (in seconds). Default is 0."
37 0
38 STRING)
39
40USER_OPTION(${use_case}_AUDIO_DURATION "Specify the audio duration to load (in seconds). If set to 0 the entire audio will be processed."
41 0
42 STRING)
43
44USER_OPTION(${use_case}_AUDIO_RES_TYPE "Specify re-sampling algorithm to use. By default is 'kaiser_best'."
45 kaiser_best
46 STRING)
47
48USER_OPTION(${use_case}_AUDIO_MIN_SAMPLES "Specify the minimum number of samples to use. By default is 16000, if the audio is shorter will be automatically padded."
49 16000
50 STRING)
51
52USER_OPTION(${use_case}_MODEL_SCORE_THRESHOLD "Specify the score threshold [0.0, 1.0) that must be applied to the inference results for a label to be deemed valid."
Kshitij Sisodia76a15802021-12-24 11:05:11 +000053 0.7
alexander3c798932021-03-26 21:42:19 +000054 STRING)
55
56# Generate input files
57generate_audio_code(${${use_case}_FILE_PATH} ${SRC_GEN_DIR} ${INC_GEN_DIR}
58 ${${use_case}_AUDIO_RATE}
59 ${${use_case}_AUDIO_MONO}
60 ${${use_case}_AUDIO_OFFSET}
61 ${${use_case}_AUDIO_DURATION}
62 ${${use_case}_AUDIO_RES_TYPE}
63 ${${use_case}_AUDIO_MIN_SAMPLES})
64
65# Generate labels file
66set(${use_case}_LABELS_CPP_FILE Labels)
67generate_labels_code(
68 INPUT "${${use_case}_LABELS_TXT_FILE}"
69 DESTINATION_SRC ${SRC_GEN_DIR}
70 DESTINATION_HDR ${INC_GEN_DIR}
71 OUTPUT_FILENAME "${${use_case}_LABELS_CPP_FILE}"
72)
73
74USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model"
75 0x00100000
76 STRING)
77
Kshitij Sisodia76a15802021-12-24 11:05:11 +000078
Cisco Cervelleraf085fa52021-08-02 09:32:07 +010079if (ETHOS_U_NPU_ENABLED)
Kshitij Sisodia76a15802021-12-24 11:05:11 +000080 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/kws_micronet_m_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite)
alexander3c798932021-03-26 21:42:19 +000081else()
Kshitij Sisodia76a15802021-12-24 11:05:11 +000082 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/kws_micronet_m.tflite)
alexander3c798932021-03-26 21:42:19 +000083endif()
84
85set(EXTRA_MODEL_CODE
86 "/* Model parameters for ${use_case} */"
87 "extern const int g_FrameLength = 640"
88 "extern const int g_FrameStride = 320"
89 "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD}"
90 )
91
92USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format."
93 ${DEFAULT_MODEL_PATH}
94 FILEPATH)
95
96# Generate model file
97generate_tflite_code(
98 MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH}
99 DESTINATION ${SRC_GEN_DIR}
100 EXPRESSIONS ${EXTRA_MODEL_CODE}
Kshitij Sisodiaaa4bcb12022-05-06 09:13:03 +0100101 NAMESPACE "arm" "app" "kws"
alexander3c798932021-03-26 21:42:19 +0000102)