#import <AVFoundation/AVFoundation.h>
// 初始化方法
AVSpeechSynthesizer *speech = [[AVSpeechSynthesizer alloc]init];
// 设置内容
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:
@"红鲤鱼与绿鲤鱼与驴"];
// 设置语音类型
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];
// 语速
utterance.rate = 0.5;
// 开始朗读
[speech speakUtterance:utterance];```
网友评论