The say instruction plays ASCII text stored in a buffer.
Synopsis
say(ctype.src)
Description
The say instruction instructs the system to speak ASCII text stored in a buffer. The ctype.src argument specifies the ASCII text string to be spoken. The script may pass text as a literally quoted string or the contents of a null-terminated field (for example, previously populated with a call to the dbase instruction). The maximum length of a literal string is 2048 characters.
Say is similar to the talk instruction used for phrases of coded speech. The text passed to say is stored in a buffer that holds up to 2048 bytes of text. This buffer is flushed and the text is played when the buffer is full and another say instruction is executed or when any wait-causing instruction is executed.
The tflush instruction may be used to flush the TTS buffer and cause the text to play. The first two arguments to tflush, the must_hear_flag and the wait_indicator, have the same effect for text-to-speech as for coded speech. The third argument to tflush, the remember_flag, is not used for TTS. That is, the first argument may be used to disable talkoff and the second may be used to play speech and to continue the script without waiting for the play to complete. Normally, TSM waits for a TTS play to complete before going to the next instruction. Spinning off a TTS play, then executing dbase to get the next block of text while the first block is playing avoids a delay in play between the two blocks of text. Scripts may continue executing alternate say, tflush, and dbase calls in this manner until all the text from a DIP is passed to say to be played.
The say instruction returns one of following values in script register 0 (r.0):
Return value |
Description |
0 |
The say instruction completed successfully. |
-1 |
The say instruction failed. This happens if the text passed to say did not fit into one TTS buffer (2048 bytes). |
As with coded speech, any text-to-speech being played stops when the script that caused it terminates or executes a tstop instruction.
Examples
In the following example, the text for both of the say instructions is sent to the speech resource for analysis. Eventually, the text is spoken as synthesized voice.
/* Need to append a space to text continued */
/* in next say() instruction */
say("For everything there is a season, ")
say("and a time for every purpose under heaven.")
tflush()
In the following example, the say instruction uses the DEALER name obtained in the dbase call for spoken output. Make sure that the DEALER is not null or the say instruction has nothing to output.
#define DIPmsg 100
#define DEALER 124 /* assuming text is at 24 byte
/* offset in message */
dbase(DIP, GET_DEALER, ch.DIPMSG, 100, 0, 0)
talk("The name and address of your local dealer is")
say(ch.DEALER)
tflush()
See also