Hi
I am having problems with NSSpeechRecognizer.
this is the this is SpeechRecAppDelegate.M file
It give me a warning [recog setDelegate:self]; it says (class SpeechRecAppDelegate does not implement the NSSpeechRecogizerDelegate protocol)
And here is the header file.
Thank you in advance
I am having problems with NSSpeechRecognizer.
this is the this is SpeechRecAppDelegate.M file
Code:
@implementation SpeechRecAppDelegate
@synthesize window;
- (id)init {
self = [super init];
if (self) {
NSArray *cmds = [NSArray arrayWithObjects:@"Forward",
@"Stop", @"Left", @"Right", @"Backwards", @"Roll over", nil];
recog = [[NSSpeechRecognizer alloc] init]; // recog is an ivar
[recog setCommands:cmds];
[recog setDelegate:self];
}
return self;
}
-(void)speechRecognizer:(NSSpeechRecognizer *)sender
didRecognizeCommand:(id)aCmd {
if ([(NSString *)aCmd isEqualToString:@"Forward"]) {
NSLog(@"Forward called");
return;
}
else if ([(NSString *)aCmd isEqualToString:@"Stop"]) {
NSLog(@"Stop called");
return;
}
else if ([(NSString *)aCmd isEqualToString:@"Roll over"]) {
NSLog(@"Rollover called");
// .... some response here...
}
else {
NSLog(@"hello");
}
}
@end
And here is the header file.
Code:
#import <Cocoa/Cocoa.h>
@interface SpeechRecAppDelegate : NSObject {
NSWindow *window;
NSSpeechRecognizer* recog;
}
@property (assign) IBOutlet NSWindow *window;
@end