Avaya Logo

Previous Topic

Next Topic

Book Contents

Book Index

Chantest using speech recognition

Chantest using speech recognition shows how chantest uses speech recognition to get caller input. This modified chantest application allows recognition during prompting, thereby requiring echo cancellation. The caller enters touch tones to indicate that input will be touch tone rather than speech. After receiving the touch-tone input, the program turns off the recognizer. The entire chantest_arc.c application is available on the system in the file /vs/examples/IRAPI/chantest_arc.c.

chantest_asr.c must include the asr grammar header file.

#include "/att/asr/grammar_hs/US.gram.h"

setTTParams() must include setting of the recognition parameters.

int setTTParmas(channel_id cid)
{ .
.
.
irSetParam(cid, IRP_TT_INTERTIME, 5000) == IRR_FAIL ||
irSetParam(cid, IRP_RECOG_PRETIME, 5000) == IRR_FAIL ||
irSetParam(cid, IRP_RECOG_TYPE, IRD_WHOLE_WORD) == IRR_FAIL ||
irSetParam(cid, IRP_RECOG_GRAMMAR, US_4dig) == IRR_FAIL ||
irSetParamStr(cid, IRP_INPUT_DELIM1, "#") == IRR_FAIL ) {
return(-1);
.
.
.

IRP_RECOG_GRAMMAR is set to US_4dig as defined in the header file included above. This grammar indicates that we are expecting to recognize exactly 4 spoken digits.

In general, the longer the echo canceler runs, the better job it does at canceling the echo from the output voice. chantest starts echo cancellation once the call is answered, allowing the echo canceler to run as long as possible before the caller is prompted. Starting the echo canceler is done asynchronously, the IRE_ECHO_START event is reported when starting the echo canceler completes. If successful, the chantest application continues by calling startChanTst().

case IRE_ANSWER_DONE:
if (ev.event_mod1 != IREM_COMPLETE) {
cleanup("Error on irAnswer", cid);
break;
}
if (irStartEcho(cid, 0) == IRR_FAIL) {
cleanup("Error in irStartEcho", cid);
break;
}


break;
case IRE_ECHO_START:
if (ev.event_mod1 == IREM_ERROR) {
cleanup("IRE_ECHO_START reports IREM_ERROR", cid);
break;
}
startChanTst(cid);
break;

Since chantest supports recognition during prompting, the recognizer must be started before the prompt is played. Prompts are queued and played from the reprompt() and playInstr() functions. Both of these functions are modified as follows:

void reprompt(channel_id cid)
{
.
.
.
if ( irStartRecog(cid,0) == IRR_FAIL ) {
cleanup("irStartRecog Error", cid);
return;
}
if (irEnd(cid, 0, 0) == IRR_FAIL) {
.
.
.
}

void playInstr(channel_id cid)
{
.
.
.
if (irStartRecog(cid,0) == IRR_FAIL) {
cleanup("irStartRecog Error", cid);
return;
}
if (irEnd(cid, 0, 0) == IRR_FAIL) {
.
.
.
}

Starting the recognizer before calling irEnd() allows the application to ensure that the recognizer is on before the prompt is played. If an attempt to start the recognizer is made after the call to irEnd() and the recognizer failed to start, the application prompts the user for input that it is not prepared to receive.

If the prompt completes before the recognition completes, the recognition timer is started. The call to irStartRecogTimer(3IRAPI) tells the recognizer that the prompt is complete and the recognition timeout, specified through the IRP_RECOG_PRETIME, now takes effect. From within the main while loop, the IRE_PLAY_DONE event for prompting is handled as follows:

case IRE_PLAY_DONE:
switch(Chl[chan].PlayDone) {
case REPROMPT_WHEN_DONE:
reprompt(cid);
break;
case START_TIMER_WHEN_DONE:
if (irCheckRecog(cid) == IRD_ON &&
irStartRecogTimer(cid) == IRR_FAIL) {
cleanup("irStartRecogTimer Failed", cid);
}
break;
.
.
.

As stated earlier, if the caller enters a touch tone, the application must switch from using recognition to using touch-tone input. Again from within the main while loop, receiving the IRE_INPUT event that only occurs for touch-tone input causes chantest to stop recognition (if on) and start the touch-tone timer.

IRE_INPUT:
if (irCheckRecog(cid) == IRR_ON) {
(void) irStopRecog(cid);
if (irStartTTTimer(cid) == IRR_FAIL) {
cleanup("Can't start TT Timer", cid);
}
}
break;

The IRE_INPUT_DONE event occurs when input has been received from the recognizer. The input_done() function now must handle recognition input while still supporting touch-tone input.

void input_done(channel_id cid, ir_event_t *evPtr)
{
switch(evPtr->event_mod1) {
case IREM_INPUT_LENGTH:
case IREM_INPUT_DELIM:
case IREM_RECOG:
Chl[chan].RetryCount = 0;
play_tt(cid);
break;
case IREM_TT_PRE:
case IREM_TT_INTER:
case IREM_RECOG_PRE:
if(Chl[chan].RetryCount++ >= 3) {

If IRE_INPUT_DONE reports input, the input is played back to the user via play_tt(). Otherwise, the retry count is increased and the script reprompts or quits as was done in the original chantest.

© 2006 Avaya Inc. All Rights Reserved.