Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 4 - Speech Manager / Speech Manager Reference
Speech Manager Routines / Starting, Stopping, and Pausing Speech


Legacy Documentclose button

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 the SpeakString function to have the Speech Manager speak a text string.

FUNCTION SpeakString (s: Str255): OSErr;
s
The string to be spoken.
DESCRIPTION
The SpeakString function attempts to speak the Pascal-style text string contained in the string s. 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, a null pointer) to SpeakString, the Speech Manager stops any speech previously being synthesized by SpeakString without generating additional speech. If your application uses SpeakString, it is often a good idea to stop any speech in progress whenever your application receives a suspend event. (Note, however, that calling SpeakString with a zero-length string has no effect on speech channels other than the one managed internally by the Speech Manager for the SpeakString function.)

The text passed to the SpeakString function may contain embedded speech commands.

SPECIAL CONSIDERATIONS
Because the SpeakString function moves memory, you should not call it at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for the SpeakString function are
Trap macroSelector
_SoundDispatch$0220000C

RESULT CODES
noErr0No error
memFullErr-108Not enough memory to speak
synthOpenFailed-241Could not open another speech synthesizer channel

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996