您好,我瞭解TTS僅在iOS 7中可用,但我過去通過檢查該類是否可用,並設法保留了以前版本的兼容性,但使用AVSpeechSynthesizer它似乎不工作,你能幫我使用iOS 7的TTS,並通過在iOS 6中禁用它來保持兼容性,非常感謝。使用iOS 7上的AVSpeechSynthesizer,但保留兼容性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 7設備乳寧時如果它的iOS 6崩潰了。
這裏是錯誤消息我得到
dyld: Symbol not found: _AVSpeechUtteranceDefaultSpeechRate
你有沒有薄弱的聯繫框架? – rmaddy
非常感謝你,在模擬器中它似乎工作! –
轉到「構建階段」並將「AVFundation」從必需變爲可選...和Voila! – TonyMkenu