Speech recognition does not work Mac OS X

I am trying to implement speech recognition features in a Mac xcode project. I am using the NSSpeechRecognizer class. When I start the project using the following code, I get a window with the message: To use the speech recognition functions, a download of 0 bytes is required. You may have to exit and open the project again after the download is completed. I press the download button, exit and open the project, but nothing changes when I start the project, I get the same window and speech recognition does not work. I would really appreciate any help. Thank you in advance

-(void)awakeFromNib
{
NSArray *cmds = [NSArray arrayWithObjects:@"Sing", @"Jump", @"Roll over", 
nil];
recog = [[NSSpeechRecognizer alloc] init]; // recog is an ivar
[recog setCommands:cmds];
[recog setDelegate:self];
}
- (IBAction)listen:(id)sender
{
if ([sender state] == NSOnState) { // listen
[recog startListening];
} else {
[recog stopListening];
}
}
- (void)speechRecognizer:(NSSpeechRecognizer *)sender didRecognizeCommand:
(id)aCmd
{
if ([(NSString *)aCmd isEqualToString:@"Sing"]) {
NSSound *snd = [[NSSound alloc] initWithContentsOfFile:[[NSBundle mainBundle] 
pathForResource:@"HappyBirthday" ofType:@"aif"] byReference:NO];
[snd play];
return;
}
if ([(NSString *)aCmd isEqualToString:@"Jump"]) {
return;
}
if ([(NSString *)aCmd isEqualToString:@"Roll over"]) {
}
}
+4
source share
1 answer

" " > " ", "" " ". , , NSSpeechRecognizer .

+1

All Articles