Removing zero silence, seems like Sphinx doesn't like it
See http://cmusphinx.sourceforge.net/wiki/faq#qwhy_my_accuracy_is_poor I couldn't reproduce the original problem, but it doesn't seem to hurt, either.
This commit is contained in:
parent
31cb3b195c
commit
0f33fcfbd0
|
@ -90,10 +90,20 @@ void processAudioStream(AudioStream& audioStream16kHzMono, ps_decoder_t& recogni
|
||||||
do {
|
do {
|
||||||
// Read to buffer
|
// Read to buffer
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
|
int16_t lastSample = INT16_MIN;
|
||||||
while (buffer.size() < capacity) {
|
while (buffer.size() < capacity) {
|
||||||
float sample;
|
// Read sample
|
||||||
if (!audioStream16kHzMono.getNextSample(sample)) break;
|
float floatSample;
|
||||||
buffer.push_back(floatSampleToInt16(sample));
|
if (!audioStream16kHzMono.getNextSample(floatSample)) break;
|
||||||
|
int16_t sample = floatSampleToInt16(floatSample);
|
||||||
|
|
||||||
|
// Remove zero silence (see http://cmusphinx.sourceforge.net/wiki/faq#qwhy_my_accuracy_is_poor)
|
||||||
|
if (sample == lastSample) {
|
||||||
|
sample += (sample < INT16_MAX) ? 1 : -1;
|
||||||
|
}
|
||||||
|
lastSample = sample;
|
||||||
|
|
||||||
|
buffer.push_back(sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analyze buffer
|
// Analyze buffer
|
||||||
|
|
Loading…
Reference in New Issue