Reputation: 305
I'm playing with NSSpeechSynthesizer class but for some reason the sound doesn't play. Here is the source code I use
#import <Foundation/Foundation.h>
#import <AppKit/`NSSpeechSynthesizer.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSSpeechSynthesizer *sp = [[NSSpeechSynthesizer alloc] init];
[sp setVolume:100.0];
[sp startSpeakingString:@"Just testing"];
}
return 0;
}
And yes the speakers are on
Upvotes: 1
Views: 465
Reputation: 7390
Your app is exiting before it has a chance to actually play the sound. You can check this by adding an infinite loop into your code:
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSSpeechSynthesizer *sp = [[NSSpeechSynthesizer alloc] init];
[sp setVolume:100.0];
[sp startSpeakingString:@"Just testing"];
while(YES);
}
return 0;
}
Upvotes: 1