µSpeech  4.1.2
Speech recognition library
 All Classes Functions Variables Pages
phoneme.cpp
1 #include "uspeech.h"
6 {
7 #ifdef ARDUINO_ENVIRONMENT
8  sample();
9 #endif
10  unsigned int pp =power();
11  //Serial.print(F("pp=")); Serial.println(pp);
12  if (pp>SILENCE) {
13  //Perform Division
14  int k = complexity(pp);
15  //Low pass filter for noise removal
16  overview[6] = overview[5];
17  overview[5] = overview[4];
18  overview[4] = overview[3];
19  overview[3] = overview[2];
20  overview[2] = overview[1];
21  overview[1] = overview[0];
22  overview[0] = k;
23 
24  int coeff = 0;
25  for (uint8_t f=0; f<6; f++) {
26  coeff += overview[f];
27  }
28  coeff /= 7;
29 
30  micPower = 0.05 * maxPower() + (1 - 0.05) * micPower;
31  if (micPower < micPowerThreshold) {
32  return ' ';
33  }
34 
35  testCoeff = coeff;
36  //Serial.print(F("coeff: ")); Serial.println(coeff); //Use this for debugging
37 
38  //Twiddle with the numbers here if your getting false triggers
39  //This is the main classifier part
40 
41  if (coeff<econstant) { /*Default value = 2*/
42  phoneme = 'e';
43  } else if (coeff<aconstant) { /*Default value = 4*/
44  phoneme = 'o';
45  } else if (coeff<vconstant) { /*Default value = 6*/
46  phoneme = 'v';
47  } else if (coeff<shconstant) { /*Default value = 10*/
48  phoneme = 'h';
49  } else {
50  phoneme = 's';
51  }
52 
53  if (f_enabled) {
54  //Serial.print(F("micPower: ")); Serial.println(micPower);
55  if (micPower > fconstant) {
56  return 'f';
57  }
58  }
59 
60  return phoneme;
61 
62  }
63 
64  micPower = 0;
65  testCoeff = 0;
66  return ' ';
67 }
68 
int vconstant
Definition: uspeech.h:35
char getPhoneme()
Definition: phoneme.cpp:5
unsigned int power()
Definition: signal.cpp:48
bool f_enabled
Definition: uspeech.h:37
unsigned int maxPower()
Definition: signal.cpp:75
int econstant
Definition: uspeech.h:33
char phoneme
Definition: uspeech.h:41
int aconstant
Definition: uspeech.h:34
int micPowerThreshold
Definition: uspeech.h:39
int shconstant
Definition: uspeech.h:36
int fconstant
Definition: uspeech.h:32
void sample()
Definition: signal.cpp:35