gpt4 book ai didi

objective-c - NSSpeechRecognizer 示例

转载 作者:太空狗 更新时间:2023-10-30 03:49:11 25 4
gpt4 key购买 nike

好的,我需要这样做:

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

谁能解释一下如何做到这一点?

最佳答案

试试这个网站:

http://www.cocoadev.com/index.pl?NSSpeechRecognizer

并这样修改:

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...
}

关于objective-c - NSSpeechRecognizer 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6104484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com