views:

33

answers:

2

Hi all,

I noticed NSSpeechRecognizer in ADC library and I found it to be very interesting, so to play with it I prepared a simple application which will just listen the command and if recognized it displays it in log.

The code used is:

- (id)init {

    if (self = [super init]) {
        // Insert code here to initialize your application 
        NSArray *cmds = [NSArray arrayWithObjects:@"A",@"B", @"C",@"alpha",@"beta",@"vodka",@"wine",nil]; 
        recog = [[NSSpeechRecognizer alloc] init]; // recog is an ivar
        [recog setCommands:cmds];
        [recog setDelegate:self];
    }
    return self;
}

- (IBAction)listen:(id)sender
{   NSLog(@"listen:");
    if ([sender state] == NSOnState) { // listen
        [recog startListening];
    } else {
        [recog stopListening];
    }
}

- (void)speechRecognizer:(NSSpeechRecognizer *)sender didRecognizeCommand:(id)aCmd {
    NSLog(@"speechRecognizer: %@",(NSString *)aCmd);
}

I tried it many times for the commands registered but I was unable to get none of the messages in log, in delegate :(

There was always some noise in the background.. could this be the reason for it or I have done something wrong in the code??

Can anyone suggest me some solution for it??

Thanks,

Miraaj

+1  A: 

Code looks fine so far.

The NSSpeechRecognizer is a bit tricky sometimes and refuses to listen to the right words. Did you try different words?

Did you try setting startListening as default?

I wrote a little tutorial some time ago. Its in german language but maybe it will help you anyway or you use some translation tool.

http://cocoa-coding.de/spracherkennung/nsspeechrecognizer1.html

Holli
A: 

Can we use NSSpeechRecognizer to develop iPhone app?

ZaldzBugz