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 {
|
||||
// Read to buffer
|
||||
buffer.clear();
|
||||
int16_t lastSample = INT16_MIN;
|
||||
while (buffer.size() < capacity) {
|
||||
float sample;
|
||||
if (!audioStream16kHzMono.getNextSample(sample)) break;
|
||||
buffer.push_back(floatSampleToInt16(sample));
|
||||
// Read sample
|
||||
float floatSample;
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue