Added dynamic_energy_threshold capability
Added dynamic_energy_threshold capability

When enabled, the speech recognition is constantly re-evaluating the ambient noise and resetting the energy threshold.

There are a few pieces to this feature.
1) Make sure to set a *high* energy_threshold to start or the energy_threshold will trigger entering the phrase state before the ambient noise floor can be evaluated. (2000 worked for me)
2) dynamic_energy_threshold_decay (0.0-1.0) is the rate at which the energy_threshold chases the ambient noise floor. A numbers closer to 0 means that the energy_thereshold will follow more quickly. Nubmer closer to 1.0 follow more slowly
3) dynamic_energy_threshold_ratio_above_ambient. This is the "gap" between the ambient noise and the threshold. Setting to 1.0 would mean the energy_threshold will equalize at the same as ambient. 1.0 would be a bad choice as some "gap" is needed or regular fluctuations in noise will cause the recognizer to move into the phrase capturing state. I found 1.10 to work well. (The audio must exceede ambient noise by 10%).

Note: There is a useful print statement that can be added just after the re-evaluation of the energy_threshold to see teh feature in action.
print str(energy) + " " + str(ambient_energy_with_ratio) + " " + str(self.energy_threshold)

Signed-off-by: Kevin Smith <7ce65d1f81f9f4b5f8469cf322ca2d4b6aafeec9@yahoo.com>

arvindch/speech_recognition,arvindch/speech_recognition,Zenohm/speech_recognition,Uberi/speech_recognition,M4573R/speech_recognition,Python-Devs-Brasil/speech_recognition,jjsg/speech_recognition,krypten/speech_recognition,jjsg/speech_recognition,adrianzhang/speech_recognition,M4573R/speech_recognition,adrianzhang/speech_recognition,Zenohm/speech_recognition,AyabongaQwabi/speech_recognition,Uberi/speech_recognition,Python-Devs-Brasil/speech_recognition,AyabongaQwabi/speech_recognition,ListFranz/speech_recognition,krypten/speech_recognition,ListFranz/speech_recognition