将AVspeechSynthsis话语转换为aiff文件或音频文件并保存到文件

时间:2017-05-06 06:57:50

标签: ios text-to-speech uilocalnotification avspeechsynthesizer

如何将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];

它转换为语音,但无法保存到文件。

0 个答案:

没有答案