home *** CD-ROM | disk | FTP | other *** search
/ Astra Blaster / Astra.cdr / voice / hearsay8.txt < prev    next >
Text File  |  1992-04-08  |  20KB  |  483 lines

  1.                            PART II
  2.  
  3.                     HEARSAY PROGRAMMER'S GUIDE
  4.  
  5.                          INTRODUCTION
  6.  
  7.      Hearsay Gold  allows programmers  to call  speech functions  directly from
  8. programs they write, without going through  the Hearsay menus.  These functions
  9. can be called directly from assembly language or by  high level languages  with
  10. register-access  capability such as "C".  For programmers  working in BASIC, an
  11. assembly-language driver program is included on the Hearsay Gold diskette.  The
  12. available functions are:
  13.  
  14.           - SPEAK A LINE OF TEXT
  15.           - SET SCREEN ECHO PARAMETERS
  16.           - SET SCREEN ECHO WINDOW
  17.           - UNHOOK HEARSAY FROM DOS
  18.           - LOAD DICTIONARY
  19.           - GET VERSION NUMBER
  20.  
  21.      Examples are given in BASIC and Assembly Language.  For BASIC programmers,
  22. sample code segments are provided, which when copied directly into your program
  23. will call the Hearsay driver  program and exercise the  programmable functions.
  24.  
  25.           CALLING HEARSAY FUNCTIONS FROM BASIC
  26.  
  27.      To access Hearsay Gold  functions from BASIC programs,  a machine language
  28. "Driver"  program  must  be  called  from  BASIC.  A  multiple  function driver
  29. (HSGOLDDR.BAS) is supplied on the Hearsay Gold diskette.
  30.  
  31.      In order to use  the Hearsay functions,  your BASIC program  must load the
  32. driver program into high memory,  and then "Call" the driver  for each function
  33. required.
  34.  
  35.      To load the driver into high memory:
  36.  
  37.      1. When loading BASIC, reserve memory for the driver by using a /M switch.
  38.  
  39.      Type in: BASIC/M:65024 (BASICA/M:65024 if you use BASICA) then
  40.  
  41.      2. Include the  following lines  in your  program to  load the driver into
  42.         memory:
  43.  
  44.           10 REM LOAD HEARSAY DRIVERS
  45.           20 DEF SEG
  46.           30 HSBASE=65024!               :REM This must be equal to the
  47.           40                             :REM number used in the /M switch
  48.           50 BLOAD "HSGOLDDR",HSBASE
  49.           60 
  50.           70                             :REM INITIALIZE HEARSAY FUNCTIONS
  51.           80 SAYSTR=HSBASE+256!          :REM Location of SAYSTR Driver
  52.           90 BUFFER=HSBASE               :REM Location of SAYSTR Buffer
  53.          100 SETSCRENCHO=HSBASE+272!     :REM Location of SETSCRENECHO
  54.          110 SETWINDOW=HSBASE+321!       :REM Location of SET WINDOW
  55.          120 UNHOOK=HSBASE+352!          :REM Location of UNHOOK HS
  56.          130 LOADDICT=HSBASE+388!        :REM Location of LOAD DICTIONARY
  57.          140 GET VERSION+HSBASE+411!     :REM Location of GET VERSION
  58.  
  59.      Once the driver is loaded, each Hearsay function  can be called by setting
  60. the proper values & then calling the  desired function from the Hearsay driver. 
  61.  
  62.      SPEAK A LINE OF TEXT
  63.  
  64.      The SAYSTR function speaks  a line (String) of text.  In the BASIC program
  65. example given below,  this is a line of text  typed at the keyboard in response 
  66. to a  prompt,  but  it  could  have  been  hard  coded  into  the  program  (By
  67. initializing A$ as the string to be spoken).
  68.  
  69.      PROGRAMMING IN BASIC
  70.  
  71.      The BASIC program segment below calls for the SAYSTR function.
  72.  
  73.           100 REM Input a line of text from the keybaord and speak it.
  74.           110 SAYSTR=HSBASE+256!                  :REM Location of SAY driver
  75.           120 BUFFER=HSBASE                       :REM Location of BUFFER
  76.           130 INPUT A$                            :REM Get line from keyboard
  77.           140 A$=A$+"."                           :REM Add period and space
  78.           150 POKE BUFFER,LEN(A$)                 :REM Store length of line
  79.           160 FOR N=1TOLEN(A$)                    :REM Store line in buffer     
  80.           170 POKE BUFFER+N,ASC(MID$(A$,N,1))
  81.           180 NEXT N
  82.           190 CALL SAYSTR                         :REM Speak line
  83.  
  84.      Lines 110-120 establish the parameters for the SAYSTR function.  Once that
  85. has been done,  it is not necessary to  do it again each time a string is to be
  86. spoken it remains available  to you until you  redfine it or leave the program.
  87.  
  88.      Lines 130-140 accept input keystrokes to define the string to be spoken, &
  89. put a period & space at the end of it.  If you were hard coding the string into
  90. your program you would replace these lines with a string defining A$, including
  91. the period and space in the definition (ie. 130 A$="THIS IS A TEST.").
  92.  
  93.      Line 150 pokes the length of the string  into the beginning  of the buffer
  94. and lines 160-180 poke the characters of the string into the buffer.  This must
  95. done for each string you want Hearsay to speak.
  96.  
  97.      Once the string  has been defined  and poked into  the proper  location in
  98. memory, line 190 calls the SAYSTR function which speaks the phrase.
  99.  
  100.           PROGRAMMING IN ASSEMBLER
  101.  
  102.      The SAYSTR function speaks the text string passed to it. The first byte of
  103. the string must contain the  length of the string.  You must allocate 256 Bytes
  104. for the string even if the length is less than 256 Bytes.
  105.  
  106.           USE
  107.  
  108.      1. First push a FAR pointer to string onto the stack.
  109.      2. The call Hearsay Gold with a function code of  00h in the AL  register.
  110.      3. Upon return, pull all parameters from the stack.
  111.  
  112.           SAY STRING EXAMPLE
  113.  
  114.      DATA            SEGMENT WORD PUBLIC 'DATA'
  115.  
  116.      String          EQU     $
  117.                      DB      24d
  118.                      DB      'I am the Hearsay Gold'
  119.                      DB      13d
  120.  
  121.      DATA            ENDS
  122.  
  123.      CODE            SEGMENT BYTE PUBLIC 'CODE'
  124.                      ASSUME CS:CODE,CS:DATA
  125.  
  126.      Say demo        PROCEDURE     NEAR
  127.  
  128.                      mov   ax,ds      ;Push far pointer to STRING
  129.                      push  ax         ;onto the stack.
  130.                      mov   ax,offset String
  131.                      push  ax
  132.                      mov   al,00h     ;Call the Hearsay Gold with
  133.                      int   55h        ;a function code of 00h.
  134.                      pop   ax         ;Pull parameters from stack.
  135.                      pop   ax
  136.                      ret
  137.      Say demo        ENDP
  138.  
  139.      CODE            ENDS
  140.                      END
  141.  
  142.           SET SCREEN ECHO PARAMETERS
  143.  
  144.      The SETSCRENECHO function set Screen Echo ON or OFF,  defines punctuation,
  145. voice, pitch, and speed for both the Screen Echo and the Say String  functions.
  146. If SETSCRNECHO is never called,  Hearsay will default to voice 1, pitch 6,  and
  147. speed 7 for Say String functions.
  148.  
  149.           PROGRAMMING IN BASIC
  150.  
  151.      In the BASIC program sample given below, Screen Echo is set on & the other
  152. parameters are set  to their default  values  (All parameters  must be included
  153. when SETSCRNECHO is called,  even if they are to be set to the default values).
  154.  
  155.      100 SETSCRNECHO=HSBASE+272!     :REM Location of SETSCRNECHO
  156.      110 ECHO%=1                     :REM Set ECHO on (0 would be off)
  157.      120 PUNCT$=0                    :REM Don't speak punctuation
  158.      130 LM%=0                       :REM Set Line Mode off
  159.      140 VOICE%=1                    :REM Use voice 1
  160.      150 PITCH%=6                    :REM Use pitch 6
  161.      160 SPEED%=7                    :REM Speed 7
  162.      170 CALL SETSCRENECHO
  163.               (ECHO%,PUNCT%,LM%,VOICE%,PITCH%,SPEED%)
  164.      180 REM Screen Echo is now set as indicated above
  165.  
  166.      Line 100  establishes  the  location  of  SETSCRENECHO,  the  Screen  Echo
  167. function in the Hearsay driver. This line needs to  occur once in your program,
  168. the location will be maintained until you leave the program.
  169.  
  170.      Lines 110-160 establish the  conditions to be implemented.  It's necessary
  171. to enumerate all conditions every time you change any one.
  172.  
  173.      Line 170 calls  the SETSCRNECHO driver  and establishes the conditions you
  174. described in lines 110-160.  This command will be included at any point in your
  175. program where you want to change to Screen Echo settings.
  176.  
  177.           PROGRAMMING IN ASSEMBLER
  178.  
  179.      USE
  180.  
  181.      1. First push an integer  (1 to 9, 1 is slowest, 7 is default)  to specify
  182.         speed.
  183.  
  184.      2. Next push an integer  (1 to 9,  1 is slowest, 6 is default)  to specify 
  185.         pitch.
  186.  
  187.      3. Then push an integer (1 or 2, 1 is lower and default) to specify voice.
  188.  
  189.      4. Next push an integer (1 or 0, 0 is off & default) to specify line mode.
  190.   
  191.      5. Then  push  an  integer  (1 or 0,  0 is off  and  default)  to  specify
  192.         punctuation mode.
  193.  
  194.      6. Next push an integer  (1 or 0, 0 is off and default)  to specify screen
  195.         echo.
  196.  
  197.      7. Now call Hearsay Gold with a function code of  01h in the AL  register.
  198.  
  199.      8. Upon return, pull all parameters from stack.
  200.  
  201.           SET SCREEN ECHO EXAMPLE
  202.  
  203.      CODE          SEGMENT BYTE PUBLIC 'CODE'
  204.                    ASSUME CS:CODE
  205.  
  206.      Set echo      PROCEDURE        NEAR
  207.  
  208.                    push    bp       ;Save stack pointer
  209.                    mov     bp,sp
  210.                    mov     ax,7     ;Speed=7
  211.                    push    ax
  212.                    mov     ax,6     ;Pitch=6
  213.                    push    ax
  214.                    mov     ax,1     ;Voice=1
  215.                    push    ax
  216.                    mov     ax,0     ;Line mode off
  217.                    push    ax
  218.                    mov     ax,0     ;Punctuation mode off
  219.                    push    ax
  220.                    mov     ax,1     ;Screen echo on
  221.                    push    ax
  222.                    mov     al,01h   ;Call the Hearsay Gold with a
  223.                    int     55h      ;function code of 01h
  224.                    mov     sp,bp    ;Remove parameters from stack
  225.                    pop     bp
  226.                    ret
  227.      Set echo      ENDP
  228.      CODE          ENDS
  229.                    END
  230.  
  231.           SET WINDOW
  232.  
  233.      The SETWINDOW function sets  Hearsay's Screen Echo window parameters.  The
  234. function defines the top & bottom lines of the window,  and whether text inside
  235. or outside of  it is to  be echoed.  Remember,  text will  only be  spoken when
  236. Screen Echo is turned on.
  237.  
  238.           PROGRAMMING IN BASIC
  239.  
  240.      The BASIC program segment below calls the Set Window function.
  241.  
  242.      100 REM speak text from lines 10 to 15.
  243.      110 SETWINDOW=HSBASE+321!:REM Location of SETWINDOW.
  244.      120 MODE%=1:              REM Speak text inside window.
  245.      130 TOP%=10:              REM From line 10 to 15
  246.      140 BOTTOM%=15
  247.      150 CALL SETWINDOW (MODE%,TOP%,BOTTOM%)
  248.  
  249.      Line 110 establishes the location of the SETWINDOW function.  This command
  250. only needs to be executed once within your program.
  251.  
  252.      Lines 120-140 set window parameters  of inside or outside, top and bottom.
  253.  
  254.      Line 150 calls the SETWINDOW function and implements the parameters set in
  255. lines 120-140. This line will  be used whenever it  is necessary  to change the
  256. Hearsay window settings.
  257.  
  258.           PROGRAMMING IN ASSEMBLER
  259.  
  260.      USE
  261.  
  262.      1. First, push  an integer  (1 to 25, 25 is the bottom  row of the screen)
  263.         specifying the bottom row of the window.
  264.  
  265.      2. Next push an integer (1 to 25, 1 is the top row) specifying the top row
  266.         of the window.
  267.  
  268.      3. Then push an integer (0 or 1, 1 is inside) specifying the mode (Whether
  269.         text inside or outside the window is to be spoken).
  270.  
  271.      4. Now call Hearsay Gold with a function of 2 in the AL register.
  272.  
  273.      5. Upon return pop all parameters from the stack.
  274.  
  275.           SET WINDOW EXAMPLE
  276.  
  277.      CODE     SEGMENT BYTE PUBLIC 'CODE'
  278.               ASSUME CS:CODE
  279.  
  280.      WINDOW   PROCEDURE          NEAR
  281.               mov     ax,20d     ;Only speak text printed from
  282.               push    ax         ;Line 10 to line 20
  283.               mov     ax,10d
  284.               push    ax
  285.               mov     ax,1       ;Set mode to speak inside window
  286.               push    ax
  287.               mov     al,02h     ;Call the HEARSAY GOLD with a
  288.               int     55h        ;function code of 02h
  289.               pop     ax         ;Pull parameters from stack
  290.               pop     ax
  291.               pop     ax
  292.               ret
  293.      WINDOW   ENDP
  294.      CODE     ENDS
  295.               END
  296.  
  297.           UNHOOK HEARSAY FROM DOS
  298.  
  299.      This command "Unloads" the Hearsay Gold program, removing all hooks to DOS 
  300. and returning all reserved memory to DOS.
  301.  
  302.      To rerun Hearsay after unhooking,  you must rerun the SpeechV2 or SPEECHV3
  303. and Hearsay programs and redefine the Hearsay Key as you  normally do at setup.
  304.  
  305.           PROGRAMMING IN BASIC
  306.  
  307.      The BASIC program segment below shows the Unhook function in use.
  308.  
  309.      100 REM Unhook the HSGOLD from DOS
  310.      110 UNHOOKHS=HSBASE+352!:        REM Location of UNHOOK HS.
  311.      120 CALL UNHOOKHS:               REM Unhook HSGOLD from DOS.
  312.  
  313.      Line 110 established the location of the Unhook function (Only needs to be
  314. done once) and line 120 calls the function.
  315.  
  316.           PROGRAMMING IN ASSEMBLER
  317.  
  318.      USE
  319.  
  320.      1. Issue a call to the Hearsay Gold  with a function  code of 3  in the AL
  321.         register.
  322.  
  323.      2. No parameters are passed or returned.
  324.  
  325.      UNHOOK EXAMPLE
  326.  
  327.      CODE    SEGMENT BYTE PUBLIC 'CODE'
  328.              ASSUME CS:CODE
  329.      UNHOOK  HS   PROCEDURE     NEAR
  330.              mov     al,03h  ;Call the Hearsay Gold with
  331.              int     55h     ;a function code of 03h
  332.              ret
  333.      UNHOOK  HS   ENDP
  334.      CODE    ENDS
  335.              END
  336.  
  337.           LOAD DICTIONARY
  338.  
  339.      This command loads a dictionary file (Created with the Speech Editor) from
  340. disk.
  341.  
  342.           PROGRAMMING IN BASIC
  343.  
  344.           An example of its use is given below:
  345.  
  346.      100 REM load dictionary file SAMPLE.
  347.      110 LOADDICT=HSBASE+388!:          REM Location of Load Dictionary
  348.      120 BUFFER=HSBASE:                 REM Location of buffer
  349.      130 FILENAME$="SAMPLE":            REM Name of file to load
  350.      140 FLAG%=0:                       REM Initialize ERROR
  351.      150 POKE BUFFER,LEN(FILENAME$):    REM Store length of filename
  352.      160 FORN=1TOLEN(FILENAME$):        REM Store filename in buffer
  353.      170 POKE BUFFER+N,ASC(MID$(FILENAME$,N,1))
  354.      180 NEXT N
  355.      190 CALL LOADDICT(FLAG%):          REM Load the file
  356.      200 IF FLAG%=0THEN220:             REM If error then print message
  357.      210 PRINT "ERROR LOADING FILE"
  358.      220 END
  359.  
  360.      Lines 110-120 establish the location of the LOADDICT function  (Only needs
  361. to be done once), line 130 provides the filename of the dictionary file, & line
  362. 140 initializes the error flag.
  363.  
  364.      Lines 150-180 poke the filename into the buffer, & line 190 actually calls
  365. the LOADDICT function which loads the specified dictionary in Hearsay's memory.
  366.  
  367.      The LOADDICT function  will check for  errors in loading  the file and set 
  368. the FLAG% variable if  any are encountered. Lines 200-210  check for errors and
  369. print an  error message  on the  screen if  one is  encountered.  (In  your own
  370. program, you may choose to  handle file loading  errors in some  other way, but 
  371. you will still test it by checking the value of FLAG%).
  372.  
  373.           PROGRAMMING IN ASSEMBLER
  374.  
  375.      The LOADDICT function is called with a FAR pointer  to the filename on the
  376. stack.  The filename can be  any legal DOS filename without the file extension,
  377. which Hearsay Gold will add automatically.
  378.  
  379.      If the file is to be loaded from other than the current drive & directory,
  380. an optional path name must be included with the filename.
  381.  
  382.      If the file loads OK, 0 will be returned in the AX register.  If there was
  383. an error in loading  the file, a non-zero  value will be  returned. Use the DOS
  384. function call 59h (GET EXTENDED ERROR) to get further information on the error.
  385.  
  386.      USE
  387.  
  388.      1. Push a FAR pointer to the filename onto the stack.
  389.  
  390.      2. Call Hearsay Gold with the function code 05h in the AL register.
  391.  
  392.      3. Upon return, pull all parameters from the stack.
  393.  
  394.      LOAD DICTIONARY EXAMPLE
  395.  
  396.      DATA          SEGMENT WORD PUBLIC 'DATA'
  397.  
  398.      filename      EQU   $
  399.                    DB    10d          ;Length of filename
  400.                    DB    C:\HS\DEMO   ;Filename with drive C and directory HS
  401.  
  402.      DATA          ENDS
  403.      CODE          SEGMENT BYTE PUBLIC 'CODE'
  404.                    ASSUME CS:CODE,DS:DATA
  405.  
  406.      Load dict     PROCEDURE NEAR
  407.                    push   bp          ;Save stack pointer
  408.                    mov    bp,sp
  409.                    mov    ax,ds       ;Push far pointer to filename
  410.                    push   ax
  411.                    mov    ax,offset filename
  412.                    push   ax
  413.                    mov    al,05h      ;Call the Hearsay Gold with a
  414.                    int    55h         ;function code of 05h
  415.                    mov    sp,bp       ;Remove filename from stack
  416.                    pop    bp
  417.                    cmp    pax,0       ;Error?
  418.                    je     Done        ;no,exit
  419.                    mov    bx,0h       ;DOS version #
  420.                    mov    ah,59h      ;Get extended error information
  421.                    int    21h         ;Process error
  422.      Done:
  423.                    ret
  424.      Load dict     ENDP
  425.      CODE          ENDS
  426.                    END
  427.  
  428.           GET VERSION NUMBER
  429.  
  430.      This command  extracts the  version of  Hearsay Gold currently being used.
  431. This permits software  developers to check version  number and version level as
  432. part of  their program. Hearsay is committed  to upward compatibility,  so that
  433. any program written for the Hearsay  Gold will run on any later version. If you
  434. are developing  programs to  use Hearsay, check  that the version  number is no
  435. lower than the one you used for development.
  436.  
  437.      The Version ID codes for Hearsay Gold versions 2 and 3 are 0300h and 0400h
  438. respectively. The first two digits indicate the product code,  and the last two
  439. indicate the release number of that product. Release 2 of Version 2 will have a
  440. Version ID of 0301h or 769 decimal.
  441.  
  442.           PROGRAMMING IN BASIC
  443.  
  444.      The program segment below shows the function in use.
  445.  
  446.      100 REM Display the HSGOLD version number.
  447.      110 HSVERSION=HSBASE+411!:           REM Location of GET VERSION
  448.      120 VERSION%=0:                      REM Initialize number.
  449.      130 CALL HSVERSION (VERSION%):       REM Get version number.
  450.      140 IF VERSION%=768 THEN PRINT "VERSION 2"
  451.      150 IF VERSION%=1024 THEN PRINT "VERSION 3"
  452.  
  453.      Line 110 locates the GET VERSION function (Only needs to be done once) and
  454. line 120 initializes VERSION to 0.                
  455.  
  456.      Line 130  actually  calls the  GET VERSION  function,  returning a version
  457. number of 768 if Version 2 is loaded or 1024 if Version 3 is loaded. Lines 140-
  458. 150 test  to see which  version is loaded,  in the  example given  printing the
  459. version number.
  460.  
  461.           PROGRAMMING IN ASSEMBLER
  462.  
  463.      The product  code is  returned in  register AH  and the  release number is
  464. returned in register AL.
  465.  
  466.      USE
  467.  
  468.      1. Call Hearsay Gold with function code 06h in the AL register.
  469.  
  470.      2. The Version ID will be returned in register AX.
  471.  
  472.           GET VERSION EXAMPLE
  473.  
  474.      CODE          SEGMENT BYTE PUBLIC 'CODE'
  475.                    ASSUME CS:CODE
  476.  
  477.      Get version   PROCEDURE NEAR
  478.                    mov     al,06h    ;Call the Hearsay Gold with a
  479.                    int 55h           ; function code of 06h
  480.                    ret
  481.      Get version   ENDP
  482.      CODE          ENDS
  483.                    END