home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / dir_nm20.zip / Dir_NM_2.0 / NM-Speak.c < prev    next >
C/C++ Source or Header  |  1992-07-16  |  19KB  |  655 lines

  1. /*                           ===  NM-Speak.c  ===
  2.  *
  3.  * int  same(st1,st2)         
  4.  * void into(newstate,wd,nxt,LINK)
  5.  * void ar(x,y)
  6.  * void gi(x,y)
  7.  * void ae(x,y)
  8.  * void j_(x,y)
  9.  * void au(x,y)
  10.  * void the(x,y)
  11.  * void sthe(x,y)
  12.  * void sh(x,y)
  13.  * void aee(x,y)
  14.  * void er(x,y)
  15.  * void wordin(LINK)
  16.  * void Word_I_O(ch_)
  17.  * void pronounce(word)
  18.  * void spell(word)
  19.  * void speak(word)
  20.  *
  21.  * void Tell(afile)
  22.  * void Voice(ch)
  23.  *
  24.  */
  25.  
  26. #include "NM.h"
  27.  
  28. int i;
  29.  
  30. int same(st1,st2)
  31.   char *st1,*st2;
  32. {
  33.   int k,short_;
  34.  
  35.   if (strlen(st1)>strlen(st2)) short_=strlen(st2);else short_=strlen(st1);k=0;
  36.   do { k++; } while (toupper(st1[k-1])==toupper(st2[k-1]) && k!=short_);
  37.   if (toupper(st1[k-1])>toupper(st2[k-1])) return -1;
  38.   else 
  39.     {
  40.       if (toupper(st1[k-1])<toupper(st2[k-1])) return 1;
  41.       else if (strlen(st1)>strlen(st2)) return -1;
  42.            else if (strlen(st1)<strlen(st2)) return 1;else return 0;
  43.     }
  44. }
  45.  
  46. /* Local variables for Word_I_O: */
  47. struct LOC_Word_I_O 
  48. {
  49.   char ch;
  50. };
  51.  
  52. void into(newstate,wd,nxt)
  53.   stater **newstate,*nxt;
  54.   char *wd;
  55. {
  56.   stater *WITH;
  57.  
  58.   *newstate=(stater *)malloc(sizeof(stater));WITH=*newstate;
  59.   strcpy(WITH->word,wd);memcpy(WITH->say,sy,sizeof(ary16));WITH->nxtone=nxt;
  60. }
  61.  
  62. void ar(x,y)
  63.   int x,y;
  64. {
  65.   DrawEllipse(x,y,9,16,0,360);Line(x+9,y+7,x+12,y+17);
  66. }
  67.  
  68. void gi(x,y)
  69.   int x,y;
  70. {
  71.   Line(x-5,y-6,x+5,y-6);Line(x+3,y-6,x+1,y-1);Line(x+1,y-1,x+1,y+5);
  72.   DrawEllipse(x-5,y+1,6,8,0,-180);
  73. }
  74.  
  75. void ae(x,y)
  76.   int x,y;
  77. {
  78.   DrawEllipse(x,y,9,13,0,150);DrawEllipse(x,y,9,13,0,-170);
  79.   Line(x,y+8,x+9,y+8);
  80. }
  81.  
  82. void j_(x,y)
  83.   int x,y;
  84. {
  85.   Line(x,y,x,y+4);DrawEllipse(x-6,y,6,8,0,-180);
  86. }
  87.  
  88. void au(x,y)
  89.   int x,y;
  90. {
  91.   DrawEllipse(x,y,9,13,0,150);DrawEllipse(x,y,9,13,0,-160);
  92. }
  93.  
  94. void the(x,y)
  95.   int x,y;
  96. {
  97.   Line(x-2,y+1,x+8,y-9);DrawEllipse(x-11,y-6,20,28,0,100);
  98.   DrawEllipse(x+1,y+2,8,11,0,360);
  99. }
  100.  
  101. void sthe(x,y)
  102.   int x,y;
  103. {
  104.   DrawEllipse(x,y,9,15,0,360);Line(x,y+7,x+9,y+7);
  105. }
  106.  
  107. void sh(x,y)
  108.   int x,y;
  109. {
  110.   DrawEllipse(x-1,y,7,10,0,180);Line(x,y+4,x,y+15);
  111. }
  112.  
  113. void aee(x,y)
  114.   int x,y;
  115. {
  116.   DrawEllipse(x,y+2,8,7,22,190);Line(x+2,y+9,x+8,y+9);
  117.   DrawEllipse(x,y+7,10,9,-22,-190);
  118. }
  119.  
  120. void er(x,y)
  121.   int x,y;
  122. {
  123.   Line(x-6,y+14,x,y);Line(x,y,x+6,y+14);
  124. }
  125.  
  126. void wordin(LINK)
  127.   struct LOC_Word_I_O *LINK;
  128. {
  129.   int i,k,nx,ny,nz,mz;
  130.   XImage *back;
  131.   char STR1[256];
  132.  
  133.   Rub(0,0,1139,862,"MediumBlue");XSetFunction(display,gc,GXcopy);
  134.   XSetLineAttributes(display,gc,2,0,0,0);SetColor("white");
  135.   DrawRectangle(320,200,500,400);Rub(321,201,498,398,"NavyBlue");
  136.   SetColor("white");for (i=1;i<=9;i++) Line(i*50+320,201,i*50+320,599);
  137.   for (i=1;i<=9;i++) Line(321,i*40+200,819,i*40+200);
  138.   S_bf=(char *)malloc(10);*S_bf='\0';
  139.   for (i=0;i<=9;i++) 
  140.     {
  141.       for (k=0;k<=9;k++) 
  142.         {
  143.       switch (i) 
  144.         {
  145.           case 0:switch (k) 
  146.                {
  147.                  case 0:strcpy(S_bf,"  ");break;
  148.              case 1:strcpy(S_bf,"^^");break;
  149.              case 2:strcpy(S_bf," :");break;
  150.              case 3:strcpy(S_bf,"ai");break;
  151.              case 4:strcpy(S_bf,"au");break;
  152.              case 5:strcpy(S_bf,"b ");break;
  153.              case 6:strcpy(S_bf,"d ");break;
  154.              case 7:strcpy(S_bf,"d ");break;
  155.              case 8:strcpy(S_bf,"e ");break;
  156.              case 9:strcpy(S_bf,"ei");break;
  157.                }
  158.         break;
  159.           case 1:switch (k) 
  160.                {
  161.                  case 0:strcpy(S_bf,"f ");break;
  162.              case 1:strcpy(S_bf,"g ");break;
  163.              case 2:strcpy(S_bf,"h ");break;
  164.              case 3:strcpy(S_bf,"i ");break;
  165.              case 4:strcpy(S_bf,"i:");break;
  166.              case 5:strcpy(S_bf,"i ");break;
  167.              case 6:strcpy(S_bf,"j ");break;
  168.              case 7:strcpy(S_bf,"k ");break;
  169.              case 8:strcpy(S_bf,"l ");break;
  170.              case 9:strcpy(S_bf,"m ");break;
  171.                }
  172.         break;
  173.           case 2:switch (k) 
  174.                {
  175.                  case 0:strcpy(S_bf,"n ");break;
  176.              case 1:strcpy(S_bf,"n ");break;
  177.              case 2:strcpy(S_bf,"o ");break;
  178.              case 3:strcpy(S_bf,"ou");break;
  179.              case 4:strcpy(S_bf,"p ");break;
  180.              case 5:strcpy(S_bf,"r ");break;
  181.              case 6:strcpy(S_bf,"s ");break;
  182.              case 7:strcpy(S_bf,"t ");break;
  183.              case 8:strcpy(S_bf,"t");break;
  184.              case 9:strcpy(S_bf,"u ");break;
  185.              }
  186.         break;
  187.           case 3:switch (k) 
  188.                {
  189.                  case 0:strcpy(S_bf,"u:");break;
  190.              case 1:strcpy(S_bf,"u ");break;
  191.              case 2:strcpy(S_bf,"v ");break;
  192.              case 3:strcpy(S_bf,"w ");break;
  193.              case 4:strcpy(S_bf,"z ");break;
  194.              case 5:strcpy(S_bf,"  ");break;
  195.                  case 6:strcpy(S_bf,"  ");break;
  196.              case 7:strcpy(S_bf," :");break;
  197.              case 8:strcpy(S_bf," i");break;
  198.              case 9:strcpy(S_bf,"  ");break;
  199.                }
  200.         break;
  201.           case 4:switch (k) 
  202.                {
  203.                  case 0:strcpy(S_bf,"  ");break;
  204.              case 1:strcpy(S_bf," :");break;
  205.              case 2:strcpy(S_bf,"  ");break;
  206.              case 3:strcpy(S_bf," e");break;
  207.              case 4:strcpy(S_bf,"  ");break;
  208.              case 5:strcpy(S_bf,"  ");break;
  209.              case 6:strcpy(S_bf,"  ");break;
  210.              case 7:strcpy(S_bf,"  ");break;
  211.              case 8:strcpy(S_bf,"  ");break;
  212.              case 9:strcpy(S_bf,"  ");break;
  213.                }
  214.         break;
  215.           case 5:switch (k) 
  216.                {
  217.                  case 0:strcpy(S_bf,"  ");break;
  218.              case 1:strcpy(S_bf,"  ");break;
  219.              case 2:strcpy(S_bf,"  ");break;
  220.              case 3:strcpy(S_bf,"  ");break;
  221.              case 4:strcpy(S_bf,"  ");break;
  222.              case 5:strcpy(S_bf,"  ");break;
  223.              case 6:strcpy(S_bf,"  ");break;
  224.              case 7:strcpy(S_bf,"  ");break;
  225.              case 8:strcpy(S_bf,"  ");break;
  226.              case 9:strcpy(S_bf,"  ");break;
  227.              }
  228.         break;
  229.           case 6:switch (k) 
  230.                {
  231.                  case 0:strcpy(S_bf,",");break;
  232.              case 1:strcpy(S_bf,". ");break;
  233.              case 2:strcpy(S_bf,"; ");break;
  234.              case 3:strcpy(S_bf,": ");break;
  235.              case 4:strcpy(S_bf,"` ");break;
  236.              case 5:strcpy(S_bf,"' ");break;
  237.              case 6:strcpy(S_bf,"\"");break;
  238.              case 7:strcpy(S_bf,"? ");break;
  239.              case 8:strcpy(S_bf,"! ");break;
  240.              case 9:strcpy(S_bf,"# ");break;
  241.              }
  242.         break;
  243.           case 7:switch (k) 
  244.                {
  245.                  case 0:strcpy(S_bf,"1 ");break;
  246.              case 1:strcpy(S_bf,"2 ");break;
  247.              case 2:strcpy(S_bf,"3 ");break;
  248.              case 3:strcpy(S_bf,"4 ");break;
  249.              case 4:strcpy(S_bf,"5 ");break;
  250.              case 5:strcpy(S_bf,"6 ");break;
  251.              case 6:strcpy(S_bf,"7 ");break;
  252.              case 7:strcpy(S_bf,"8 ");break;
  253.              case 8:strcpy(S_bf,"9 ");break;
  254.              case 9:strcpy(S_bf,"0 ");break;
  255.                }
  256.         break;
  257.           case 8:switch (k) 
  258.                {
  259.                  case 0:strcpy(S_bf,"+ ");break;
  260.              case 1:strcpy(S_bf,"- ");break;
  261.              case 2:strcpy(S_bf,"* ");break;
  262.              case 3:strcpy(S_bf,"/ ");break;
  263.              case 4:strcpy(S_bf,"< ");break;
  264.              case 5:strcpy(S_bf,"= ");break;
  265.              case 6:strcpy(S_bf,"> ");break;
  266.              case 7:strcpy(S_bf,"% ");break;
  267.              case 8:strcpy(S_bf,"& ");break;
  268.              case 9:strcpy(S_bf,"| ");break;
  269.                }
  270.         break;
  271.           case 9:switch (k) 
  272.                {
  273.                  case 0:strcpy(S_bf,"$ ");break;
  274.              case 1:strcpy(S_bf,"@ ");break;
  275.              case 2:strcpy(S_bf,"~ ");break;
  276.              case 3:strcpy(S_bf,"_ ");break;
  277.              case 4:strcpy(S_bf,"( ");break;
  278.              case 5:strcpy(S_bf,") ");break;
  279.              case 6:strcpy(S_bf,"[ ");break;
  280.              case 7:strcpy(S_bf,"] ");break;
  281.              case 8:strcpy(S_bf,"{ ");break;
  282.              case 9:strcpy(S_bf,"} ");break;
  283.                }
  284.         break;
  285.         }/* case */
  286.       SetColor("white");
  287.       if (i==4 && k==6) OutTextXY(k*50+337,i*40+230,S_bf);
  288.       else OutTextXY(k*50+337,i*40+230,S_bf);
  289.     }
  290.     }
  291.   ar(437,213);gi(705,227);ae(600,255);j_(396,309);sh(754,293);j_(754,306);
  292.   ae(401,336);gi(595,346);au(636,335);au(686,335);au(736,335);au(786,335);
  293.   ae(799,335);ae(337,376);ae(387,376);ae(449,376);ae(489,375);aee(435,374);
  294.   sthe(538,374);sh(593,372);j_(593,385);er(643,376);the(687,379);*wd='\0';
  295.   back=XGetImage(display,win,320,200,50,40,8,ZPixmap);i=1;nx=0;ny=0;nz=0;mz=0;
  296.   DrawRectangle(21,658,363,42);Rub(22,659,361,40,"magenta");SetColor("green");
  297.   OutTextXY(43,687,"Word spelling    Unit group");
  298.   OutTextXY(450,160,"\\--finish  Ecs--exit");highlight(20,736,20,25);
  299.   do {
  300.        do { } while (!(LINK->ch=GetKey()));
  301.        if (LINK->ch == '}' || LINK->ch == '{' || LINK->ch == ']' ||
  302.        LINK->ch == '[' || LINK->ch == '~' || LINK->ch == '`' ||
  303.        LINK->ch == '@' || LINK->ch == '|' ||
  304.        (LINK->ch & 255) >= 224 && (LINK->ch & 255) <= 228 ||
  305.        LINK->ch >= '[' && LINK->ch <= '\'' ||
  306.        LINK->ch >= '!' && LINK->ch <= '?' || LINK->ch == ' ' ||
  307.        isalpha(LINK->ch)) 
  308.      {
  309.        sprintf(wd+strlen(wd),"%c",LINK->ch);sprintf(STR1,"%c",LINK->ch);
  310.        highlight(i*20,736,20,25);
  311.            if (LINK->ch != '!') { SetColor("green");OutTextXY(i*20,760,STR1); }
  312.        i++;highlight(i*20,736,20,25);
  313.      }
  314.      } while (LINK->ch != '!' && LINK->ch != '\\' && LINK->ch != '&');
  315.   if (LINK->ch=='\\' || LINK->ch=='&') return;highlight(i*20,736,20,25);
  316.   k=0;highlight(400,730,50,40);highlight(320,200,50,40);
  317.   do {
  318.        LINK->ch=GetKey();
  319.        if (LINK->ch=='@' || LINK->ch=='>' || LINK->ch=='<' || LINK->ch =='?') 
  320.      {
  321.        highlight(nx*50+320,ny*40+200,50,40);
  322.        switch (LINK->ch) 
  323.          {
  324.            case '<':if (nx==0) nx=9;else nx--;break;
  325.            case '>':if (nx==9) nx=0;else nx++;break;
  326.            case '?':if (ny==0) ny=9;else ny--;break;
  327.            case '@':if (ny==9) ny=0;else ny++;break;
  328.          }
  329.        back=XGetImage(display,win,nx*50+320,ny*40+200,50,40,8,ZPixmap);
  330.        highlight(nx*50+320,ny*40+200,50,40);k=ny*10+nx;
  331.      } 
  332.        else if (LINK->ch=='C'||LINK->ch=='Z') 
  333.           {
  334.         highlight(nz*50+400,730,50,40);
  335.         if (LINK->ch=='Z') { if (nz>0) nz--;else nz=mz; } 
  336.         else { if (nz==mz) nz=0;else nz++; }
  337.         highlight(nz*50+400,730,50,40);
  338.           } else if (LINK->ch=='!') 
  339.                {
  340.              highlight(nz*50+400,730,50,40);
  341.                      XPutImage(display,win,gc,back,0,0,nz*50+400,730,50,40);
  342.              if (nz<15) 
  343.                {
  344.                  nz++;if (nz>mz) mz=nz;
  345.                  highlight(nz*50+400,730,50,40);sy[nz-1]=k;
  346.                } 
  347.              else LINK->ch = '\\';
  348.                }
  349.      } while (LINK->ch != '\\' && LINK->ch != '&');
  350.   sy[mz]=0;free(back);
  351. }
  352.  
  353. void Word_I_O(ch_)
  354.   char ch_;
  355. {
  356.   int k;
  357.   struct LOC_Word_I_O V;
  358.   stater *WITH;
  359.   char *TEMP;
  360.  
  361.   V.ch = ch_;
  362.   if ((wordfile=fopen("Dir_Song/IM.wrd","r"))!=NULL)
  363.     {
  364.       rewind(wordfile);size=1;mid=(midstate *)malloc(sizeof(midstate));
  365.       firststate=(stater *)malloc(sizeof(stater));
  366.       atstate=(stater *)malloc(sizeof(stater));
  367.       laststate=(stater *)malloc(sizeof(stater));
  368.       newstate=(stater *)malloc(sizeof(stater));
  369.       fread(mid,sizeof(midstate),1,wordfile);WITH=firststate;
  370.       strcpy(WITH->word,mid->word);memcpy(WITH->say,mid->say,sizeof(ary16));
  371.       WITH->nxtone=newstate;
  372.       while (!feof(wordfile)) 
  373.     {
  374.       size++;fread(mid,sizeof(midstate),1,wordfile);
  375.       strcpy(newstate->word,mid->word);
  376.       memcpy(newstate->say,mid->say,sizeof(ary16));
  377.       atstate=newstate;newstate=(stater *)malloc(sizeof(stater));
  378.       atstate->nxtone=newstate;
  379.     }
  380.       /* p2c: sp1.pas, line 177:
  381.        * Warning: Procedure release not yet supported [118] */
  382.       /*  release((Anyptr)(&newstate)); */
  383.       atstate->nxtone=NULL;laststate=atstate;atstate=firststate;
  384.       if (wordfile != NULL) fclose(wordfile);
  385.     } 
  386.   else 
  387.     {
  388.       mid=(midstate *)malloc(sizeof(midstate));
  389.       firststate=(stater *)malloc(sizeof(stater));
  390.       atstate=(stater *)malloc(sizeof(stater));
  391.       laststate=(stater *)malloc(sizeof(stater));
  392.       newstate=(stater *)malloc(sizeof(stater));
  393.       WITH=newstate;strcpy(WITH->word,"A");WITH->say[0]=9;
  394.       WITH->say[1]=0;WITH->nxtone=NULL;firststate=newstate;
  395.       newstate=(stater *)malloc(sizeof(stater));WITH=newstate;
  396.       strcpy(WITH->word,"Z");WITH->say[0]=34;WITH->say[1]=14;WITH->say[2]=0;
  397.       WITH->nxtone=NULL;laststate=newstate;firststate->nxtone=laststate;
  398.       atstate=firststate;
  399.       if (wordfile != NULL) rewind(wordfile);else wordfile=tmpfile();
  400.       WITH=firststate;strcpy(mid->word,WITH->word);
  401.       memcpy(mid->say,WITH->say,sizeof(ary16));
  402.       fwrite(mid,sizeof(midstate),1,wordfile);WITH=laststate;
  403.       strcpy(mid->word,WITH->word);memcpy(mid->say,WITH->say,sizeof(ary16));
  404.       fwrite(mid,sizeof(midstate),1,wordfile);
  405.       if (wordfile != NULL) fclose(wordfile);size=2;
  406.     }
  407.   if (toupper(V.ch)=='I') 
  408.     {
  409.       do {
  410.        wordin(&V);
  411.        if (*wd !='\0') 
  412.          {
  413.            if (same(wd,atstate->word)==-1) 
  414.          {
  415.            do {
  416.                 laststate=atstate;atstate = atstate->nxtone;
  417.               } while (!((atstate->nxtone==NULL) | (same(wd,atstate->
  418.                                word)==1) | (same(wd, atstate->word) == 0)));
  419.            if (same(wd,atstate->word)==0)
  420.              memcpy(atstate->say,sy,sizeof(ary16));
  421.            else if (same(wd,atstate->word) == 1) 
  422.                   {
  423.                 into(&newstate,wd,atstate);
  424.                 laststate->nxtone=newstate;
  425.               }
  426.                 else 
  427.               {
  428.                 into(&newstate,wd,NULL);
  429.                 atstate->nxtone=newstate;
  430.               }
  431.          } 
  432.            else if (same(wd,atstate->word)==1) 
  433.               {
  434.             if (same(wd,firststate->word)==1) 
  435.               {
  436.                 into(&newstate,wd,firststate);
  437.                 firststate=newstate;atstate=newstate;
  438.               } 
  439.             else 
  440.               {
  441.                 atstate=firststate;
  442.                 do {
  443.                      laststate=atstate;atstate=atstate->nxtone;
  444.                    } while (!((same(wd,atstate->word)==1) |
  445.                       (same(wd,atstate->word)==0)));
  446.                 if (same(wd, atstate->word)==1) 
  447.                   {
  448.                 into(&newstate,wd,atstate);
  449.                 laststate->nxtone=newstate;
  450.                   } 
  451.                 else memcpy(atstate->say, sy, sizeof(ary16));
  452.               }
  453.               } 
  454.            else memcpy(atstate->say, sy, sizeof(ary16));
  455.          }
  456.      } while (V.ch != '&');
  457.       if (wordfile!=NULL) rewind(wordfile);else wordfile=tmpfile();
  458.       atstate=firststate;
  459.       while (atstate != NULL) 
  460.     {
  461.       WITH = atstate;strcpy(mid->word,WITH->word);
  462.       memcpy(mid->say,WITH->say,sizeof(ary16));
  463.       fwrite(mid,sizeof(midstate),1,wordfile);atstate=atstate->nxtone;
  464.     }
  465.       if (wordfile != NULL) fclose(wordfile);
  466.     }
  467.   if (V.ch=='O') 
  468.     {
  469.       XClearWindow(display,win);atstate = firststate;i = 1;k = 0;
  470.       while (atstate != NULL) 
  471.     {
  472.       WITH=atstate;OutTextXY((int)i,70,WITH->word);j=1;
  473.       do {
  474.            printf("%3ld", WITH->say[j - 1]);j++;
  475.          } while (WITH->say[j - 1] != 0);
  476.       if (i==1) i=41;else { i=1;putchar('\n'); }
  477.       atstate = atstate->nxtone;k++;if (k % 46 != 0) continue;
  478.       OutTextXY(23, 70,"Esc--exit   Bar--continue ...\n");
  479.       V.ch=GetKey();if (V.ch=='&') return;
  480.     }
  481.       putchar('\n');OutTextXY(33,80,"      words");Out_I_XY(33,80,size);
  482.       do { } while ((ch = GetKey())!=NULL);V.ch = GetKey();
  483.     }
  484.   if (V.ch=='D') 
  485.     {
  486.       XClearWindow(display,win);;printf("which word ?");fgets(wd,17,stdin);
  487.       TEMP=strchr(wd,'\n');if (TEMP != NULL) *TEMP=0;
  488.       if (same(wd,firststate->word)==0) firststate=firststate->nxtone;
  489.       else 
  490.     {
  491.       atstate=firststate;
  492.       do {
  493.            laststate=atstate;atstate=atstate->nxtone;
  494.          } while (same(wd,atstate->word) != 0 && atstate != NULL);
  495.       if (atstate==NULL) return;laststate->nxtone=atstate->nxtone;
  496.     }
  497.       if (wordfile != NULL) rewind(wordfile);else wordfile=tmpfile();
  498.       atstate=firststate;
  499.       while (atstate != NULL) 
  500.     {
  501.       WITH=atstate;strcpy(mid->word,WITH->word);
  502.       memcpy(mid->say,WITH->say,sizeof(ary16));
  503.       fwrite(mid, sizeof(midstate),1,wordfile);atstate=atstate->nxtone;
  504.     }
  505.       if (wordfile != NULL) fclose(wordfile);
  506.     }
  507. }
  508.  
  509. void pronounce(word)
  510.   char *word;
  511. {
  512.   int i;
  513.   stater *WITH;
  514.  
  515.   i=1;WITH=atstate;
  516.   do { ptr_.nt[0]=-WITH->say[i-1];Play();i++; } while (WITH->say[i-1]!=0);
  517.   /*   delay(77); */
  518. }
  519.  
  520. void spell(word)
  521.   char *word;
  522. {
  523.   int i;
  524.   char STR1[256];
  525.  
  526. /*   sound(360);delay(600);nosound();delay(700); */
  527.   i=1;
  528.   do {
  529.        atstate=firststate;
  530.        while (toupper(word[i-1])!=toupper(atstate->word[0]))
  531.      atstate=atstate->nxtone;
  532.        sprintf(STR1,"%c",word[i-1]);pronounce(STR1); /* delay(690); */
  533.        i++;
  534.      } while (i <= strlen(word));
  535. /*   delay(700);sound(327);delay(500);nosound();delay(700); */
  536. }
  537.  
  538. void speak(word)
  539.   char *word;
  540. {
  541.   int i,none;
  542.   char STR1[18];
  543.  
  544.   atstate=firststate;none=0;i=0;
  545.   do {
  546.        i++;
  547.        while (toupper(word[i-1])!=toupper(atstate->word[i-1]) && !none)
  548.      {
  549.        laststate=atstate;atstate=atstate->nxtone;
  550.        sprintf(STR1,"%sS",laststate->word);
  551.        if ((atstate==NULL) | (same(word,atstate->word)==1) |
  552.                (same(STR1,word)==0))
  553.          none = 1;
  554.      }
  555.      } while (!(i==strlen(word) || none));
  556.   if (!none) { pronounce(word);return; } sprintf(STR1,"%sS",laststate->word);
  557.   if (same(STR1, word) != 0) { spell(word);return; }
  558.   ptr_.nt[0]=-26;ptr_.at=0;ptr_.cm=0;pronounce(word);Play();
  559. }
  560.  
  561. void Tell(afile)
  562.   char *afile;
  563. {
  564.   char buffer[1048],st[17],STR1[256];
  565.  
  566.   filvar=fopen(afile,"r");rewind(filvar);setvbuf(filvar, buffer, _IOFBF, 1048);
  567. /* Note: Make sure setvbuf() call occurs when file is open [200] */
  568.   while (!feof(filvar)) 
  569.     {
  570.       ch=getc(filvar);if (ch=='\n') ch=' ';*st='\0';
  571.       switch (ch) 
  572.     {
  573.       case ' ':
  574.       case '\n':
  575.       case '\015':
  576.       case '\033':putchar(ch);break;
  577.       default:if (ch >= '!' && ch <= '?' || ch >= '[' && ch <= '\'' ||
  578.               (ch & 255)>=224 && (ch & 255)<=228 || (ch & 255)==234 ||
  579.               ch=='|' || ch=='@' || ch=='`' || ch=='~' || ch=='[' ||
  580.               ch == ']' || ch == '{' || ch == '}') 
  581.                 { putchar(ch);sprintf(STR1,"%c",ch);speak(STR1); } 
  582.               else if (isalpha(ch)) 
  583.                  {
  584.                sprintf(st,"%c",ch);putchar(ch);
  585.                do {
  586.                     if (strlen(st)==16) *st='\0';ch=getc(filvar);
  587.                 if (ch=='\n') ch=' ';putchar(ch);
  588.                 if (isalpha(ch)) sprintf(st+strlen(st),"%c",ch);
  589.                   } while (isalpha(ch));
  590.                speak(st);*st = '\0';
  591.                if (ch!='\n' && ch!='\015' && ch!='\033' && ch!=' ') 
  592.                  { sprintf(STR1,"%c",ch);speak(STR1); }
  593.              }
  594.         break;
  595.     }/*case*/
  596.     }
  597.   /* else begin write(ch);delay(2000);halt;end;*/
  598. }
  599.  
  600. void Voice(ch)
  601.   char ch;
  602. {
  603.   int k;
  604.   char str[256],STR1[256],*TEMP;
  605.   stater *WITH;
  606.  
  607.   if ((wordfile=fopen("Dir_Song/IM.wrd","r"))==NULL) return;
  608.   printf("--- Voice ---\n\n");S_bf=(char *)malloc(17);*S_bf='\0';
  609.   rewind(wordfile);mid=(midstate *)malloc(sizeof(midstate));
  610.   firststate=(stater *)malloc(sizeof(stater));
  611.   atstate=(stater *)malloc(sizeof(stater));
  612.   laststate=(stater *)malloc(sizeof(stater));
  613.   newstate=(stater *)malloc(sizeof(stater));
  614.   fread(mid,sizeof(midstate),1,wordfile);
  615.   WITH=firststate;strcpy(WITH->word,mid->word);
  616.   memcpy(WITH->say, mid->say, sizeof(ary16));WITH->nxtone=newstate;
  617.   while (!feof(wordfile)) 
  618.     {
  619.       fread(mid,sizeof(midstate),1,wordfile);strcpy(newstate->word,mid->word);
  620.       memcpy(newstate->say,mid->say,sizeof(ary16));atstate=newstate;
  621.       newstate=(stater *)malloc(sizeof(stater));atstate->nxtone=newstate;
  622.     }
  623.   free(newstate);atstate->nxtone=NULL;laststate=atstate;atstate=firststate;
  624.   if (wordfile != NULL) fclose(wordfile);wordfile=NULL;
  625.   switch (ch) 
  626.     {
  627.       case 'P':printf("Phrase= ");gets(str);strcat(str," ");i=strlen(str);k=0;
  628.            do {
  629.             k++;ch=str[k-1];*S_bf='\0';
  630.             if (ch>='!'&&ch<='?'||ch>='['&&ch<='\''||
  631.             (ch&255)>=224&&(ch&255)<=228||ch==' '||(ch&255)==234) 
  632.               { sprintf(STR1, "%c", ch);speak(STR1); } 
  633.             else if (isalpha(ch)) 
  634.                    {
  635.                  sprintf(S_bf,"%c",ch);
  636.                  do {
  637.                       if (strlen(S_bf)==16) *S_bf='\0';
  638.                   k++;ch=str[k-1];
  639.                   if (isalpha(ch)) 
  640.                     sprintf(S_bf+strlen(S_bf),"%c",ch);
  641.                 } while (isalpha(ch));
  642.                  speak(S_bf);*S_bf='\0';
  643.                  if (ch !='\n' && ch !='!' && ch !=' ') 
  644.                    { sprintf(STR1, "%c", ch);speak(STR1); }
  645.                }
  646.           } while (k != i);
  647.     break;
  648.       case 'F':printf("File name:");fgets(filname,100,stdin);
  649.            TEMP=strchr(filname,'\n');if (TEMP != NULL) *TEMP=0;
  650.            if ((wordfile=fopen(filname,"r"))!=NULL) Tell(filname);
  651.            else printf("No such file !\n");
  652.     break;
  653.     }
  654. }
  655.