1 #import <AVFoundation/AVFoundation.h> 2 3 // 初始化方法 4 AVSpeechSynthesizer *speech = [[AVSpeechSynthesizer alloc]init]; 5 6 // 设置内容 7 AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString: 8 @"红鲤鱼与绿鲤鱼与驴"]; 9 // 设置语音类型 10 utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"]; 11 12 // 语速 13 utterance.rate = 0.5; 14 15 // 开始朗读 16 [speech speakUtterance:utterance];
时间: 2024-10-01 05:00:52