`+----------------------------------------------------------------
`------+
`| Copyright (c) 1996-1998 Vail Systems, Inc. All Rights
`Reserved |
`+----------------------------------------------------------------
`------+
`$Id: mc_vr.c,v 1.1 1999/04/03 17:26:21 alex Exp $
`+----------------------------------------------------------------
`------+
`*/
`****************************************************************
`************
` Module : mc_vr.c
` This module holds Webley ASR code.
` HISTORICAL INFORMATION:
` 10-04-96 alex:Vail Created
`*****************************************************************
`*************/
`#include <stdio.h>
`#include <stdlib.h>
`#include <string.h>
`#include <ctype.h>
`#include <sys/types.h>
`#include <sys/timeb.h>
`#include <time.h>
`#include <dirent.h>
`#include <sys/wait.h>
`#include <sys/stat.h>
`#include <sys/ipc.h>
`#include <sys/msg.h>
`#include <rpc/rpc.h>
`#include <sys/fcntl.h>
`#include <memory.h>
`#include <setjmp.h>
`#include <unistd.h>
`#include <math.h>
`#include <errno.h>
`#include "vlib_scsa.h"
`#include "notif_scsa.h"
`#include "job.h"
`#include "parus_api.h"
`#include "app_api.h"
`
`/*
`
`1
`
`Parus Exhibit 2036
`Google, et al. v. Parus Holdings, Inc.
`IPR2020-00846
`Page 1 of 19
`
`
`
`#include "mcall.h"
`#undef DEBUG
`#define DEBUG(x) x
`static int vr_allocated = 0;
`static int nuance_flag = 0;
`static int nuance_checked = 0;
`static char nuance_package[MAX_STRING_SIZE + 1];
`static int contacts_rsrc = -1;
`static int load_contacts_flag = 0;
`static int load_corp_flag = 0;
`static int load_lists_flag = 0;
`extern int trunk_num;
`extern char app_name[];
`extern char app_home[];
`extern char msg_home[];
`extern char msg_host[];
`extern char *convertPhone();
`extern char *vr_convert();
`extern char *processPrompt();
`extern char *processIniName();
`int vrAllocNuance(int, char *);
`int vrGoNuance(char *, int *, char *, char *, int,int,struct
`VR_RES *,int,int);
`static int vrResNuance(struct VR_RES *, struct ASR_RES *, char
`*);
`static int vrGrammarDynamic(char *, char *, char *);
` ---------------------------------------------------------------
`----------- */
`int vrNuance()
`har *np;
`if (!nuance_checked) {
`nuance_checked = 1;
`np = GetConfigVar(app_name, "NUANCE");
`if (!np)
`nuance_flag = 0;
`else if (!strcmp(np, "YES") || !strcmp(np, "yes"))
`nuance_flag = 1;
`else
`nuance_flag = 0;
`eturn(nuance_flag);
`
`{c
`
`}r
`
`/*
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`int vrExit()
`{
`
`2
`
`Parus Exhibit 2036, Page 2 of 19
`
`
`
`register int ret_val;
`if (vrNuance())
`return(vrExitNuance());
`vrDealloc();
`DEBUG(printf("<%d>vrExit() ret = %d\n", trunk_num,
`ret_val));
`return 0;
`
`}/*
`
`{r
`
` ---------------------------------------------------------------
`----------- */
`int vrDealloc()
`egister int ret_val;
`if (vrNuance())
`return(vrDeallocNuance());
`if ( vr_allocated ) {
`ret_val = app_dealloc_vr_psp();
`DEBUG(printf("<%d>vrDealloc() ret = %d\n", trunk_num,
`vr_allocated = 0;
`eturn 0;
`
`ret_val));
`
`}r
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`int vrAlloc(int vr_type, char *path)
`egister int retries = 6, ret_val = R_FALSE;
`if (vrNuance())
`return(vrAllocNuance(vr_type, path));
`if ( !vr_allocated ) {
` /* Try to allocate voice recognition port */
` while (retries--) {
`
`ret_val = app_alloc_vr_psp(path);
` DEBUG(printf("<%d>vrAlloc(%d) ret = %d\n",
`trunk_num, vr_type,ret_val));
`if (ret_val == R_TRUE )
`break;
`sleep(1);
` }
` if (ret_val != R_TRUE ) {
` fprintf(stderr,"<%d>ERROR :
`vrAlloc()\n",trunk_num);
` }
`
`{r
`
`3
`
`Parus Exhibit 2036, Page 3 of 19
`
`
`
` else
` vr_allocated = vr_type;
`lse
`return R_TRUE;
` return ret_val;
`
`}e
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`static int vrCheckStatus(struct VR_RES *vtk, char *voc, char *mn)
`tatic int flag = 0;
`if (vrNuance())
`return(R_FALSE);
`fldtmf();
`DEBUG(printf("<%d>vrCheckStatus() result=%d\n", trunk_num,
`vtk[0].condition));
`switch( vtk[0].condition ) {
`case APP_VR_TIMEOUT:
`break;
`case APP_VR_INT_TIMEOUT :
` /*-->vr_too_slow
` *-->Faster please
` */
`strcpy(mn, vr_too_slow);
`break;
`case APP_VR_SPOKE_TOO_SOON:
` /*-->vr_too_soon
` *-->Sorry, I wasn't ready. Please try again.
` */
`strcpy(mn, vr_too_soon);
`break;
`case APP_VR_SPOKE_TOO_LOUD:
` /*-->vr_too_loud
` *--> Softer please
` */
`strcpy(mn, vr_too_loud);
`break;
`case APP_VR_SPOKE_TOO_SOFT:
` /*-->vr_too_soft
` *-->Louder please
` */
`strcpy(mn, vr_too_soft);
`break;
`case APP_VR_TALKED_TOO_LONG:
` /*-->vr_too_long
` *-->Please repeat, try not to speak too long
` */
`strcpy(mn, vr_too_long);
`
`{s
`
`4
`
`Parus Exhibit 2036, Page 4 of 19
`
`
`
`break;
`default:
`if ( strcmp(voc, "yncqh" ) ) {
`strcpy(mn, vp_no_result_alt);
`
`}e
`
`lse {
`return R_TRUE;
`reak;
`
`}b
`
`}r
`
`eturn R_FALSE;
`
`}/*
`
`{s
`
` ---------------------------------------------------------------
`----------- */
`int addTimeVR(int t)
`tatic int timeInVr = 0;
`if ( t > 0 )
`timeInVr += t;
`return timeInVr;
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`int speechStartTimeout(char *mode, int val)
`tatic int speechTimeout = 6;
`int ret_val;
`ret_val = speechTimeout;
`if (!strcmp(mode, "set")) {
`speechTimeout = val;
`ret_val = speechTimeout;
`lse if (!strcmp(mode, "get") ) {
`ret_val = speechTimeout;
`speechTimeout = 6;
`eturn ret_val;
`
`}e
`
`}r
`
`{s
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`int vrContPSP(char *msg, /* voice prompt filename; barge in or no
`barge in */
`int *retp,
`/* indicates if dtmf is expected on input
`and
` if a dtmf was actually entered on output
`
`5
`
`Parus Exhibit 2036, Page 5 of 19
`
`
`
`*/
`/* name of the vocabulary .lex file */
`char *voc,
`int debugFlag, /* collect voice samples in .wav if not 0
`
`*/
`
`struct VR_RES *vr_tokens,
`/* vr results structure */
`int rej, /* rejection level */
`int mode )
`/* mode: barge in or no barge in, plus fax
`termination;
`*/
`egister int i, j, ret_val = R_FALSE, rFlag = 0;
`char *p, *pmsg, buf[64], mName[128];
`char *iniPath = NULL, *iniFile, scratch[MAX_STRING_SIZE + 1];
`int flagDtmf = 0;
`int flagFax = 0;
`int tVR = 0;
`time_t BeforeRec, AfterRec;
`struct stat stat_buf;
`int effScore, score = 3;
`int len;
`if (*retp == TR_MAXDG) {
`flagDtmf++;
`retp = 0;
`if (!msg) {
` fprintf(stderr,
`"<%d>ERROR: Can't run barge through ASR without
`msg\n",
`trunk_num);
`return R_FAILURE;
`f ( rej == -2 )
`/* all recognizers */
`rej = 0;
`else if ( rej < 0 ) {
`if (vrNuance())
`/* Nuance recognizer */
`rej = 320;
`else
`/* PureSpeech recognizer */
`rej = 9;
`lse if (rej > 0 && vrNuance())
`/* Nuance recognizer */
`rej = 360;
`if ( mode & VR_FAX_TERM )
`
`6
`
`}e
`
`}*
`
`}i
`
`{r
`
`Parus Exhibit 2036, Page 6 of 19
`
`
`
`flagFax |= VR_FAX_TERM;
`if ( mode & VR_NOFLUSH )
`flagFax |= VR_NOFLUSH;
`iniFile = processIniName(voc);
`if (*voc == '/' ) {
`strncpy(scratch, voc, MAX_STRING_SIZE);
`scratch[MAX_STRING_SIZE] = 0;
`iniFile = strrchr(scratch, '/' );
`if ( iniFile ) {
`*iniFile++ = 0;
`iniPath = scratch;
`if ( ! *iniPath )
`*iniPath = '/';
` DEBUG(printf("<%d>Set ASR %s.ini path at %s\n",
`trunk_num, iniFile, iniPath ));
`
`}e
`
`lse
`
`iniFile = voc;
`f (vrNuance()) {
`if (vrAllocNuance(VR_NUANCE, NULL) != R_TRUE ) {
` fprintf(stderr, "<%d>ERROR vrAlloc(..)\n",
`trunk_num);
` return R_FAILURE;
`}
`lse {
`
`DEBUG(printf("<%d>Set ASR %s.ini path at %s; faxTerm=%
`d\n",
`trunk_num, iniFile, iniPath, flagFax ));
`if (vrAlloc(VR_PSP, iniPath) != R_TRUE) {
` fprintf(stderr, "<%d>ERROR vrAlloc(..)\n",
`trunk_num);
` return R_FAILURE;
`}
`msg = msg;
`while (1) {
`*retp = -2;
`vr_tokens[0].vr_tokens[0] = 0;
`vr_tokens[1].vr_tokens[0] = 0;
`vr_tokens[0].vr_tags[0] = 0;
`vr_tokens[1].vr_tags[0] = 0;
`pmsg = processPrompt(pmsg);
`len = strlen(pmsg);
`
`if (len > 0 && strstr(pmsg, ".vox8")) {
`
` /* set 8Kz mode */
`
` set_play_format(MD_ADPCM | PM_SR8);
`
`}
`
`}p
`
`7
`
`}i
`
`}e
`
`Parus Exhibit 2036, Page 7 of 19
`
`
`
`if ( mode & VR_NO_BARGE_THRU ) {
` *retp = playf(pmsg);
` set_play_format(MD_ADPCM | PM_SR6);
` if (*retp == TR_LOOP) {
` vrDealloc();
`nvroute(0,0);
`return TR_LOOP;
` }
` DEBUG(printf("<%d>: vrContPSP nobargein
`retp=%d; msg=%s.\n",
`trunk_num, *retp, pmsg));
` if ( *retp == TR_MAXDG || *retp == TR_TERMDG ) {
`*retp = TR_MAXDG;
`for ( i = 0; *retp == TR_MAXDG && i < 3; i++ ) {
` if ((*retp = checkdtmf(1)) == TR_LOOP) {
` vrDealloc();
` nvroute(0,0);
` return TR_LOOP;
` }
` else if (*retp == TR_MAXDG) {
` vr_tokens[0].vr_tokens[i] = *dtmf_buf;
` vr_tokens[0].vr_tokens[i + 1] = 0;
`*dtmf_buf = 0;
`ret_val = R_TRUE;
`
` }
`}
` }
` else {
`time(&BeforeRec);
`set_dtmf(DTMF_TRAILING, 1);
`if (vrNuance())
`ret_val =
`vrGoNuance(msg,retp,iniPath,iniFile,
`debugFlag, flagFax, vr_tokens, rej,
`APP_PSP_PROFILE | APP_PSP_TAGS |
`
`APP_PSP_TONE);
`
`else
`
`debugFlag,
`APP_PSP_TONE,
`
`ret_val = app_vr_psp(retp, iniFile,
`APP_PSP_PROFILE | APP_PSP_TAGS |
`25,flagFax,vr_tokens);
`time(&AfterRec);
`set_dtmf(DTMF_TRAILING, DTMF_DFLT);
`tVR = AfterRec - BeforeRec;
`addTimeVR(tVR);
` DEBUG(printf(
`"<%d>app_vr_psp: At %s retp=%d cond=%d voc=%s
`spoke opt1=%s, opt2=%s.\n",
`trunk_num, msg, vr_tokens[0].condition,
`*retp,
`iniFile, vr_tokens[0].vr_tokens,
`
`8
`
`Parus Exhibit 2036, Page 8 of 19
`
`
`
`vr_tokens[1].vr_tokens));
` DEBUG(printf(
`"<%d>At %s score1=%d, conf1=%d, score2=%d, conf2
`=%d, tag1=%s, tag2=%s.\n",
`trunk_num, msg, vr_tokens[0].score,
`vr_tokens[0].confidence,
`vr_tokens[1].confidence,
`vr_tokens[1].vr_tags));
`
`vr_tokens[1].score,
`vr_tokens[0].vr_tags,
` }
`lse {
` DEBUG(printf("<%d>: vrContPSP barge=%s.
`\n",trunk_num,pmsg));
` set_dtmf(DTMF_TRAILING, 1);
` time(&BeforeRec);
` if (vrNuance())
`ret_val = vrGoNuance(pmsg,retp,
` iniPath,iniFile,debugFlag, flagFax,
`vr_tokens, rej,
`APP_PSP_PROFILE | APP_PSP_TAGS);
` else
` ret_val = app_play_vr_psp(pmsg, retp,
`iniFile,
`debugFlag, APP_PSP_PROFILE | APP_PSP_TAGS,
`25,
`flagFax, vr_tokens);
` set_play_format(MD_ADPCM | PM_SR6);
` time(&AfterRec);
` set_dtmf(DTMF_TRAILING, DTMF_DFLT);
` tVR = AfterRec - BeforeRec;
` addTimeVR(tVR);
` DEBUG(printf(
`"<%d>app_play_vr_psp: At %s ret=%d retp=%d cond=%
`d voc=%s spoke opt1=%s, opt2=%s.\n",
`trunk_num, msg, ret_val, *retp,
`vr_tokens[0].condition, iniFile,
`vr_tokens[0].vr_tokens,vr_tokens[1].vr_tokens));
` DEBUG(printf(
`"<%d>At %s score1=%d, conf1=%d, score2=%d, conf2
`=%d, tag1=%s, tag2=%s.\n",
`trunk_num, msg,
`vr_tokens[0].score,
`vr_tokens[0].confidence,
`vr_tokens[1].score,
`vr_tokens[1].confidence,
`vr_tokens[0].vr_tags,
`vr_tokens[1].vr_tags ));
` if (*retp == TR_LOOP) {
` vrDealloc();
`nvroute(0,0);
`
`}e
`
`9
`
`Parus Exhibit 2036, Page 9 of 19
`
`
`
`return TR_LOOP;
` }
` if (*retp == TR_TONE) {
` vrDealloc();
` nvroute(0,0);
` return TR_TONE;
` }
` if (vrNuance() && *retp == TR_SIL) {
`/* Nuance knock-off received */
` vrExitNuance();
` nvroute(0,0);
` fprintf(stderr, "<%d>ERROR Knock-off\n",
`trunk_num);
` if (vrAllocNuance(VR_NUANCE, NULL) != R_TRUE ) {
`fprintf(stderr,
`"<%d>ERROR vrAlloc(..)\n", trunk_num);
`
`
`
`} n
`
`ap_poll(70);
` return R_FALSE;
` }
`ffScore = vr_tokens[0].score;
`if (ret_val == R_TRUE && *retp != TR_MAXDG &&
` isalnum(*vr_tokens[0].vr_tags) &&
`/* isalnum(*vr_tokens[0].vr_tags) && */
` !strcmp(vr_tokens[0].vr_tags,
`vr_tokens[1].vr_tags)) {
`effScore += vr_tokens[1].score;
`}
`if ( *retp == TR_MAXDG || *retp == TR_TERMDG ) {
` DEBUG(printf("<%d>Dtmf entered=%s, tok=%s.\n",
`trunk_num, dtmf_buf,
`vr_tokens[0].vr_tokens ));
`if (strlen(vr_tokens[0].vr_tokens) > 1) {
`*retp = -2;
`}
`lse if ( rej == 0) {
` vrDealloc();
`nvroute(0,0);
`return ret_val;
`lse if (ret_val == R_TRUE && rej > 0
`&& ( vr_tokens[0].confidence < rej ||
`effScore < score ) ) {
`DEBUG(printf(
`"<%d>Rejected tok=%s confidence=%d rej=%d
`trunk_num, vr_tokens[0].vr_tokens,
`vr_tokens[0].confidence, rej));
` /*-->vp_no_result_alt
`
`\n",
`
`}e
`
`}e
`
`}e
`
`10
`
`Parus Exhibit 2036, Page 10 of 19
`
`
`
`*-->Sorry, I am not sure what you said
`*/
`ret_val = R_FALSE;
`pmsg = vp_no_result_alt;
`rFlag++;
` if (rFlag < 2 && vr_tokens[0].condition )
` *mName = 0;
` if ( vrCheckStatus(vr_tokens,
`iniFile, mName)
`!= R_TRUE ) {
` if ( *mName )
` pmsg = mName;
` }
` }
`if( rFlag < 2 )
`continue;
` vrDealloc();
`nvroute(0,0);
`return ret_val;
`}
` if ( ret_val == R_FALSE ) {
` fprintf(stderr,"<%d>No result from
`recognizer: app_vr_psp() at %s, condition=%d\n",
`trunk_num, msg,
`vr_tokens[0].condition);
`if (rFlag < 2 &&
` vr_tokens[0].condition != APP_VR_TIMEOUT) {
`*mName = 0;
`if ( vrCheckStatus(vr_tokens, iniFile,
`== R_TRUE ) {
`
`mName)
`
`{
`
`vrDealloc();
`nvroute(0,0);
`return ret_val;
`f ( *mName )
`pmsg = mName;
`else {
`pmsg = msg;
`Flag++;
`continue;
`}
` vrDealloc();
`nvroute(0,0);
`return ret_val;
`}
` vrDealloc();
`nvroute(0,0);
`if ( ret_val != R_TRUE ) {
`
`}i
`
`}r
`
`11
`
`Parus Exhibit 2036, Page 11 of 19
`
`
`
`fprintf(stderr,
`"<%d>ERROR app_vr_psp(%s,.) ret_val=%d,
`
`}b
`
`}i
`
`}i
`
`&&
`{
`
`{
`
`condition=%d\n",
`trunk_num,msg,ret_val,vr_tokens[0].condition);
`return ret_val;
`f ( !strncmp(iniFile,"digits",6) &&
`!strstr(vr_tokens[0].vr_tokens, "CANCEL")
`!strstr(vr_tokens[0].vr_tokens, "cancel") )
` if ( *retp != TR_MAXDG && *retp != TR_TERMDG ) {
`for (i = 0,j = 0,p = vr_tokens[0].vr_tokens;
`j < 63 && *p != '\0'; p++, j++) {
`if ( isdigit(*p) || *p == '*' )
`buf[i++] = *p;
`uf[i] = 0;
`if (*buf && strlen(buf) < 63)
`strcpy(vr_tokens[0].vr_tokens, buf);
` for (i = 0,j = 0,p =
`vr_tokens[1].vr_tokens;
` j < 63 && *p != '\0';
`p++, j++) {
` if ( isdigit(*p) )
` buf[i++] = *p;
` }
` buf[i] = 0;
` strcpy(vr_tokens[1].vr_tokens, buf);
` }
`f ( *retp == TR_MAXDG || *retp == TR_TERMDG )
`if ( !flagDtmf && strncmp(iniFile,"digits",6) )
`fldtmf();
`
`}
`DEBUG(printf(
`"<%d>At %s spoke opt1=%s, opt2=%s with
`condition=%d.\n",
`trunk_num, msg,
`vr_tokens[0].vr_tokens,
`vr_tokens[1].vr_tokens, vr_tokens[0].condition));
`break;
`eturn ret_val;
`
`}r
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`
`12
`
`Parus Exhibit 2036, Page 12 of 19
`
`
`
`/*
`
`/*
`
`/*
`
`{i
`
` ---------------------------------------------------------------
`----------- */
`/* -----------------------------
`NUANCE --------------------------------- */
` ---------------------------------------------------------------
`----------- */
` ---------------------------------------------------------------
`----------- */
`int vrExitNuance()
`/*
`This is the only place where we do deallocate */
`nt ret_val;
`if (vr_allocated) {
`vr_allocated = 0;
`ret_val = app_nuance_dealloc();
`if (ret_val != R_TRUE)
`fprintf(stderr, "<%d>ERROR %d
`app_nuance_dealloc()\n",
`trunk_num, ret_val);
`load_contacts_flag = 0;
`load_corp_flag = 0;
`load_lists_flag = 0;
`if (contacts_rsrc > 0) {
`parus_deallocate_rsrc(RSRC_PSEUDO1);
`contacts_rsrc = -1;
`
`/*
`
`}
`
`*/
`eturn(0);
`
`}r
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`int vrDeallocNuance()
`/*
`We never deallocate here */
`{
`return(0);
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`int vrAllocNuance(int vr_type, char *package)
`nt ret_val, ntimeout, retries = 6;
`char *val, *np;
`if (vr_allocated)
`
`{i
`
`13
`
`Parus Exhibit 2036, Page 13 of 19
`
`
`
`return(R_TRUE);
` if ((val = GetConfigVar(app_name, "NUANCE_PACKAGE")) ==
`NULL) {
`sprintf(nuance_package, "%s/%s/nuance/menu",
`msg_home,app_name);
`lse {
`strncpy(nuance_package, val, MAX_STRING_SIZE);
`nuance_package[MAX_STRING_SIZE] = '\0';
`
`}e
`
`}e
`
`/*
`
`}s
`
`trunk_num,
`
`Nuance*/
`
`}
`if (!package) {
`sprintf(nuance_package, "%s/%s/nuance/menu",
`msg_home,app_name);
`lse {
`strncpy(nuance_package, package, MAX_STRING_SIZE);
`nuance_package[MAX_STRING_SIZE] = '\0';
`
`}
`*/
`ntimeout = 0;
` np = GetConfigVar(app_name, "NUANCE_START_SPEECH_TO");
` if (np)
` ntimeout = atoi(np);
`while (retries--) {
`ret_val = app_nuance_alloc(nuance_package);
`DEBUG(printf("<%d>app_nuance_alloc(%s) ret %d\n",
`nuance_package, ret_val));
`if (ret_val == R_TRUE) {
`vr_allocated = 1;
`/* allow Nuance to init; only used
`in non-inititiolized version of
`if (ntimeout > 0 && ntimeout < 100)
`nap_poll(ntimeout);
`break;
`leep(1);
`} /* while */
`if (ret_val != R_TRUE )
`fprintf(stderr, "<%d>ERROR vrAllocNuance(%s)\n",
`trunk_num,
`nuance_package);
`return(ret_val);
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`int vrGoNuance(char *playf_name, int *dtmf_retp, char *inipath,
`
`14
`
`Parus Exhibit 2036, Page 14 of 19
`
`
`
`char *grammar,
`int debugFlag, int flagFax, struct VR_RES *vr_res, int rej,
`int mode)
`nt ret_val, nuance_mode = 0, nuance_time = 6, nuance_confidence
`= 20, i;
`char *slp, nuance_grammar[MAX_ASR_SUBDICT],
`dynamic_grammar[MAX_ASR_SUBDICT];
`unsigned char gl;
`struct ASR_RES asr_res[3];
`/*
`build nuance_grammar */
`nuance_grammar[0] = '.';
`slp = strrchr(grammar, '/');
`if (slp)
`slp++;
`else
`slp = grammar;
`nuance_time = speechStartTimeout("get", nuance_time);
`for (i = 0; i < (MAX_ASR_SUBDICT - 2); i++) {
`gl = (unsigned char)*(slp + i);
`if (!gl)
`break;
`if (gl == '.')
`break;
`if (islower(gl))
`nuance_grammar[i + 1] = toupper(gl);
`else
`nuance_grammar[i + 1] = gl;
`uance_grammar[i + 1] = '\0';
`Check if nuance_grammar is dynamic and make sure it's loaded
`/*
`*/
`ret_val = vrGrammarDynamic(inipath, grammar,
`nuance_grammar);
`DEBUG(printf("<%d>Built nuance_grammar (%s) ret %d\n",
`trunk_num,
`nuance_grammar, ret_val));
`
`{i
`
`}n
`
`/*
`
`build nuance_mode */
`if (mode & APP_PSP_TONE)
`nuance_mode |= APP_NUANCE_TONE; /* no barge-in */
`else
`nuance_mode |= APP_NUANCE_PLAY; /* barge-in mode */
`if (mode & APP_PSP_PROFILE)
`nuance_mode |= APP_NUANCE_PROFILE;
`if (flagFax & VR_FAX_TERM)
`
`15
`
`Parus Exhibit 2036, Page 15 of 19
`
`
`
`nuance_mode |= APP_NUANCE_FAX;
`if (flagFax & VR_NOFLUSH)
`nuance_mode |= APP_NUANCE_NOFLUSH;
`ret_val = app_nuance_asr(playf_name, dtmf_retp,
`nuance_package,
`nuance_grammar, nuance_time, nuance_mode,
`nuance_confidence,
`asr_res);
`if (dtmf_retp) {
`DEBUG(printf("<%d>app_nuance_asr(%s,,,%s,,%X,,) ret %d
`dtmf_ret=%d\n",
`trunk_num, playf_name, nuance_grammar,
`nuance_mode, ret_val, *dtmf_retp));
`EBUG(printf("<%d>buf (%s) info (%s) score %d conf %d\n",
`trunk_num,
`asr_res->asr_buf, asr_res->asr_info, asr_res->
`score,
`asr_res->confidence));
`if (!strcmp(asr_res->asr_buf, APP_KNOCK_OFF) ) {
`*dtmf_retp = TR_SIL;
`return R_FALSE;
`
`}D
`
`}
`restructure results */
`if (ret_val != R_TRUE) {
`return(ret_val);
`
`} v
`
`rResNuance(vr_res, asr_res, nuance_grammar);
`if (strlen((asr_res + 1)->asr_buf))
`vrResNuance(vr_res + 1, &asr_res[1], nuance_grammar);
`return(ret_val);
`
`/*
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`static int vrResNuance(struct VR_RES *vr_res, struct ASR_RES
`*asr_res,
`char *nuance_grammar)
`
`{c
`
`har *spacep, *underp;
`if (strlen(asr_res->asr_info)) {
`strncpy(vr_res->vr_tokens, asr_res->asr_info,
`MAX_DIGITS);
`vr_res->vr_tokens[MAX_DIGITS] = '\0';
`strncpy(vr_res->vr_tags, asr_res->asr_buf,
`MAX_DIGITS);
`vr_res->vr_tags[MAX_DIGITS] = '\0';
`
`16
`
`Parus Exhibit 2036, Page 16 of 19
`
`
`
`spacep = strstr(vr_res->vr_tags, " ");
`if (spacep)
`*spacep = '\0';
`}
`/*
`else if (strlen(asr_res->asr_buf) > 1 && isdigit(asr_res->
`asr_buf[0]) &&
`isdigit(asr_res->asr_buf[1])) {
`Temporary fix
`strcpy(vr_res->vr_tokens, "some menu command");
`strncpy(vr_res->vr_tags, asr_res->asr_buf,
`MAX_DIGITS);
`vr_res->vr_tags[MAX_DIGITS] = '\0';
`spacep = strstr(vr_res->vr_tags, " ");
`if (spacep)
`*spacep = '\0';
`
`}
`else {
`strncpy(vr_res->vr_tokens, asr_res->asr_buf,
`MAX_DIGITS);
`vr_res->vr_tokens[MAX_DIGITS] = '\0';
`if (!strcmp(nuance_grammar, ".CONTACTS") ||
`!strcmp(nuance_grammar, ".LISTS")) {
`while(1) {
`underp = strchr(vr_res->vr_tokens, '_');
`if (!underp)
`break;
`*underp = ' ';
`
`*/
`
`}
`r_res->vr_tags[0] = '\0';
`r_res->score = 99;
`vr_res->confidence = asr_res->confidence * 10;
`vr_res->condition = 0;
`
`}v
`
`}v
`
`}/*
`
`{i
`
`'C')
`
` ---------------------------------------------------------------
`----------- */
`static int vrGrammarDynamic(char *inipath, char *source_gr, char
`*gr)
`/* grammars .C10000 .M123, .M1234567890, .L123, .L1234567890 are
`dynamic */
`nt ret_val, i, len;
`char *pp, *new_name, *wgil_ext = ".wgil";
`char dynamic_grammar[MAX_ASR_SUBDICT],
`wgil_file[MAX_ASR_SUBDICT];
`DEBUG(printf("<%d>Checking grammar (%s)\n", trunk_num, gr));
`if (*(gr + 1) != 'M' && *(gr + 1) != 'L' && *(gr + 1) !=
`
`17
`
`Parus Exhibit 2036, Page 17 of 19
`
`
`
`return(0); /* not dynamic */
`len = strlen(gr);
`for (i = 2; i < len; i++) {
`if (!isdigit(*(gr + i)))
`return(0); /* not dynamic */
`
`}e
`
`/*
`
`}
`Loading (if necessary) dynamic grammar here */
`if (*(gr + 1) == 'M' ) {
`new_name = ".CONTACTS";
`strcpy(gr, new_name);
`if (load_contacts_flag)
`/* already loaded */
`return(1);
`lse if (*(gr + 1) == 'C' ) {
`new_name = ".MCALL";
`strcpy(gr, new_name);
`if (load_corp_flag)
`/* already loaded */
`return(1);
`
`}e
`
`lse {
`new_name = ".LISTS";
`strcpy(gr, new_name);
`if (load_lists_flag)
`/* already loaded */
`return(1);
`
`/*
`
`}
`building wgil_file name */
`wgil_file[0] = '\0';
`pp = strrchr(source_gr, '.');
`if (pp)
`*pp = '\0';
`if (inipath) {
`if (strlen(inipath) + 1 + strlen(source_gr) +
`strlen(wgil_ext) <
`MAX_ASR_SUBDICT)
`sprintf(wgil_file, "%s/%s%s", inipath, source_gr,
`wgil_ext);
`lse if (strlen(source_gr) + strlen(wgil_ext)
`< MAX_ASR_SUBDICT)
`sprintf(wgil_file, "%s%s", source_gr, wgil_ext);
`if (pp)
`*pp = '.';
`if (!strlen(wgil_file)) {
`fprintf(stderr,"<%d>ERROR building wgil_file name (%
`s,%s,..)\n",
`
`}e
`
`18
`
`Parus Exhibit 2036, Page 18 of 19
`
`
`
`trunk_num, inipath, source_gr);
`
`return(1);
`printf(dynamic_grammar, "%s_DYNAMIC", new_name + 1);
`DEBUG(printf("<%d>Loading wgil_file (%s)\n", trunk_num,
`wgil_file));
`ret_val = app_nuance_load(wgil_file, dynamic_grammar, 0);
`DEBUG(printf("<%d>app_nuance_load(%s,%s,0) ret %d\n",
`trunk_num,
`wgil_file, dynamic_grammar, ret_val));
`/*
`01-12-99 Since gr is overwritten, 'M' stands for corp. names
`and 'C' stands for contacts here
`*/
`if (*(gr + 1) == 'M' )
`load_corp_flag++;
`else if (*(gr + 1) == 'C' )
`load_contacts_flag++;
`else
`load_lists_flag++;
`return(1);
`
`}s
`
`}/*
`
` ---------------------------------------------------------------
`----------- */
`
`19
`
`Parus Exhibit 2036, Page 19 of 19
`
`