Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
461 changes: 461 additions & 0 deletions application/team trinova/.cproject

Large diffs are not rendered by default.

3,545 changes: 3,545 additions & 0 deletions application/team trinova/.project

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions application/team trinova/.projectlinkstore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"data":[{"hit":0,"alias":"app.c","type":"FILE","data":"C:/Users/INDARAM SRI CHARITHA/SimplicityStudio/v5_workspace/.browser/ml_voice_control_light/app.c"},{"hit":0,"alias":"main.c","type":"FILE","data":"C:/Users/INDARAM SRI CHARITHA/SimplicityStudio/v5_workspace/.browser/ml_voice_control_light/main.c"},{"hit":0,"alias":"readme.md","type":"FILE","data":"C:/Users/INDARAM SRI CHARITHA/SimplicityStudio/v5_workspace/.browser/ml_voice_control_light/readme.md"},{"hit":0,"alias":"Post Build Editor","type":"TOOL","data":"postbuildeditor"},{"hit":0,"alias":"Pin Tool","type":"TOOL","data":"pintool"},{"hit":0,"alias":"Memory Editor","type":"TOOL","data":"memoryeditor"},{"hit":0,"alias":"Software Components","type":"NAVIGATION","data":"softwarecomponents"},{"hit":0,"alias":"docs.silabs.com","type":"EXTERNAL_URL","data":"https://docs.silabs.com/"}]}
26 changes: 26 additions & 0 deletions application/team trinova/app.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/***************************************************************************//**
* @file
* @brief Top level application functions
*******************************************************************************
* # License
* <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#include "app.h"
#include "voice_control_light.h"

/***************************************************************************//**
* Initialize application.
******************************************************************************/
void app_init(void)
{
voice_control_light_init();
}
26 changes: 26 additions & 0 deletions application/team trinova/app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/***************************************************************************//**
* @file app.h
* @brief Top level application functions
*******************************************************************************
* # License
* <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/

#ifndef APP_H
#define APP_H

/***************************************************************************//**
* Initialize application.
******************************************************************************/
void app_init(void);

