【发布时间】:2014-01-13 22:18:37
【问题描述】:
您好,我了解 TTS 仅在 iOS 7 中可用,但我过去通过检查该类是否可用并设法保持与以前版本的兼容性,但使用 AVSpeechSynthesizer 它似乎不起作用,你可以请帮助我在 iOS 7 中使用 TTS 并通过在 iOS 6 中禁用它来保持兼容性,非常感谢。
这是我的代码,但它似乎不起作用
if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)) {
if([AVSpeechSynthesizer class]) {
AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
utterance.rate = AVSpeechUtteranceDefaultSpeechRate/2;
utterance.pitchMultiplier = 0.9;
utterance.preUtteranceDelay = 0;
utterance.postUtteranceDelay = 0;
[synth speakUtterance:utterance];
} else {
// Feature not available, do something else
}
}
我已经在我的项目中链接了 avfoundation 并设置了部署目标 iOS 6,如果它的 iOS 6 崩溃,它似乎只有在 iOS 7 设备上运行时才有效。
这是我收到的错误消息
dyld: Symbol not found: _AVSpeechUtteranceDefaultSpeechRate
【问题讨论】:
-
你是否弱链接了框架?
-
非常感谢,在模拟器中好像可以了!
-
转到“构建阶段”并将“AVFundation”从必需更改为可选......然后瞧!
标签: ios iphone objective-c xcode ios7