alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 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 Sisodia | aa4bcb1 | 2022-05-06 09:13:03 +0100 | [diff] [blame] | 17 | # Append the API to use for this use case |
| 18 | list(APPEND ${use_case}_API_LIST "asr") |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 19 | |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 20 | USER_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 Gottardi | 2181d0a | 2021-04-07 09:27:38 +0100 | [diff] [blame] | 22 | PATH_OR_FILE) |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 23 | |
| 24 | USER_OPTION(${use_case}_LABELS_TXT_FILE "Labels' txt file for the chosen model." |
| 25 | ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/labels/labels_wav2letter.txt |
| 26 | FILEPATH) |
| 27 | |
| 28 | USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 16000." |
| 29 | 16000 |
| 30 | STRING) |
| 31 | |
| 32 | USER_OPTION(${use_case}_AUDIO_MONO "Specify if the audio needs to be converted to mono. Default is ON." |
| 33 | ON |
| 34 | BOOL) |
| 35 | |
| 36 | USER_OPTION(${use_case}_AUDIO_OFFSET "Specify the offset to start reading after this time (in seconds). Default is 0." |
| 37 | 0 |
| 38 | STRING) |
| 39 | |
| 40 | USER_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 | |
| 44 | USER_OPTION(${use_case}_AUDIO_RES_TYPE "Specify re-sampling algorithm to use. By default is 'kaiser_best'." |
| 45 | kaiser_best |
| 46 | STRING) |
| 47 | |
| 48 | USER_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 | |
| 52 | USER_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." |
| 53 | 0.5 |
| 54 | STRING) |
| 55 | |
| 56 | # Generate input files |
| 57 | generate_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 |
| 66 | set(${use_case}_LABELS_CPP_FILE Labels) |
| 67 | generate_labels_code( |
Kshitij Sisodia | e12ac83 | 2021-05-20 11:18:53 +0100 | [diff] [blame] | 68 | INPUT "${${use_case}_LABELS_TXT_FILE}" |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 69 | DESTINATION_SRC ${SRC_GEN_DIR} |
| 70 | DESTINATION_HDR ${INC_GEN_DIR} |
| 71 | OUTPUT_FILENAME "${${use_case}_LABELS_CPP_FILE}" |
| 72 | ) |
| 73 | |
| 74 | |
| 75 | USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model" |
Kshitij Sisodia | 661959c | 2021-11-24 10:39:52 +0000 | [diff] [blame] | 76 | 0x00200000 |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 77 | STRING) |
| 78 | |
Cisco Cervellera | f085fa5 | 2021-08-02 09:32:07 +0100 | [diff] [blame] | 79 | if (ETHOS_U_NPU_ENABLED) |
Kshitij Sisodia | 3be2623 | 2021-10-29 12:29:06 +0100 | [diff] [blame] | 80 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/wav2letter_pruned_int8_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite) |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 81 | else() |
Kshitij Sisodia | e12ac83 | 2021-05-20 11:18:53 +0100 | [diff] [blame] | 82 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/wav2letter_pruned_int8.tflite) |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 83 | endif() |
| 84 | |
| 85 | set(EXTRA_MODEL_CODE |
| 86 | "/* Model parameters for ${use_case} */" |
| 87 | "extern const int g_FrameLength = 512" |
| 88 | "extern const int g_FrameStride = 160" |
| 89 | "extern const int g_ctxLen = 98" |
| 90 | "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD}" |
| 91 | ) |
| 92 | |
| 93 | USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format." |
| 94 | ${DEFAULT_MODEL_PATH} |
| 95 | FILEPATH |
| 96 | ) |
| 97 | |
| 98 | # Generate model file |
| 99 | generate_tflite_code( |
| 100 | MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH} |
| 101 | DESTINATION ${SRC_GEN_DIR} |
| 102 | EXPRESSIONS ${EXTRA_MODEL_CODE} |
Kshitij Sisodia | aa4bcb1 | 2022-05-06 09:13:03 +0100 | [diff] [blame] | 103 | NAMESPACE "arm" "app" "asr") |