ADC Home > Reference Library > Technical Q&As > Audio > Carbon >

Not Recommended Documentclose button

Important: The information in this document is Not Recommended and should not be used for new development.

Current information on this Reference Library topic can be found here:

Capturing Speech Manager Output

Q Is it possible to capture the output from the Speech Synthesis Manager so I can save it to a file or modify it?

A There is no direct provision in the Speech Synthesis Manager for doing this; however, it is possible if you are willing to do it in a roundabout fashion.

The Speech Synthesis Manager, via the soSoundOutput selector, has the ability to direct speech to any arbitrary sound output device. Because the Speech Synthesis Manager speaks by creating buffers of speech and then playing those buffers via the Sound Manager, it can use the Sound Manager's ability to direct sounds to a specific sound output component.

This feature was designed so that the Speech Synthesis Manager could speak over the phone, but it is not limited to just talking over the phone. If you create a sound output component that saves the sounds played to it (either to memory or to a file), you can have the Speech Synthesis Manager speak to this sound output component and use it to capture the Speech Synthesis Manager's output. From here, you can do whatever you want with the captured sound.

A DTS sample called AIFF-Writer is a sample sound output component that saves whatever sound is played through it to an AIFF file, so this is a good starting point for the sound output component.

The Component Manager allows you to register a component from any resource file. Normally components are in separate files placed in the Extensions folder, but this is not a requirement. For instance, your component can reside in your application's resource fork rather than in a separate file. Furthermore, the Component Manager allows you to register a component locally so that it is available only to your application and the Mac OS. This ability allows for the stealthy use of the AIFF-Writer component (or any other component). The user does not ever have to know that you have installed your custom version of the AIFF-Writer component. You can install it, select it, use it, and unregister it--all without the user ever knowing that anything interesting happened.

Note: The installation of your custom sound output component does not affect the normal playing of sounds from your application or any other application. Only sounds that are specifically directed to your custom sound output component will play through it.


Note: When sounds are being played to your custom sound output device component, they are not heard (because they are not going to the default sound output component). If you want them to be heard, you will have to play the sound twice, once to the default sound output device (so it can be heard), and once to your custom output device (so it can be captured). The Sound Manager will allow you to play a sound simultaneously to multiple different output components, so playing the sound twice does not require any extra time.

Here is some sample code that shows how to install and use your custom sound output component with the Speech Synthesis Manager:

    OSErr                   theErr              = noErr;
    ComponentDescription    writerOutputDev;
    Component               theWriterComponent  = 0;
    SpeechChannel           theWriterSpeechChan = nil;

    // Load the AIFF-Writer component resources from our resource fork
    numCompsReg = RegisterComponentResourceFile (CurResFile(), 0);

    writerOutputDev.componentType = kSoundOutputDeviceType;
    writerOutputDev.componentSubType = 'AIFW';
    writerOutputDev.componentManufacturer = kAppleManufacturer;
    writerOutputDev.componentFlags = 0;
    writerOutputDev.componentFlagsMask = 0;

    // Find AIFF-Writer's component instance
    theWriterComponent = FindNextComponent (0, &writerOutputDev);

    theErr = NewSpeechChannel (nil, &theWriterSpeechChan);
    if (theErr != noErr)
        return theErr;

    // Change output device to talk through AIFF-Writer
    theErr = SetSpeechInfo (theWriterSpeechChan, soSoundOutput, &theWriterComponent);

Further References


[May 18 1998]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.