Important: Inside Macintosh: Sound is deprecated as of Mac OS X v10.5. For new audio development in Mac OS X, use Core Audio. See the Audio page in the ADC Reference Library.
SpeakString
You can use theSpeakString
function to have the Speech Manager speak a text string.
FUNCTION SpeakString (s: Str255): OSErr;
s
- The string to be spoken.
DESCRIPTION
TheSpeakString
function attempts to speak the Pascal-style text string contained in the strings
. Speech is produced asynchronously using the default system voice. When an application calls this function, the Speech Manager makes a copy of the passed string and creates any structures required to speak it. As soon as speaking has begun, control is returned to the application. The synthesized speech is generated asynchronously to the application so that normal processing can continue while the text is being spoken. No further interaction with the Speech Manager is required at this point, and the application is free to release the memory that the original string occupied.If
SpeakString
is called while a prior string is still being spoken, the sound currently being synthesized is interrupted immediately. Conversion of the new text into speech is then begun. If you pass a zero-length string (or, in C, anull
pointer) toSpeakString
, the Speech Manager stops any speech previously being synthesized bySpeakString
without generating additional speech. If your application usesSpeakString
, it is often a good idea to stop any speech in progress whenever your application receives a suspend event. (Note, however, that callingSpeakString
with a zero-length string has no effect on speech channels other than the one managed internally by the Speech Manager for theSpeakString
function.)The text passed to the
SpeakString
function may contain embedded speech commands.SPECIAL CONSIDERATIONS
Because theSpeakString
function moves memory, you should not call it at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theSpeakString
function are
Trap macro Selector _SoundDispatch
$0220000C RESULT CODES
noErr 0 No error memFullErr -108 Not enough memory to speak synthOpenFailed -241 Could not open another speech synthesizer channel