Vjy
Vjy

Reputation: 2135

iOS 6 - Issue with AVSpeechSynthesizer

Why do I get an error when I run it on iOS6 though I checked for AVSpeechSynthesizer? I am aware that AVSpeechSynthesizer is only available in iOS7

if (NSClassFromString(@"AVSpeechSynthesizer")) {

      AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
      AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Just what do you think you're doing, Dave?"];
      utterance.rate = AVSpeechUtteranceMinimumSpeechRate; // Tell it to me slowly
      [synthesizer speakUtterance:utterance];

}

Upvotes: 0

Views: 530

Answers (2)

Lewis Gordon
Lewis Gordon

Reputation: 1731

I see a similar issue with roughly the same code. The problem on iOS6 is that AVSpeechUtteranceMinimumRate doesn't exist and a dynamic link error is generated when the code is loaded. Comment that line out and the code does actually run on iOS6 but doesn't say anything. I guess it must be that the AV speech code is done differently to other interfaces and you'll need to find another way to decide if it is iOS7.

Upvotes: 2

Abdullah Shafique
Abdullah Shafique

Reputation: 6918

Because AVSpeechSynthesizer is only for iOS 7! In apple developers page for AVSpeechSynthesizer Class Reference:

Availability: Available in iOS 7.0 and later.

Upvotes: 1

Related Questions