Created
April 8, 2013 23:44
-
-
Save janodev/5341598 to your computer and use it in GitHub Desktop.
Text to speech on iOS with private framework.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Not App Store safe. Only available in real devices. | |
#define RTLD_LAZY 0x1 | |
#define RTLD_NOW 0x2 | |
#define RTLD_LOCAL 0x4 | |
#define RTLD_GLOBAL 0x8 | |
NSObject *voiceSynthesizer; | |
void *voiceServices; | |
-(void) say:(NSString*)text { | |
if (!voiceSynthesizer) | |
{ | |
NSString *vsLocation = @"/System/Library/PrivateFrameworks/VoiceServices.framework/VoiceServices"; | |
voiceServices = dlopen(vsLocation.UTF8String, RTLD_LAZY); | |
voiceSynthesizer = [NSClassFromString(@"VSSpeechSynthesizer") new]; | |
} | |
[voiceSynthesizer performSelector:@selector(startSpeakingString:) withObject:text]; | |
} | |
/* | |
@interface VSSpeechSynthesizer : NSObject | |
+ (id)availableLanguageCodes; | |
+ (BOOL)isSystemSpeaking; | |
- (id)startSpeakingString:(id)string; | |
- (id)startSpeakingString:(id)string toURL:(id)url; | |
- (id)startSpeakingString:(id)string toURL:(id)url withLanguageCode:(id)code; | |
- (float)rate; // default: 1 | |
- (id)setRate:(float)rate; | |
- (float)pitch; // default: 0.5 | |
- (id)setPitch:(float)pitch; | |
- (float)volume; // default: 0.8 | |
- (id)setVolume:(float)volume; | |
@end | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment