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

Commit

Permalink
Merge pull request #11 from arjo129/3.0-workingBranch
Browse files Browse the repository at this point in the history
Release V2.1
  • Loading branch information
arjo129 committed Sep 7, 2013
2 parents 6e8b13c + 71a93f3 commit 1d78327
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 160 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
63 changes: 0 additions & 63 deletions formant.cpp

This file was deleted.

12 changes: 0 additions & 12 deletions installation/examples/Calibration/Calibration.ino

This file was deleted.

42 changes: 42 additions & 0 deletions installation/examples/Debug_uSpeech/Debug_uSpeech.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <uspeech.h>
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");
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){
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());
}
if(option=='d'){
Serial.println(voice.testCoeff);
}
if(option=='e'){

Serial.println(voice.vowelRatio);
}
}

This file was deleted.

1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ getPhoneme KEYWORD2
snr KEYWORD2
sample KEYWORD2
calibrate KEYWORD2
power KEYWORD2
#######################################
# Instances (KEYWORD2)
#######################################
Expand Down
29 changes: 12 additions & 17 deletions phoneme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -21,17 +24,19 @@ 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;
//Serial.println(micPower)//If you are having trouble with fs

if (micPower > 37/*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
zeroCrossingSearch();
//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';
}
Expand Down Expand Up @@ -65,18 +70,8 @@ char signal::getPhoneme(){
}
}
else{
micPower = 0;
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++;
}
}

27 changes: 27 additions & 0 deletions signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ unsigned int signal::maxPower(){
while (i<32){
if(max<abs(arr[i])){
max = abs(arr[i]);
maxPos = i;
}
i++;
avgPower+=arr[i];
}
avgPower /= 32;
return max;
}
int signal::snr(int power){
Expand All @@ -89,3 +92,27 @@ int signal::snr(int power){
}
return sqrt(j/mean)/power;
}
void signal::zeroCrossingSearch(){
int i=maxPos;
int prev = arr[i];
int upper = 0;
int lower = 0;
while (i<32){
prev = arr[i]-avgPower;
if(prev<0){
upper = i;
i = 33; //Break out of loop
}
i++;
}
i=maxPos;
while (i>0){
prev = arr[i]-avgPower;
if(prev<0){
lower = i;
i = 0; //Break out of loop
}
i--;
}
vowelRatio = (upper-i)*100/lower-i;
}
19 changes: 10 additions & 9 deletions uspeech.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,12 +11,14 @@

#include "Arduino.h"
#include <math.h>
#define SILENCE 92
#define SILENCE 1500
#define F_DETECTION 3
#define F_CONSTANT 380
class signal{
public:
int arr[32];
int arr[32],avgPower;
int calib;
int testCoeff;
signal(int port);
int micPower;
void sample();
Expand All @@ -26,19 +28,18 @@ class signal{
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.
char getPhoneme(); //void lowPass(int freq); Todo: Implement moving average low pass filter.
int goertzel(int freq);

int vowelRatio;
void zeroCrossingSearch();
private:
int pin;
int mil;
int maxPos;
bool silence;
void formantAnal(); //Todo: Remove

};


Expand Down

0 comments on commit 1d78327

Please sign in to comment.