如何将NSString转换为语音并将其保存到音频文件? 我希望在事件发生时播放该音频,并将该事件的标题作为通知的声音。
我试过以下:
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
NSString *userName = [[NSUserDefaults standardUserDefaults]valueForKey:@"USER_NAME"];
NSString *string = [NSString stringWithFormat:@"Hello %@, it's time for %@",userName,self.eventNameLbl.text];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:string];
[utterance setRate:AVSpeechUtteranceDefaultSpeechRate];
[synthesizer speakUtterance:utterance];
它转换为语音,但无法保存到文件。