语音播报

项目中用到了语音播报推送内容,发现iOS7以后系统支持语音播报.记下用以备用

#import 
@implementation declarer
-(void)playWith:(NSString *)textString volume:(float)volume rate:(float)rate pitchMultiplier:(float)pitchMultiplier{
//创建一个AVSpeechSynthesizer对象用来播放AVSpeechUtterance对象
    AVSpeechSynthesizer *AVSS = [[AVSpeechSynthesizer alloc]init];
    AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc]initWithString:textString];  //需要播报的文本
    utterance.volume = volume; //播报的音量
    utterance.voice=[AVSpeechSynthesisVoice voiceWithLanguage:@"zh-TW"];//设置语言
    utterance.rate = rate;//播报语调频率
    utterance.pitchMultiplier = pitchMultiplier;//播报音调
    [AVSS speakUtterance:utterance];
}


@end

你可能感兴趣的:(语音播报)