home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Speech Unit Source / UsesSpeechOld < prev    next >
Encoding:
Text File  |  1993-09-02  |  2.3 KB  |  70 lines  |  [TEXT/MPS ]

  1.     PROCEDURE TTextEntryDialog.GetTextBBAtItemBB(VAR theText:Str255;ItemNo:INTEGER);
  2.     VAR 
  3.         CharIndex , theType:INTEGER;(* gives the type of the item requested *)
  4.         theTextHdl:Handle;(* gives a handle to the item *)
  5.         txtBox:Rect;(* gives the display rectangle of the item *)
  6.         theChannel:    SpeechChannel;
  7.         theVoiceSpecPtr:    VoiceSpecPtr;
  8.         theVoiceSpec:    VoiceSpec;
  9.         
  10.         
  11.         
  12.         myErr:        OSErr;
  13.         finalTicks,textlen,delayLen: LONGINT;
  14.         theTextPtr:Ptr;
  15. {
  16. Comment on string lengths:
  17. Pasted from Spinside mac 
  18. Toolbox utilities:
  19. String         'STR '               m bytes    The string (1-byte length
  20.                                                followed by the characters)
  21. THE MEMORY MANAGER 
  22.       Str255       = STRING[255];
  23. My remarks (PMS):
  24. 8bits specify 2^8=256 possibilities (less one possibility of string 0 length) or 255
  25. }
  26.         voiceCount:integer;
  27.         BEGIN
  28.         
  29.             {Standard calls to get text from a dialogue box I made:}
  30.             
  31.             GetDItem (fDialog, ItemNo, theType, theTextHdl, txtBox);
  32.             GetIText (theTextHdl, theText);
  33.             
  34.             {Following are speech commands,
  35.             Put speech.p in Lab 7 folder,
  36.             so PMake would see it without too much auxiliary scripting:}
  37.             
  38.             {Some sort of initialization needed even if not do loop of all:}
  39.             myErr := CountVoices    (voiceCount);
  40.             
  41.             {Type transfer from generic pointer:}
  42.             theVoiceSpecPtr := VoiceSpecPtr(@theVoiceSpec);
  43.             
  44.             {Liked the deep voice, most like Schwartznegger's:}
  45.             myErr := GetIndVoice          (6, theVoiceSpecPtr);
  46.             myErr := NewSpeechChannel     (theVoiceSpecPtr, theChannel);
  47.             
  48.             
  49.             {Note: @theText= @theText[0] would tell length of text, since theText:Str255,
  50.             so we use @theText[1] to start reading where we want to below:}
  51.             theTextPtr:=Ptr(@theText[1]);
  52.             
  53.             {Since we started reading at the right byte, we have the expected text length:}
  54.             textlen:=Ord4(LENGTH(theText));
  55.  
  56.             {OK now we have set up and it can speak:}            
  57.             myErr := SpeakText (theChannel,theTextPtr,textlen);
  58.  
  59.             {The need for the following wait loop shows 
  60.             that statements following speech 
  61.             can happen concurrently, that is,
  62.             are immediately executed during speech!
  63.             Don't want to dispose his speech while the speaker is speaking!}
  64.             
  65.             while    (NOT (SpeechBusy = 0)) do
  66.                 Delay(15, delayLen);
  67.             myErr := DisposeSpeechChannel (theChannel);
  68.  
  69.         END;    
  70.