diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.sds b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.sds index a9656f7..d5f1b9c 100644 Binary files a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.sds and b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.sds differ diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.sds.png b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.sds.png index d4ffa58..d64e9fe 100644 Binary files a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.sds.png and b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.sds.png differ diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.wav b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.wav index 5e056c2..9063a87 100644 Binary files a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.wav and b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.0.wav differ diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.sds.yml b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.sds.yml index b6fedec..1461372 100644 --- a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.sds.yml +++ b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_In.sds.yml @@ -1,6 +1,6 @@ sds: name: ML input - description: Mono audio from microphone + description: Mono audio from microphone sampled at 16kHz sample-frequency: 16000 content: - audio: diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_Out.0.sds b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_Out.0.sds index f1090e2..7edc39a 100644 Binary files a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_Out.0.sds and b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_Out.0.sds differ diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_Out.0.sds.png b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_Out.0.sds.png index 16c7e46..bacd990 100644 Binary files a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_Out.0.sds.png and b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/ML_Out.0.sds.png differ diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/README.md b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/README.md index b6f7726..0400986 100644 --- a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/README.md +++ b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/SDS Recordings/README.md @@ -36,7 +36,7 @@ You can graphically represent SDS files using the **SDS-View** utility. ``` Example visualization: - ![ML_Out.3.sds](ML_Out.0.sds.png) + ![ML_Out.0.sds](ML_Out.0.sds.png) ## Audio data You can convert recorded microphone data with **SDS-Convert** utility into a .wav format. diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm.h b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm.h index 034bcc4..e744276 100644 --- a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm.h +++ b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm.h @@ -28,20 +28,20 @@ extern "C" /** \fn int32_t InitAlgorithm (void) - \brief Initialize algorithm under test. + \brief Initialize the algorithm under test. \return 0 on success; -1 on error */ extern int32_t InitAlgorithm (void); /** \fn void ResetAlgorithm (void) - \brief Reset algorithm under test before starting a playback run. + \brief Reset the algorithm under test before initiating recording or playback. */ extern void ResetAlgorithm (void); /** \fn int32_t ExecuteAlgorithm (uint8_t *in_buf, uint32_t in_num, uint8_t *out_buf, uint32_t out_num) - \brief Execute algorithm under test. + \brief Execute the algorithm under test. \param[in] in_buf pointer to memory buffer containing input data for algorithm \param[in] in_num number of data bytes in input data buffer (in bytes) \param[out] out_buf pointer to memory buffer for returning algorithm output diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm_user.cpp b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm_user.cpp index ac109d8..12a5b41 100644 --- a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm_user.cpp +++ b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm_user.cpp @@ -41,12 +41,12 @@ int get_data (size_t offset, size_t length, float *out_ptr) { return -1; } - return numpy::int16_to_float((int16_t *)ptr_in_data + (offset * sizeof(int16_t)), out_ptr, length); + return numpy::int16_to_float(reinterpret_cast(ptr_in_data) + offset,out_ptr, length); } /** \fn int32_t InitAlgorithm (void) - \brief Initialize algorithm under test. + \brief Initialize the algorithm under test. \return 0 on success; -1 on error */ int32_t InitAlgorithm (void) { @@ -62,14 +62,15 @@ int32_t InitAlgorithm (void) { /** \fn void ResetAlgorithm (void) - \brief Reset algorithm under test before starting a playback run. + \brief Reset the algorithm under test before initiating recording or playback. */ void ResetAlgorithm (void) { + run_classifier_init(); } /** \fn int32_t ExecuteAlgorithm (uint8_t *in_buf, uint32_t in_num, uint8_t *out_buf, uint32_t out_num) - \brief Execute algorithm under test. + \brief Execute the algorithm under test. \param[in] in_buf pointer to memory buffer containing input data for algorithm \param[in] in_num number of data bytes in input data buffer (in bytes) \param[out] out_buf pointer to memory buffer for returning algorithm output diff --git a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/sds_main.c b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/sds_main.c index 50ac5fc..0cb4429 100644 --- a/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/sds_main.c +++ b/ST/B-U585I-IOT02A/KeywordSpotting/algorithm/sds_main.c @@ -36,6 +36,9 @@ static uint8_t sds_data_out_buf[(ALGO_DATA_OUT_BLOCK_SIZE * 2) + 2048] __ALIGNED static sdsId_t sds_data_in_id = NULL; static sdsId_t sds_data_out_id = NULL; +// Algorithm reset request +static volatile uint8_t reset_algo = 0U; + // Recording/playback mode text static const char *SDS_MODE[] = { "recording", "playback" }; @@ -53,10 +56,11 @@ int32_t OpenStreams (void) { if ((sdsFlags & SDS_FLAG_PLAYBACK) != 0U) { // If open for playback requested play = 1U; - // Reset algorithm under test before starting a playback run - ResetAlgorithm(); } + // Activate the algorithm reset request before starting recording or playback + reset_algo = 1U; + // Open stream for playback or recording of input data, depending on the mode if (play != 0U) { // -- Playback // Check https://arm-software.github.io/SDS-Framework/main/theory.html#filenames for details on playback filename @@ -197,6 +201,12 @@ __NO_RETURN void AlgorithmThread (void *argument) { } } + // If the algorithm reset request is active and the state is ACTIVE, call the ResetAlgorithm() function + if ((sds_state == SDS_STATE_ACTIVE) && (reset_algo != 0U)) { + reset_algo = 0U; + ResetAlgorithm(); + } + // Execute algorithm under test if (ExecuteAlgorithm(algo_data_in_buf, sizeof(algo_data_in_buf), algo_data_out_buf, sizeof(algo_data_out_buf)) != 0) { // If there was an error executing algorithm skip recording