1. 程式人生 > >[iOS]AVSpeechSynthesizer語音合成

[iOS]AVSpeechSynthesizer語音合成

初始化 bsp string span str lan peak with rate

 1 #import <AVFoundation/AVFoundation.h>
 2 
 3 // 初始化方法
 4 AVSpeechSynthesizer *speech = [[AVSpeechSynthesizer alloc]init];
 5 
 6 // 設置內容
 7 AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:
 8                                 @"紅鯉魚與綠鯉魚與驢"];
 9 // 設置語音類型
10 utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"
zh-CN"]; 11 12 // 語速 13 utterance.rate = 0.5; 14 15 // 開始朗讀 16 [speech speakUtterance:utterance];

[iOS]AVSpeechSynthesizer語音合成