Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 语音识别器示例_Objective C_Command - Fatal编程技术网

Objective c 语音识别器示例

Objective c 语音识别器示例,objective-c,command,Objective C,Command,好的,我需要这样做: 等待命令,“晚安”。然后运行一个操作 有人能解释一下如何做到这一点吗?试试这个网站: 并修改如下: NSSpeechRecognizer *listen; NSArray *cmds = [NSArray arrayWithObjects:@"goodnight",nil]; listen = [[NSSpeechRecognizer alloc] init]; [listen setCommands:cmds]; [listen setDelegate:self]; [

好的,我需要这样做:

等待命令,“晚安”。然后运行一个操作

有人能解释一下如何做到这一点吗?

试试这个网站:

并修改如下:

NSSpeechRecognizer *listen;
NSArray *cmds = [NSArray arrayWithObjects:@"goodnight",nil];
listen = [[NSSpeechRecognizer alloc] init];
[listen setCommands:cmds];
[listen setDelegate:self];
[listen setListensInForegroundOnly:NO];
[listen startListening];
[listen setBlocksOtherRecognizers:YES];

- (void)speechRecognizer:(NSSpeechRecognizer *)sender didRecognizeCommand:(id)aCmd {
    if ([(NSString *)aCmd isEqualToString:@"goodnight"]) {
        [self performSelector:@selector(goodnightMethod:)];
    }
}
你处理晚安的方法是(根据我写的):

-(void)goodnightMethod:(id)sender {
    //Do stuff here...
}