//判斷版本大于7.0
if ([[[UIDevice currentDevice] systemVersion] integerValue] >= 7.0) {
NSString * tempStr = @"朗讀内容! ";
AVSpeechUtterance * utterance = [AVSpeechUtterance speechUtteranceWithString:[NSString stringWithFormat:@"話秋天氣提醒您:%@", tempStr]];
//速率
utterance.rate = 0.15;
//設定語言
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];
AVSpeechSynthesizer * synthesizer = [[AVSpeechSynthesizer alloc] init];
//擷取目前系統語音 - 語音合成器會生成音頻
[synthesizer speakUtterance:utterance];
}else {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"溫馨提示" message:@"目前系統不支援語音播報" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alertView show];
}
轉載于:https://www.cnblogs.com/yujidewu/p/6187139.html