iOS10 苹果开放SIri API,SiriKit的功能非常强大,支持音频、视频、消息发送接收、搜索照片、预订行程、管理锻炼等等。
#import <Speech/Speech.h>
@interface ViewController () <SFSpeechRecognizerDelegate>
/**
* 1. 先导入Speech.framework的框架
* 2. 导入头文件设置代理
* 3. 声明语音识别器
* 4. 授权
*/
@property (strong, nonatomic) IBOutlet UIButton *siriBtn;//siri按钮
@property (strong, nonatomic) IBOutlet UITextView *siriTextView;//显示语音转化成文字
@property(nonatomic,strong)SFSpeechRecognitionTask *recongnitionTask;//语音识别任务
@property(nonatomic,strong)SFSpeechRecognizer *speechRecognizer;//语音识别器
@property(nonatomic,strong)SFSpeechAudioBufferRecognitionRequest *recongnitionRequest;//语音识别请求
@property(nonatomic,strong)AVAudioEngine *audioEngine;//录音引擎
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a