snapshot
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
## Using the AI Thinker ESP32 Audio Kit Micro Speech
|
||||
|
||||
I found some cheap [AI Thinker ESP32 Audio Kit V2.2](https://docs.ai-thinker.com/en/esp32-audio-kit) on AliExpress and because I was tired of all the wires I had to connect to implement my different scenarios that are possible with my [Arduino Audio Tools Library](https://github.com/pschatzmann/arduino-audio-tools), I thought it to be a good idea to buy this board.
|
||||
|
||||
<img src="https://pschatzmann.github.io/Resources/img/audio-toolkit.png" alt="Audio Kit" />
|
||||
|
||||
You dont need to bother about any wires because everything is on one nice board. Just just need to install the dependencies
|
||||
|
||||
The staring point for doing speech recognition on an Arduino based board is TensorFlow Light For Microcontrollers with the example sketch called micro_speech!
|
||||
|
||||
I have adapted the MicroSpeech example from TensorFlow Lite to follow the philosophy of this framework. The example uses a Tensorflow model which can recognise the words 'yes' and 'no'. The output stream class is TfLiteAudioOutput. In the example I am using an ESP32 AudioKit board, but you can replace this with any type of processor with a microphone.
|
||||
Further information can be found in the [Wiki](https://github.com/pschatzmann/arduino-audio-tools/wiki/TensorFlow-Lite---MicroSpeech)
|
||||
|
||||
|
||||
### Note
|
||||
|
||||
The log level has been set to Info to help you to identify any problems. Please change it to AudioLogger::Warning to get the best sound quality!
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
You need to install the following libraries:
|
||||
|
||||
- https://github.com/pschatzmann/arduino-audio-tools
|
||||
- https://github.com/pschatzmann/arduino-audio-driver
|
||||
- https://github.com/pschatzmann/tflite-micro-arduino-examples
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/AudioLibs/TfLiteAudioStream.h"
|
||||
#include "model.h" // tensorflow model
|
||||
|
||||
AudioBoardStream kit(AudioKitEs8388V1); // Audio source
|
||||
TfLiteAudioStream tfl; // Audio sink
|
||||
const char* kCategoryLabels[4] = {
|
||||
"silence",
|
||||
"unknown",
|
||||
"yes",
|
||||
"no",
|
||||
};
|
||||
StreamCopy copier(tfl, kit); // copy mic to tfl
|
||||
int channels = 1;
|
||||
int samples_per_second = 16000;
|
||||
|
||||
void respondToCommand(const char* found_command, uint8_t score,
|
||||
bool is_new_command) {
|
||||
if (is_new_command) {
|
||||
char buffer[80];
|
||||
sprintf(buffer, "Result: %s, score: %d, is_new: %s", found_command, score,
|
||||
is_new_command ? "true" : "false");
|
||||
Serial.println(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// setup Audiokit
|
||||
auto cfg = kit.defaultConfig(RX_MODE);
|
||||
cfg.input_device = ADC_INPUT_LINE2;
|
||||
cfg.channels = channels;
|
||||
cfg.sample_rate = samples_per_second;
|
||||
cfg.use_apll = false;
|
||||
//cfg.auto_clear = true;
|
||||
cfg.buffer_size = 512;
|
||||
cfg.buffer_count = 16;
|
||||
kit.begin(cfg);
|
||||
|
||||
// Setup tensorflow
|
||||
auto tcfg = tfl.defaultConfig();
|
||||
tcfg.setCategories(kCategoryLabels);
|
||||
tcfg.channels = channels;
|
||||
tcfg.sample_rate = samples_per_second;
|
||||
tcfg.kTensorArenaSize = 10 * 1024;
|
||||
tcfg.respondToCommand = respondToCommand;
|
||||
tcfg.model = g_model;
|
||||
tfl.begin(tcfg);
|
||||
}
|
||||
|
||||
void loop() { copier.copy(); }
|
||||
Reference in New Issue
Block a user