#endif // APP_H
43 changes: 43 additions & 0 deletions application/team trinova/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/***************************************************************************//**
* @file main.c
* @brief main() function.
*******************************************************************************
* # License
* <b>Copyright 2025 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_main_init.h"
#include "sl_main_kernel.h"

int main(void)
{
// Initialize Silicon Labs device, system, service(s) and protocol stack(s).
sl_main_second_stage_init();

app_init();

while (sl_main_start_task_should_continue()) {
app_process_action();
}
}
10 changes: 10 additions & 0 deletions application/team trinova/ml_voice_control_light.pintool
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="ASCII"?>
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="pin_tool.EFR32MG26B510F3200IM68" partId="mcu.arm.efr32.mg26.efr32mg26b510f3200im68" contextId="com.silabs.sdk.stack.sisdk:2025.6.2._-662044072">
<mode name="DefaultMode">
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
</mode>
<modeTransition>
<property object="RESET &#x2192; DefaultMode" propertyId="modeTransition.source" value="RESET"/>
<property object="RESET &#x2192; DefaultMode" propertyId="modeTransition.target" value="DefaultMode"/>
</modeTransition>
</device:XMLDevice>
84 changes: 84 additions & 0 deletions application/team trinova/ml_voice_control_light.slcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Silicon Labs Project Configuration Tools: slcp, v0, Component selection file.
project_name: ml_voice_control_light
label: ml_voice_control_light
description: |
This application uses TensorFlow Lite for Microcontrollers to detect the spoken words "on" and "off" from audio data recorded on the microphone in a Micrium OS kernel task. The detected keywords are used to control an LED on the board.
category: AI/ML Application
filter:
- name: Capability
value: [Machine Learning]
- name: Device Type
value: [SoC]
- name: MCU
value: [32-bit MCU]
- name: Project Difficulty
value: [Advanced]
package: aiml
quality: production
readme:
- {path: readme.md}
- {path: readme.md}
source:
- {path: app.c}
- {path: voice_control_light.cc}
- {path: recognize_commands.cc}
tag: ['hardware:device:flash:130', 'hardware:device:ram:128', 'hardware:component:microphone',
'hardware:component:led:1+']
include:
- path: .
file_list:
- {path: app.h}
- {path: voice_control_light.h}
- {path: recognize_commands.h}
sdk: {id: simplicity_sdk, version: 2025.6.2}
toolchain_settings:
- {value: -Wno-unused-parameter, option: gcc_compiler_option}
- {value: -Wno-missing-field-initializers, option: gcc_compiler_option}
component:
- {from: aiml, id: ml_audio_feature_generation}
- {from: aiml, id: tensorflow_debug_log_iostream}
- {from: aiml, id: tensorflow_lite_micro}
- {from: aiml, id: tensorflow_lite_micro_accelerated_kernels}
- {from: aiml, id: tensorflow_lite_micro_optimized_kernels}
- {id: EFR32MG26B510F3200IM68}
- {id: brd2608a}
- {id: clock_manager}
- {id: device_init}
- {id: iostream_recommended_stream}
- {id: iostream_retarget_stdio}
- {id: memory_manager}
- {id: micriumos_kernel}
- {id: power_manager}
- {id: printf}
- instance: [led0]
id: simple_led
- {id: sl_main}
- {id: sleeptimer}
- {id: status}
define:
- {name: DEBUG_EFM}
- {name: TF_LITE_STATIC_MEMORY}
config_file:
- {path: config/recognize_commands_config.h}
- {path: config/tflite/keyword_spotting_on_off_v2.tflite, directory: tflite}
configuration:
- {name: SL_BOARD_ENABLE_VCOM, value: '1'}
- {name: SL_BOARD_ENABLE_SENSOR_MICROPHONE, value: '1'}
- condition: [iostream_usart]
name: SL_IOSTREAM_USART_VCOM_CONVERT_BY_DEFAULT_LF_TO_CRLF
value: '1'
- condition: [iostream_uart]
name: SL_IOSTREAM_UART_VCOM_CONVERT_BY_DEFAULT_LF_TO_CRLF
value: '1'
- {name: SL_ML_AUDIO_FEATURE_GENERATION_AUDIO_BUFFER_SIZE, value: '4096'}
- {name: SL_TFLITE_MICRO_ARENA_SIZE, value: '100000'}
- {name: SL_HEAP_SIZE, value: '8192'}
- condition: [tensorflow_lite_micro_accelerated_kernels]
name: SL_MVP_OPTIMIZE_SPEED
value: '1'
ui_hints:
highlight:
- {path: readme.md, focus: true}
sdk_extension:
- {id: aiml, version: 2.1.2}

17 changes: 17 additions & 0 deletions application/team trinova/ml_voice_control_light.slps
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="ASCII"?>
<model:MDescriptors xmlns:model="http://www.silabs.com/ss/Studio.ecore">
<descriptors name="ml_voice_control_light">
<properties key="projectCommon.sdkId" value="com.silabs.sdk.stack.sisdk:2025.6.2._-662044072"/>
<properties key="universalConfig.relativeWorkspacePath" value="..\ml_voice_control_light.slcw"/>
<properties key="universalConfig.generationDirectory" value=""/>
<properties key="universalConfig.toolchainCompatibility" value="gcc"/>
<properties key="projectCommon.overwriteCopiedSources" value="false"/>
<properties key="projectCommon.boardIds" value="brd2608a:0.0.0.A02"/>
<properties key="projectCommon.kitId" value=""/>
<properties key="projectCommon.partId" value="mcu.arm.efr32.mg26.efr32mg26b510f3200im68"/>
<properties key="projectCommon.toolchainId" value="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:12.2.1.20221205"/>
<properties key="universalConfig.projectTypeIds" value="com.silabs.ss.framework.ide.project.core.cdtMbsProjectType"/>
<properties key="projectCommon.importModeId" value="LINK_LIBRARIES"/>
<properties key="universalConfig.compSelProjInstanceId" value="1763969429120"/>
</descriptors>
</model:MDescriptors>
34 changes: 34 additions & 0 deletions application/team trinova/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Voice Control Light
This application uses TensorFlow Lite for Microcontrollers to detect the spoken
words "on" and "off" from audio data recorded on the microphone. The detected
keywords are used to control an LED on the board.

Audio is sampled continuously from the microphone at a rate of 8kHz. The
frequency components are then extracted by calculating the FFT on short segments
of audio as they become available. The result is an array of filterbanks,
representing the frequency components of the past second of audio. The processed
audio data is passed into a neural network at an interval of 200 ms. If the
model detects that either of the keywords "on" or "off" were spoken, LED0 will
toggle accordingly and the keyword detection result is printed on VCOM.

The application is based on TensorFlow's example application, **[micro speech](https://github.com/tensorflow/tensorflow/tree/v2.3.1/tensorflow/lite/micro/examples/micro_speech)**.

## Model
The application uses one of two different available models
(```keyword_spotting_on_off.tflite``` or ```keyword_spotting_on_off_v2.tflite```)
as the default model, depending on whether the application is generated for a
development board featuring an MVP hardware accelerator or not. When an MVP
hardware accelerator is featured on the board, inference will run at a faster
speed such that a larger model can be chosen, yielding more accurate keyword
detections.

The neural network model has been trained to identify the two keywords "on" and
"off" from preprocessed audio data. When neither words are recognized, the model
will classify the input as either "unknown" or "background". The model takes an
array of filterbanks as input and outputs a vector with each value corresponding
to the probability that the input belongs to each of the
categories.

Details about the model architectures and scripts for generating the models can
be found in the [Silicon Labs machine learning applications](https://github.com/SiliconLabs/machine_learning_applications/tree/main/) repository, under
```application/voice/keyword_spotting/model```.
95 changes: 95 additions & 0 deletions application/team trinova/recognize_commands.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This file has been modified by Silicon Labs.
==============================================================================*/

#include "recognize_commands.h"

#include <limits>

// Labels used by the Voice Control tflite model
// 0 - on
// 1 - off
// 2 - unknown
// 3 - background
const char* kCategoryLabels[kMaxCategoryCount] = {
"on",
"off",
"unknown",
"background",
};

RecognizeCommands::RecognizeCommands(tflite::ErrorReporter* error_reporter,
uint8_t detection_threshold,
int32_t suppression_ms)
: error_reporter_(error_reporter),
detection_threshold_(detection_threshold),
suppression_ms_(suppression_ms),
previous_results_(error_reporter)
{
previous_top_label_index_ = 3; // "background"
previous_top_label_time_ = std::numeric_limits < int32_t > ::min();
}

TfLiteStatus RecognizeCommands::ProcessLatestResults(
const TfLiteTensor* latest_results, const int32_t current_time_ms,
uint8_t* found_command_index, uint8_t* score, bool* is_new_command)
{

uint8_t category_count = latest_results->dims->data[1];
int8_t current_top_index = 0;
int32_t current_top_score = 0;
uint8_t converted_scores[kMaxCategoryCount];

// Convert the model output to uint8
if (latest_results->type == kTfLiteInt8) {
for(int i = 0; i < category_count; ++i) {
converted_scores[i] = (uint8_t)(latest_results->data.int8[i] + 128);
}
} else {
TF_LITE_REPORT_ERROR(error_reporter_, "Unsupported output tensor data type, must be int8 or float32");
return kTfLiteError;
}

for (int i = 0; i < category_count; i++) {
if (converted_scores[i] > current_top_score) {
current_top_score = converted_scores[i];
current_top_index = i;
}
}

// If we've recently had another label trigger, assume one that occurs too
// soon afterwards is a bad result.
int64_t time_since_last_top;
if ((previous_top_label_index_ == 3 || previous_top_label_index_ == 2)
|| (previous_top_label_time_ == std::numeric_limits < int32_t > ::min())) {
time_since_last_top = std::numeric_limits < int32_t > ::max();
// Reset timer if detecting background / unknown
} else {
time_since_last_top = current_time_ms - previous_top_label_time_;
}

if ((current_top_score > detection_threshold_) && (time_since_last_top > suppression_ms_)) {
previous_top_label_index_ = current_top_index;
previous_top_label_time_ = current_time_ms;
*is_new_command = true;
} else {
*is_new_command = false;
}

*found_command_index = current_top_index;
*score = current_top_score;
return kTfLiteOk;
}
Loading
Loading