next up previous contents index
Next: 3.5 Recognition Up: 3 Using HAPI: An Example Application Previous: 3.3 Initialisation

3.4 User interaction

 

In the initial application user interaction is kept to a minimum. Apart from indicating that the recogniser should start processing the next utterance, the only interaction with the user is calibrating the speech detector (when it is used).

This calibration procedure will probably be the first time the user has interacted with the recogniser and it gives the user an opportunity to verify that the audio system is set up correctly.

    There are two functions in HAPI for calibrating the speech detector. Both operate on a source object, when the source object is not a direct audio device or when the speech detector is not being used these functions do nothing. The functions differ in that one ( hapiSourceCalibrateSilence) expects a few seconds of silence whilst the other (hapiSourceCalibrateSpeech) expects a mixture of speech and silence. Although using the second of these functions requires that the user say something, it does allow the average speech level to be measured. This allows the user to verify that audio system is functioning correctly and that the signal-to-noise ratio is high enough to ensure that the recogniser will operate accurately.

int CalibrateInput(ApplicationHAPIInfo *ahi, int wait)
{
   char buf[STR_LEN];
   int fail,needed;
   float levels[HAPI_CAL_size];
   
   fail = ((needed=hapiSourceCalibrateSpeech(ahi->source,NULL))<0);
   if (!fail && needed>0) {
      /* Now need to set up for interaction */
      /* This application doesn't have any fancy interface so its printf !! */
      printf(" Recogniser calibration:\n\n");
      printf("  If the mean speech level isn't 20-40dB higher than silence\n");
      printf("   level please check the audio system and try again\n\n");
      
      /* Now we will measure then display the speech levels */
      if (wait) {
         printf("Press return to measure speech levels\n");
         gets(buf);
      }
      printf(" Now say 'She sells sea shells by the sea shore'\n");
      fail = (hapiSourceCalibrateSpeech(ahi->source,levels)<0);
      printf(" Thank you\n\n");
      printf(" Mean speech level in dBs %.2f (%.1f%%), silence %.2f\n\n",
             levels[HAPI_CAL_speech],levels[HAPI_CAL_peak]*100.0,
             levels[HAPI_CAL_background]);
   }
   fail = ((needed=hapiSourceCalibrateSilence(ahi->source,NULL))<0);
   if (!fail && needed>0) {
      printf(" Silence measurement\n\n");
      
      /* Now we will measure then display the speech levels */
      if (wait) {
         printf("Press return to measure silence\n");
         gets(buf);
      }
      printf("Quiet please - measuring silence\n");
      fail = (hapiSourceCalibrateSilence(ahi->source,levels)<0);
      printf(" Thank you\n\n");
      printf(" Mean silence level in dBs %.2f\n\n",
             levels[HAPI_CAL_background]);
   }
   return(!fail);
}

Apart from this calibration procedure the only other user interaction is to start the recogniser listening for the start of speech. This is done in a similar manner in the main function using gets to wait for the user to press return.


next up previous contents index
Next: 3.5 Recognition Up: 3 Using HAPI: An Example Application Previous: 3.3 Initialisation

Entropic HAPI_V1.4 email support@entropic.com