0

I'm using pocketshpinx for speech recognition in a custom C++ application. I noticed that sometimes the hypothesis string returned by the ps_get_hyp() method is an empty string.

Question: Is this an expected behaviour? If so, is there a way to tell pocketsphinx to not give the empty string as a hypothesis?

Following is a snippet of the relevant portion of my code:

do { ReadAudioBuffer(); } while (!in_speech);
while (in_speech) { ReadAudioBuffer(); }

ps_end_utt(ps);
hyp = ps_get_hyp(ps, NULL);

The ReadAudioBuffer() method:

void SpeechRecognizer::ReadAudioBuffer()
{
    if ((k = ad_read(ad, adbuf, 2048)) < 0)
    {
        UE_LOG(LogTemp, Warning, TEXT("Failed to read audio\n"));
        return;
    }

    ps_process_raw(ps, adbuf, k, FALSE, FALSE);
    in_speech = ps_get_in_speech(ps);
    FPlatformProcess::Sleep(0.005);
}
jithinpt
  • 1,204
  • 2
  • 16
  • 33

1 Answers1

1

Question: Is this an expected behaviour?

There is nothing wrong with it

If so, is there a way to tell pocketsphinx to not give the empty string as a hypothesis?

If you said nothing what should be returned then?

FPlatformProcess::Sleep(0.005);

Sleep is not really needed here

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
  • Thanks for the reply. Regarding your qn 'If you said nothing what should be returned then?' : I would like it to wait until I say a word. The speech recognition in my app is done in a background thread in the application. So even if it keeps running for a long time, it wont affect the responsiveness of the app. I would like it to wait until I say a word present in the dictionary. Is that possible? – jithinpt May 27 '15 at 00:49
  • Adding to the previous comment, my understanding was that the function ps_get_in_speech() would return true only when the user has uttered a word. If the user remains silent, it should return false, right? Or did I understand it incorrectly? – jithinpt May 27 '15 at 00:50
  • Not necessary, it might accidentally start decoding on short noises like UM or cough. The final decision is for decoder. The detection for the word is implemented with keyword spotting, there are many examples here. – Nikolay Shmyrev May 27 '15 at 08:24
  • Thanks Nikolay! Regarding the last statement in your comment, did you mean to paste a link in there: "there are many examples here...". Are there any code snippet examples that perform keyword spotting with pocketsphinx? – jithinpt May 29 '15 at 19:31