iOS 文字转语音
#import <AVFoundation/AVFoundation.h>
- (void)readText(NSString *)txtContent{
AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-TW"]; //en-US
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:txtContent];
utterance.voice = voice;
utterance.rate = ([UIDevice currentDevice].systemVersion.doubleValue>=9.0) ? 0.5 : 0.2; //0.4;
//utterance.pitchMultiplier = 2.0;//语调 0.5-2.0
AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
[speechSynthesizer speakUtterance:utterance];
}
本文标题:iOS 文字转语音
本文链接:https://www.haomeiwen.com/subject/gbkrlqtx.html
网友评论