#import "ViewController.h"
#import <AVFoundation/AVSpeechSynthesis.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(IBAction)haha:(id)sender{
synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance =
[AVSpeechUtterance speechUtteranceWithString:@"那一年我25岁,刚考入博士班,一边修习学位,一边创作,已经出版了第一本小说集《海水正蓝》,并且因为难以预料的畅销状况,引人侧目。我很安逸于古典世界与学院生活,那里我是小小的桃花源,我可以安静地圈点和阅读,把自己潜藏起来,遇见一个巧妙的词句,便可赞叹玩味许久,得到很大的喜悦。不知从哪里看见形容男子“身形伟岸”的词,狠狠琢磨一回,那是怎样的形象呢?我们中文系的教授们,有温文儒雅的,有玉树临风的,孤傲遗世的,但,都称不上伟岸,我心中仿佛有着对于伟岸的认识,只是难以描摹。寒假以后,我遇见了这样一位大学教授,高大壮硕,行动从容,微微含笑,为我们讲授诗词,因为曾经是体育系的,他看起来不同一般的中文系气质。每个周末,我们都要到老师家里上课,大家围着餐桌,并不用餐,而是解说一首诗或者一阕词。看见他朗然笑语,喷吐烟雾,我悄悄想着,这就是一个伟岸男子了吧?四十岁的老师,当时在学术界是很活跃的"];
utterance.rate = AVSpeechUtteranceMaximumSpeechRate / 2.0f;
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"ch-ch"]; // defaults to your system language Examples: en-US (U.S. English), fr-CA (French Canadian) ch-ch
[synthesizer speakUtterance:utterance];
}
-(IBAction)poust:(id)sender{
// [synthesizer stopSpeakingAtBoundary:AVSpeechBoundaryWord];
[synthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryImmediate];
}
-(IBAction)goon:(id)sender{
[synthesizer continueSpeaking];
}
-(IBAction)stopvoice:(id)sender{
[synthesizer stopSpeakingAtBoundary:AVSpeechBoundaryWord];
}
@end