-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compilation problem #21
Comments
Please upload the |
here is the model.h file , thanks a lot.
|
If you want to do KWS, either 1) use EdgeImpulse or similar software, 2) record many samples of you saying something different from the keyword you want to recognize or many sounds different from the one of interest (for example street noise, TV backgound, any sound from YouTube). Then it may work, but it's not a guarantee. |
here is the arduino project file, thanks again:
|
Ok, you're reading an old blog post, the code changed. Here it is. #include <arduinoFFT.h>
// uncomment when doing classification
#include "model.h.cpp"
#define MIC A0
#define NUM_SAMPLES 64
#define SAMPLING_FREQUENCY 1024
#define INTERVAL 5
#define SOUND_THRESHOLD 3
unsigned int samplingPeriod;
unsigned long microSeconds;
int32_t backgroundSound;
double features[NUM_SAMPLES];
arduinoFFT fft;
// add this
Eloquent::ML::Port::RandomForest classifier;
void setup() {
Serial.begin(115200);
pinMode(MIC, INPUT);
samplingPeriod = round(1000000*(1.0/SAMPLING_FREQUENCY));
calibrate();
}
void loop() {
if (!soundDetected()) {
delay(10);
return;
}
captureWord();
printFeatures();
// uncomment when doing classification
Serial.print("You said ");
// replace this
Serial.println(classifier.predictLabel(features));
delay(1000);
}
/**
Get analog readings
@return
*/
int16_t readMic() {
return analogRead(MIC);
return (analogRead(MIC) - 512) >> 2;
}
/**
Get "ambient" volume
*/
void calibrate() {
for (int i = 0; i < 200; i++)
backgroundSound += readMic();
backgroundSound /= 200;
Serial.print("Threshold set at ");
Serial.println(backgroundSound);
}
bool soundDetected() {
return abs(readMic() - backgroundSound) >= SOUND_THRESHOLD;
}
void captureWord() {
for (uint16_t i = 0; i < NUM_SAMPLES; i++) {
microSeconds = micros();
features[i] = readMic();
while(micros() < (microSeconds + samplingPeriod));
}
fft.Windowing(features, NUM_SAMPLES, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
}
void printFeatures() {
const uint16_t numFeatures = sizeof(features) / sizeof(double);
for (int i = 0; i < numFeatures; i++) {
Serial.print(features[i]);
Serial.print(i == numFeatures - 1 ? '\n' : ',');
}
} Modifications at:
|
Again, as is now, the classifier will always print "shang1": you have to train it on more that one word, or in your case, train on "shang1" vs "everything but shang1" |
It's very kind of you! I'll try. |
You will actually need any possible sound that may happen where you're going to deploy your system. Will you deploy in a forest? Go into a forest and record the birds, the wind, the woods, other animals and so on. Of course, remember to 1) balance your dataset (since you will have many more samples of "negative" class than "shang1") or 2) properly set the class_weights parameter in random forest or 3) any other tecnique to handle imbalanced datasets. Yes, you can reach me on Twitter. I warn you that I'm not always available though. |
today I try again, a new compile error appears: |
I modified the model.h file and it work! but the result is regret. It can't correctlly classify even tow words :"shang" , "xia". o Orz... |
this method is suitable for some simple sound,for example the sounf of machine, but not good for speach(maybe I didn't do it in right way). Anyway , thank Simone very much! |
You're correct. I will make it more clear on the blog, this is only for simple detection. I was able to distinguish "play" from "stop". |
Dear man:
After I recorded the sound data and train them, I use micromlgen to output a "model.h" file. But when I include it to my project file and try to compile it, I found the "cstdarg.h" is missing. I changed it to "stdarg.h" and compiled again, it come out a error: 'predict' was not declared in this scope.
Is there anything wrong?
The text was updated successfully, but these errors were encountered: