From 8e5d6f48383cd0774b0f261981cf5d75b3270835 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 9 Jul 2013 09:39:46 +0800 Subject: [PATCH 01/26] Improving vowel detection --- uspeech.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uspeech.h b/uspeech.h index ee7b7b5..e6c8f8e 100755 --- a/uspeech.h +++ b/uspeech.h @@ -37,9 +37,10 @@ class signal{ private: int pin; int mil; + int maxPos; bool silence; void formantAnal(); //Todo: Remove }; -#endif \ No newline at end of file +#endif From 494fa231b2b1bf8a42995b7687e6ac92247dd5f3 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 9 Jul 2013 10:03:40 +0800 Subject: [PATCH 02/26] Added private zeroCrossingSearch method --- uspeech.h | 1 + 1 file changed, 1 insertion(+) diff --git a/uspeech.h b/uspeech.h index e6c8f8e..990d3e8 100755 --- a/uspeech.h +++ b/uspeech.h @@ -40,6 +40,7 @@ class signal{ int maxPos; bool silence; void formantAnal(); //Todo: Remove + void zeroCrossingSearch(); }; From 6f6caf8a1bc3c449e9f73f6cca24602fddeff5d6 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 9 Jul 2013 10:04:56 +0800 Subject: [PATCH 03/26] Update uspeech.h --- uspeech.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uspeech.h b/uspeech.h index 990d3e8..8db5473 100755 --- a/uspeech.h +++ b/uspeech.h @@ -1,5 +1,5 @@ /* - uspeech v.1.9.3 (2.0betaRC2) + uspeech v.3.0Alpha1 2012 Arjo Chakravarty uspeech is a library that allows sounds to be classified into certain phonemes From 7fdd34e284d69cbfcdc3b39e7be5d4e342e5144d Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 9 Jul 2013 10:11:08 +0800 Subject: [PATCH 04/26] Declared AVG power --- uspeech.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uspeech.h b/uspeech.h index 8db5473..0c41f6f 100755 --- a/uspeech.h +++ b/uspeech.h @@ -20,7 +20,8 @@ class signal{ signal(int port); int micPower; void sample(); - unsigned int maxPower(); + unsigned int maxPower(); + unsigned int avgPower(); //Todo: Implement unsigned int power(); unsigned int complexity(int power); unsigned long fpowerex(int sum, int xtra); //Todo: Remove From fa7328015b48fd865878e63776787431167a8c34 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 9 Jul 2013 10:12:30 +0800 Subject: [PATCH 05/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11040e3..39b4ef5 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ uSpeech library ============== - +This is branch is the 3.0 release sandbox. It is currently vaporware unless you wish to contribute. The uSpeech library provides an interface for voice recognition using the Arduino. It currently produces phonemes, often the library will produce junk phonemes. Please bare with it for the time being. A noise removal function is underway. ##Minimum Requirements ## The library is quite intensive on the processor. Each sample collection takes about 3.2 milliseconds so pay close attention to the time. The library has been tested on the Arduino Uno (ATMega32). Each signal object uses up 160bytes. No real time scheduler should be used with this. From 963c3864f2c7280fe0331cd4e7b1d7b880d0d5fb Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 9 Jul 2013 10:24:09 +0800 Subject: [PATCH 06/26] changed avgPower() to property for optimization --- uspeech.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uspeech.h b/uspeech.h index 0c41f6f..32fb798 100755 --- a/uspeech.h +++ b/uspeech.h @@ -17,11 +17,11 @@ class signal{ public: int arr[32]; int calib; + unsigned int avgPower; //Todo: Implement in maxPower (for optimization) signal(int port); - int micPower; + int micPower; void sample(); unsigned int maxPower(); - unsigned int avgPower(); //Todo: Implement unsigned int power(); unsigned int complexity(int power); unsigned long fpowerex(int sum, int xtra); //Todo: Remove From 0a06922996caf90ba467ffa18c5c1bc677fc87e7 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 10 Jul 2013 11:22:36 +0800 Subject: [PATCH 07/26] Added avgPower method; AVGpower is used for zerocrossing point --- signal.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/signal.cpp b/signal.cpp index a71ea63..c9ca9f0 100755 --- a/signal.cpp +++ b/signal.cpp @@ -77,7 +77,9 @@ unsigned int signal::maxPower(){ max = abs(arr[i]); } i++; + avgPower+=arr[i]; } + avgPower /= 32; return max; } int signal::snr(int power){ From f652b677dd57114f02a0de373d763720cfeb790a Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 10 Jul 2013 11:25:29 +0800 Subject: [PATCH 08/26] added F_CONSTANT for improved usability --- uspeech.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uspeech.h b/uspeech.h index 32fb798..7cd7b3e 100755 --- a/uspeech.h +++ b/uspeech.h @@ -13,11 +13,12 @@ #include #define SILENCE 92 #define F_DETECTION 3 +#define F_CONSTANT 37 class signal{ public: int arr[32]; int calib; - unsigned int avgPower; //Todo: Implement in maxPower (for optimization) + unsigned int avgPower; signal(int port); int micPower; void sample(); From d8ba13079774796514aab111734d50a43b14f83b Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 10 Jul 2013 11:38:58 +0800 Subject: [PATCH 09/26] private var vowelRatio added --- uspeech.h | 1 + 1 file changed, 1 insertion(+) diff --git a/uspeech.h b/uspeech.h index 7cd7b3e..710871d 100755 --- a/uspeech.h +++ b/uspeech.h @@ -43,6 +43,7 @@ class signal{ bool silence; void formantAnal(); //Todo: Remove void zeroCrossingSearch(); + int vowelRatio; }; From 25fa0d148972117da012939ded6a53ce9a63c073 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 10 Jul 2013 11:40:02 +0800 Subject: [PATCH 10/26] Added private zeroCrossingSearch method implementation --- signal.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/signal.cpp b/signal.cpp index c9ca9f0..643358c 100755 --- a/signal.cpp +++ b/signal.cpp @@ -75,6 +75,7 @@ unsigned int signal::maxPower(){ while (i<32){ if(max0){ + prev = arr[i]-avgPower; + if(prev<0){ + lower = i; + i = 33; //Break out of loop + } + i--; + } + vowelRatio = (upper-i)*100/lower-i; +} From e78fdc70e436acf553254bb560f7449b38001496 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Thu, 11 Jul 2013 18:12:42 +0800 Subject: [PATCH 11/26] updated for easier use --- phoneme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phoneme.cpp b/phoneme.cpp index 0583e08..0b92195 100755 --- a/phoneme.cpp +++ b/phoneme.cpp @@ -26,7 +26,7 @@ char signal::getPhoneme(){ micPower = 0.05 * maxPower() + (1 - 0.05) * micPower; //Serial.println(micPower)//If you are having trouble with fs - if (micPower > 37/*Replace this value (37) with your own*/) { + if (micPower > F_CONSTANT){/*Replace this value (37) with your own*/) { return 'f'; } #endif From 8b8cf09eb013ff5c6bb1b04bd073c48bc6842786 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Thu, 11 Jul 2013 18:15:16 +0800 Subject: [PATCH 12/26] Fixed compile error --- phoneme.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phoneme.cpp b/phoneme.cpp index 0b92195..c1027a6 100755 --- a/phoneme.cpp +++ b/phoneme.cpp @@ -26,12 +26,13 @@ char signal::getPhoneme(){ micPower = 0.05 * maxPower() + (1 - 0.05) * micPower; //Serial.println(micPower)//If you are having trouble with fs - if (micPower > F_CONSTANT){/*Replace this value (37) with your own*/) { + if (micPower > F_CONSTANT/*Use the header file to change this*/) { return 'f'; } #endif //Twiddle with the numbers here if your getting false triggers //This is the main recognizer part + //Todo: use move values to header file if(coeff<30 && coeff>20){ return 'u'; } From ef5b84b4ff00974585e6aaba6451bc9db1165352 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 6 Aug 2013 15:30:37 +0800 Subject: [PATCH 13/26] Clean up: removed unessecary moving average filters --- formant.cpp | 63 ----------------------------------------------------- phoneme.cpp | 13 +---------- uspeech.h | 17 +++++---------- 3 files changed, 6 insertions(+), 87 deletions(-) delete mode 100755 formant.cpp diff --git a/formant.cpp b/formant.cpp deleted file mode 100755 index 9c0e2ce..0000000 --- a/formant.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "uspeech.h" - -void signal::voiceFormants(){ - unsigned int j; - filters[0] = fpowerex(25,0); //400 - j+= filters[0]; - filters[1] = fpowerex(16,6)-j; //600 - j+= filters[1]; - filters[2] = fpowerex(12,5)-j; //800 - j+= filters[2]; - filters[3] = fpowerex(10,0)-j; //1000 - j+= filters[3]; - filters[4] = fpowerex(8,3)-j; //1200 - j+= filters[4]; - filters[5] = fpowerex(7,1)-j; //1400 - j+= filters[5]; - filters[6] = fpowerex(6,3)-j; //1600 - j+= filters[6]; - filters[7] = fpowerex(5,5)-j; //1800 - j+= filters[7]; - filters[8] = fpowerex(5,0)-j; //2000 - j+= filters[8]; - filters[9] = fpowerex(4,5)-j; //2200 - j+= filters[9]; - filters[10] = fpowerex(4,0)-j; //2400 - j+= filters[10]; - filters[11] = fpowerex(3,8)-j; //2600 - j+= filters[11]; - filters[12] = fpowerex(3,5)-j; //2800 - j+= filters[12]; - filters[13] = fpowerex(3,3)-j; //3000 - j+= filters[13]; - filters[14] = fpowerex(2,9)-j; //3200 - j+= filters[14]; - filters[15] = fpowerex(2,7)-j; //3400 - j+= filters[15]; - filters[16] = fpowerex(2,6)-j; //3600 - j+= filters[16]; - filters[17] = fpowerex(2,5)-j; //3800 - j+= filters[17]; -} -void signal::debugPrintFilter(){ - int i = 0; - while(i<18){ - Serial.println(filters[i]); - i++; - } - Serial.println("-----"); -} - -int signal::goertzel(int freq){ -freq = freq/100000; -int s_prev = 0 ; -int s_prev2 = 0 ; -int coeff = 2 * cos(2 * 3.14 * freq) ; -for(int i = 2; i < 32; i++){ - int s = arr[i] + coeff *s_prev - s_prev2 ; - s_prev2 = s_prev ; - s_prev = s ; -} -return s_prev2 * s_prev2 + s_prev * s_prev - coeff * s_prev * s_prev2 ; - -} diff --git a/phoneme.cpp b/phoneme.cpp index c1027a6..6f78ee0 100755 --- a/phoneme.cpp +++ b/phoneme.cpp @@ -69,15 +69,4 @@ char signal::getPhoneme(){ return ' '; } } -void signal::formantAnal(){ - int i = 0; - int k = 0; - while(i<18){ - if((long)(filters[i]-filters[i-1]) > 0 & (long)(filters[i]-filters[i+1]) < 0){ - if(k < 3){ - formants[k] = i; - } - } - i++; - } -} + diff --git a/uspeech.h b/uspeech.h index 710871d..e1c88f8 100755 --- a/uspeech.h +++ b/uspeech.h @@ -1,5 +1,5 @@ /* - uspeech v.3.0Alpha1 + uspeech v.1.9.3 (2.0betaRC2) 2012 Arjo Chakravarty uspeech is a library that allows sounds to be classified into certain phonemes @@ -11,40 +11,33 @@ #include "Arduino.h" #include -#define SILENCE 92 +#define SILENCE 1500 #define F_DETECTION 3 -#define F_CONSTANT 37 class signal{ public: int arr[32]; int calib; - unsigned int avgPower; signal(int port); - int micPower; + int micPower; void sample(); - unsigned int maxPower(); + unsigned int maxPower(); unsigned int power(); unsigned int complexity(int power); unsigned long fpowerex(int sum, int xtra); //Todo: Remove int snr(int power); void calibrate(); - unsigned long filters[18], formants[3], intoned; //Todo: Remove unsigned int overview[7]; char getPhoneme(); void debugPrintFilter(); //Todo: Remove - void voiceFormants(); //Todo: Remove //void lowPass(int freq); Todo: Implement moving average low pass filter. int goertzel(int freq); private: int pin; int mil; - int maxPos; bool silence; void formantAnal(); //Todo: Remove - void zeroCrossingSearch(); - int vowelRatio; }; -#endif +#endif \ No newline at end of file From ddec907b09df57d0bf97dff91b7a85d6542ed0bd Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 6 Aug 2013 15:33:53 +0800 Subject: [PATCH 14/26] re-introduced new methods --- uspeech.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uspeech.h b/uspeech.h index e1c88f8..7852473 100755 --- a/uspeech.h +++ b/uspeech.h @@ -13,6 +13,7 @@ #include #define SILENCE 1500 #define F_DETECTION 3 +#define F_CONSTANT 37 class signal{ public: int arr[32]; @@ -37,6 +38,7 @@ class signal{ int mil; bool silence; void formantAnal(); //Todo: Remove + int vowelRatio; }; From a5bba1c317dc8dc60d36fddfde2d07ffcd18c21f Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 6 Aug 2013 15:37:23 +0800 Subject: [PATCH 15/26] Fixing more compile errors; Bloody ubuntu one! --- signal.cpp | 2 +- uspeech.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/signal.cpp b/signal.cpp index 643358c..03e5b05 100755 --- a/signal.cpp +++ b/signal.cpp @@ -93,7 +93,7 @@ int signal::snr(int power){ return sqrt(j/mean)/power; } void signal::zeroCrossingSearch(){ - int i=maxPos + int i=maxPos; int prev = arr[i]; int upper = 0; int lower = 0; diff --git a/uspeech.h b/uspeech.h index 7852473..8b42869 100755 --- a/uspeech.h +++ b/uspeech.h @@ -16,7 +16,7 @@ #define F_CONSTANT 37 class signal{ public: - int arr[32]; + int arr[32],avgPower; int calib; signal(int port); int micPower; @@ -32,10 +32,11 @@ class signal{ void debugPrintFilter(); //Todo: Remove //void lowPass(int freq); Todo: Implement moving average low pass filter. int goertzel(int freq); - + void zeroCrossingSearch(); private: int pin; int mil; + int maxPos; bool silence; void formantAnal(); //Todo: Remove int vowelRatio; From d716ecc6b7fc93c75ec29e9e65c9b9be15d38323 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 6 Aug 2013 15:38:24 +0800 Subject: [PATCH 16/26] Haz I forgtten teh codes? --- signal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signal.cpp b/signal.cpp index 03e5b05..7a5b8ce 100755 --- a/signal.cpp +++ b/signal.cpp @@ -105,7 +105,7 @@ void signal::zeroCrossingSearch(){ } i++; } - int i=maxPos; + i=maxPos; while (i>0){ prev = arr[i]-avgPower; if(prev<0){ From 5db11548cbeedab2df58f97521113c085a6092f1 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 6 Aug 2013 15:41:10 +0800 Subject: [PATCH 17/26] unimportant stuff --- uspeech.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uspeech.h b/uspeech.h index 8b42869..d8df05e 100755 --- a/uspeech.h +++ b/uspeech.h @@ -1,5 +1,5 @@ /* - uspeech v.1.9.3 (2.0betaRC2) + uspeech v.3.0Alpha 2012 Arjo Chakravarty uspeech is a library that allows sounds to be classified into certain phonemes From ea8b59e483ff71f1d28923ec9769e11e12975607 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 6 Aug 2013 15:58:20 +0800 Subject: [PATCH 18/26] reset buffer if silent --- phoneme.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/phoneme.cpp b/phoneme.cpp index 6f78ee0..63b097d 100755 --- a/phoneme.cpp +++ b/phoneme.cpp @@ -66,6 +66,7 @@ char signal::getPhoneme(){ } } else{ + micPower = 0; return ' '; } } From 25c6d684881a9b7e4ea06ca40a18c8fb6a8dd19a Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 6 Aug 2013 16:01:55 +0800 Subject: [PATCH 19/26] added 'power' keyword for better integration into IDE --- keywords.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/keywords.txt b/keywords.txt index dcd9a5e..58acaf8 100755 --- a/keywords.txt +++ b/keywords.txt @@ -14,6 +14,7 @@ getPhoneme KEYWORD2 snr KEYWORD2 sample KEYWORD2 calibrate KEYWORD2 +power KEYWORD2 ####################################### # Instances (KEYWORD2) ####################################### From 65166ed7b62be1b341d12de0dd7f0775c132276e Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 6 Aug 2013 16:09:28 +0800 Subject: [PATCH 20/26] revealed coeff to public, for testing purposes --- phoneme.cpp | 1 + uspeech.h | 1 + 2 files changed, 2 insertions(+) diff --git a/phoneme.cpp b/phoneme.cpp index 63b097d..c221ae1 100755 --- a/phoneme.cpp +++ b/phoneme.cpp @@ -21,6 +21,7 @@ char signal::getPhoneme(){ f++; } coeff /= 7; + testCoeff = coeff; //Serial.println(coeff); //Use this for debugging #if F_DETECTION > 0 micPower = 0.05 * maxPower() + (1 - 0.05) * micPower; diff --git a/uspeech.h b/uspeech.h index d8df05e..4f3a6c9 100755 --- a/uspeech.h +++ b/uspeech.h @@ -18,6 +18,7 @@ class signal{ public: int arr[32],avgPower; int calib; + int testCoeff; signal(int port); int micPower; void sample(); From ea196dd48f4b9c26560ab96fe1a683fef5236183 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 7 Aug 2013 17:53:04 +0800 Subject: [PATCH 21/26] updated installation sketches for easier use. --- .../examples/Calibration/Calibration.ino | 12 ---- .../examples/Debug_uSpeech/Debug_uSpeech.ino | 33 +++++++++++ .../_SpeechAdvancedTraining.ino | 58 ------------------- 3 files changed, 33 insertions(+), 70 deletions(-) delete mode 100755 installation/examples/Calibration/Calibration.ino create mode 100644 installation/examples/Debug_uSpeech/Debug_uSpeech.ino delete mode 100644 installation/examples/_SpeechAdvancedTraining/_SpeechAdvancedTraining.ino diff --git a/installation/examples/Calibration/Calibration.ino b/installation/examples/Calibration/Calibration.ino deleted file mode 100755 index 55903bb..0000000 --- a/installation/examples/Calibration/Calibration.ino +++ /dev/null @@ -1,12 +0,0 @@ -#include -signal voice(A0); -void setup(){ - voice.calibrate(); - Serial.begin(9600); -} -void loop(){ - //Serial.println(voice.getPhoneme()); - voice.sample(); - Serial.println(voice.power()); - -} diff --git a/installation/examples/Debug_uSpeech/Debug_uSpeech.ino b/installation/examples/Debug_uSpeech/Debug_uSpeech.ino new file mode 100644 index 0000000..80e70b6 --- /dev/null +++ b/installation/examples/Debug_uSpeech/Debug_uSpeech.ino @@ -0,0 +1,33 @@ +#include +signal voice(A0); +char option = 0; +void setup(){ + voice.calibrate(); + Serial.begin(9600); +} +void loop(){ + voice.sample(); + char c=voice.getPhoneme(); + if(option==0){ + Serial.println("uSpeech debug tool--------"); + Serial.println(" Press 'a' if you wish to calibrate/check the f algorithm"); + Serial.println(" Press 'b' if you wish to calibrate/check the getPhoneme"); + Serial.println(" Press 'c' if you wish to calibrate/check the volume of your microphone"); + option = 1; + } + if(option==1){ + if (Serial.available() > 0) { + // read the incoming byte: + option = Serial.read(); + } + } + if(option=='a'){ + Serial.println(voice.micPower); + } + if(option=='b'){ + Serial.println(c); + } + if(option=='c'){ + Serial.println(voice.power()); + } +} diff --git a/installation/examples/_SpeechAdvancedTraining/_SpeechAdvancedTraining.ino b/installation/examples/_SpeechAdvancedTraining/_SpeechAdvancedTraining.ino deleted file mode 100644 index 89bdd8a..0000000 --- a/installation/examples/_SpeechAdvancedTraining/_SpeechAdvancedTraining.ino +++ /dev/null @@ -1,58 +0,0 @@ -#include - -signal voice(A0); -int around = 0; -int maxp = 0; -void setup(){ - voice.calibrate(); - Serial.begin(9600); -} -void loop(){ - voice.sample(); - if(around == 0){ - Serial.println("please remain silent"); - } - else{ - if(around < 2000){ - if(voice.power()>maxp){ - maxp = voice.power(); - } - } - else{ - if(around == 2000){ - Serial.print("SILENCE is"); - Serial.print(maxp); - Serial.println("Please say ffff"); - maxp = 0; - } - else{ - if(around < 8000){ - voice.getPhoneme(); - if(maxpvoice.micPower){ - maxp = voice.micPower; - } - } - if(around==12000){ - Serial.print("f2 ="); - Serial.print(maxp); - } - } - } - } - } - } - around++; -} From d89124051d8205ed9ca9b313f44b621251fb4c2d Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 7 Aug 2013 18:04:10 +0800 Subject: [PATCH 22/26] moved vowelRatio to public --- uspeech.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/uspeech.h b/uspeech.h index 4f3a6c9..7de953f 100755 --- a/uspeech.h +++ b/uspeech.h @@ -13,7 +13,7 @@ #include #define SILENCE 1500 #define F_DETECTION 3 -#define F_CONSTANT 37 +#define F_CONSTANT 380 class signal{ public: int arr[32],avgPower; @@ -29,10 +29,9 @@ class signal{ int snr(int power); void calibrate(); unsigned int overview[7]; - char getPhoneme(); - void debugPrintFilter(); //Todo: Remove - //void lowPass(int freq); Todo: Implement moving average low pass filter. + char getPhoneme(); //void lowPass(int freq); Todo: Implement moving average low pass filter. int goertzel(int freq); + int vowelRatio; void zeroCrossingSearch(); private: int pin; @@ -40,7 +39,7 @@ class signal{ int maxPos; bool silence; void formantAnal(); //Todo: Remove - int vowelRatio; + }; From 6dfac75a9aef6734a396d427f5599a4bef9f2a70 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 7 Aug 2013 18:05:23 +0800 Subject: [PATCH 23/26] added ability to detect vowels --- phoneme.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/phoneme.cpp b/phoneme.cpp index c221ae1..aa3c0ca 100755 --- a/phoneme.cpp +++ b/phoneme.cpp @@ -31,6 +31,7 @@ char signal::getPhoneme(){ return 'f'; } #endif + zeroCrossingSearch(); //Twiddle with the numbers here if your getting false triggers //This is the main recognizer part //Todo: use move values to header file From 32df6849aada9137c69894705b8008ca270512af Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Thu, 8 Aug 2013 13:57:11 +0800 Subject: [PATCH 24/26] updated debug test --- installation/examples/Debug_uSpeech/Debug_uSpeech.ino | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/installation/examples/Debug_uSpeech/Debug_uSpeech.ino b/installation/examples/Debug_uSpeech/Debug_uSpeech.ino index 80e70b6..28765c6 100644 --- a/installation/examples/Debug_uSpeech/Debug_uSpeech.ino +++ b/installation/examples/Debug_uSpeech/Debug_uSpeech.ino @@ -13,6 +13,8 @@ void loop(){ Serial.println(" Press 'a' if you wish to calibrate/check the f algorithm"); Serial.println(" Press 'b' if you wish to calibrate/check the getPhoneme"); Serial.println(" Press 'c' if you wish to calibrate/check the volume of your microphone"); + Serial.println(" Press 'd' if you wish to calibrate/check the coeff"); + Serial.println(" Press 'e' if you wish to calibrate/check the vowel detector"); option = 1; } if(option==1){ @@ -30,4 +32,11 @@ void loop(){ if(option=='c'){ Serial.println(voice.power()); } -} + if(option=='d'){ + Serial.println(voice.testCoeff); + } + if(option=='e'){ + + Serial.println(voice.vowelRatio); + } +} \ No newline at end of file From fbd6da9545ffa81b1fc149c2cd3f6e9e207aac6d Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 13 Aug 2013 19:59:50 +0800 Subject: [PATCH 25/26] Couple of optimization tricks --- phoneme.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/phoneme.cpp b/phoneme.cpp index aa3c0ca..72e4770 100755 --- a/phoneme.cpp +++ b/phoneme.cpp @@ -4,9 +4,12 @@ */ char signal::getPhoneme(){ sample(); - if(power()>SILENCE){ + unsigned int pp =power(); + if(pp>SILENCE){ + //Low pass filter for noise removal - int k = complexity(power()); + int k = complexity(pp); + overview[6] = overview[5]; overview[5] = overview[4]; overview[4] = overview[3]; @@ -26,13 +29,12 @@ char signal::getPhoneme(){ #if F_DETECTION > 0 micPower = 0.05 * maxPower() + (1 - 0.05) * micPower; //Serial.println(micPower)//If you are having trouble with fs - if (micPower > F_CONSTANT/*Use the header file to change this*/) { return 'f'; } #endif zeroCrossingSearch(); - //Twiddle with the numbers here if your getting false triggers + //Twiddle with the numbers here if your getting false triggers //This is the main recognizer part //Todo: use move values to header file if(coeff<30 && coeff>20){ From 71a93f3e09baa32353e570a3fa6d7d7c82c5ccd2 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 13 Aug 2013 20:00:08 +0800 Subject: [PATCH 26/26] fixed perpetual loop --- signal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signal.cpp b/signal.cpp index 7a5b8ce..6e4df0c 100755 --- a/signal.cpp +++ b/signal.cpp @@ -110,7 +110,7 @@ void signal::zeroCrossingSearch(){ prev = arr[i]-avgPower; if(prev<0){ lower = i; - i = 33; //Break out of loop + i = 0; //Break out of loop } i--; }