AVSpeechUtterance

AVSpeechUtterance是iOS中语音合成的类。

AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Hello World"];  //创建语音  Hello World 合成的文本
    utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; //合成英文 嗓音属性
    utterance.rate = 0.5f;    //  播放速率
    utterance.pitchMultiplier = 0.8f;  //改变音调
    utterance.postUtteranceDelay = 0.1f;  //播放下一句是有个短时间的暂停
    AVSpeechSynthesizer *av = [[AVSpeechSynthesizer alloc] init];  //运用合成器
    [av speakUtterance:utterance];            //变成音频输出

输入iOS支持的语言

[AVSpeechSynthesisVoice speechVoices];

你可能感兴趣的:(AVSpeechUtterance)