Posted this on Twitter a week back, but maybe it’s of some interest to blog readers; here’s how to do simple voice synthesis on the iPhone 3GS (3GS-only, I’m afraid). It’s a private API, but hopefully if we file enough Radars they’ll make it a public one.
To enable the following code to work you’ll need to link the VoiceServices.framework
(from the PrivateFrameworks folder of the SDK) in your app.
NSObject *v = [[NSClassFromString(@"VSSpeechSynthesizer") alloc] init];
[v startSpeakingString:@"All your base are belong to us"];
Apologies for my lazy ‘NSObject’ define above, but you get the idea :-)
With that, you have simple speech synthesis for your application (obviously you cannot include this when you submit to the App Store as it links to a private framework, but you can use it in your internal applications). It requires the 3GS because the Speech stuff just isn’t in the firmware for the older devices.