Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions ST/B-U585I-IOT02A/KeywordSpotting/algorithm/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<const int16_t *>(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) {
Expand All @@ -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
Expand Down
14 changes: 12 additions & 2 deletions ST/B-U585I-IOT02A/KeywordSpotting/algorithm/sds_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" };

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading