[iOS]AVSpeechSynthesizer語音合成

#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];
相關文章
相關標籤/搜索