iOS系统自带有TTS模块,支持多语言。
使用方式如下:
导入AVFoundation库
1 | #import <AVFoundation/AVFoundation.h> |
启动TTS
AVSpeechSynthesizer *av = [AVSpeechSynthesizer new];
AVSpeechUtterance *urrerance = [[AVSpeechUtterance alloc] initWithString:@"科比 kobe bryant"];
urrerance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];
[av speakUtterance:urrerance];