Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/arjo129/uSpeech
Browse files Browse the repository at this point in the history
Conflicts:
	vocab.cpp
  • Loading branch information
arjo129 committed Feb 23, 2014
1 parent b448c60 commit 82299d3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 12 deletions.
4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Copyright (C) 2012-2013 Arjo Chakravarty
Copyright (C) 2012-2014 Arjo Chakravarty

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 changes: 31 additions & 0 deletions statcollector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "uspeech.h"

statCollector::statCollector(){
n=0;mean=0;M2=0;M3=0;M4=0;
}
int statCollector::_mean(){
return mean;
}
int statCollector::stdev(){
return M2;
}
int statCollector::kurtosis(){
int kurtosis = (n*M4) / (M2*M2) - 3;
return kurtosis;
}
int statCollector::skew(){
int kurtosis = (n*M3) / (M2*M2*M2) - 3;
return kurtosis;
}
void statCollector::collect(int x) {
int n1 = n;
n = n + 1;
int delta = x - mean;
int delta_n = delta / n;
int delta_n2 = delta_n * delta_n;
int term1 = delta * delta_n * n1;
mean = mean + delta_n;
M4 = M4 + term1 * delta_n2 * (n*n - 3*n + 3) + 6 * delta_n2 * M2 - 4 * delta_n * M3;
M3 = M3 + term1 * delta_n * (n - 2) - 3 * delta_n * M2;
M2 = M2 + term1;
}
40 changes: 30 additions & 10 deletions uspeech.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
uspeech v.4.x.x
2012 Arjo Chakravarty
2012-2014 Arjo Chakravarty
uspeech is a library that allows sounds to be classified into certain phonemes
on the Arduino. This creates a simple beginning for a full scale voice recognition
Expand All @@ -20,6 +20,9 @@
#define F_DETECTION 3
#define F_CONSTANT 350

/**
* The main recognizer class
*/
class signal{
public:
int arr[32]; /*!< This is the audio buffer*/
Expand All @@ -35,7 +38,7 @@ class signal{
int amplificationFactor; /*!<Amplification factor: Adjust as you need*/
int micPowerThreshold; /*!< Ignore anything with micPower below this */
int scale;
char phoneme; /*!< the phoneme detected when f was returned */
char phoneme; /*!< The phoneme detected when f was returned */
signal(int port);
int micPower;
void sample();
Expand All @@ -54,16 +57,33 @@ class signal{
unsigned int complexity(int power);
};

class statCollector {
public:
//Note: May be necessary to change to double type.
int n,mean,M2,M3,M4;
statCollector();
int kurtosis();
int skew();
int _mean();
int stdev();
void collect(int x);

};

/**
* Simple Accumulator Vector. Stores simple syllables. Useful for basic word recognition.
*/
class syllable{
public:
int f,e,o,s,h,v;
syllable();
void classify(char c);
int* tointptr();
#if ARDUINO_ENVIRONMENT > 0
void debugPrint();
int f,e,o,s,h,v; /*!< Accumulators for the stated characters */
syllable(); /*!< Constructor for the class*/
void reset(); /*!< Resets the accumulator so a new syllable can be formed. Call this when you detect silence*/
void classify(char c);
int* tointptr(); /*!< Returns the vector from the accumulators as an integer pointer */
void reset(); /*!< Resets Accumulator*/
#if ARDUINO_ENVIRONMENT > 0
void debugPrint(); /*!< Outputs the datain the accumulator vector. Only enabled for arduino.*/
#endif

};

//TODO: implement statistics classes.
#endif

0 comments on commit 82299d3

Please sign in to comment.