Home › Forums › OpenEars › [Resolved] OpenEarsEventsObserver not working properly › Reply To: OpenEarsEventsObserver not working properly
July 3, 2013 at 10:10 pm
#1017609
phunkytube
Participant
Hi Halle, thanks for the swift reply! My code is the following (with names replaced for simplicity):
// OpenEarsWrapper.h
#import <Foundation/Foundation.h>
#import <OpenEars/OpenEarsEventsObserver.h>
@interface OpenEarsWrapper : NSObject <OpenEarsEventsObserverDelegate>
- (id)initAndStartListeningWithWordsArray:(NSArray *)_words filename:(NSString *)_filename;
@end
// OpenEarsWrapper.m
#import "OpenEarsWrapper.h"
#import <OpenEars/LanguageModelGenerator.h>
#import <OpenEars/PocketsphinxController.h>
#import <OpenEars/OpenEarsLogging.h>
@interface OpenEarsWrapper ()
@property (nonatomic, strong) OpenEarsEventsObserver *openEarsEventsObserver;
@property (nonatomic, strong) NSString *languageModelPath;
@property (nonatomic, strong) NSString *dictionaryPath;
@property (nonatomic, strong) PocketsphinxController *pocketSphinxController; // out of curiosity why is the 's' in "sphinx" lowercase???
@end
@implementation OpenEarsWrapper
@synthesize openEarsEventsObserver;
@synthesize languageModelPath, dictionaryPath;
@synthesize pocketSphinxController;
- (id)initAndStartListeningWithWordsArray:(NSArray *)_words filename:(NSString *)_filename {
self = [super init];
if (self) {
//[OpenEarsLogging startOpenEarsLogging];
openEarsEventsObserver = [[OpenEarsEventsObserver alloc] init];
[openEarsEventsObserver setDelegate:self];
LanguageModelGenerator *languageModelGenerator = [[LanguageModelGenerator alloc] init];
NSError *error = [languageModelGenerator generateLanguageModelFromArray:_words withFilesNamed:_filename];
NSDictionary *languageGeneratorResults = nil;
if ([error code] == noErr) {
languageGeneratorResults = [error userInfo];
languageModelPath = [languageGeneratorResults objectForKey:kLanguageModelPathKey];
dictionaryPath = [languageGeneratorResults objectForKey:kDictionaryPathKey];
} else {
NSLog(@"Error: %@", [error localizedDescription]);
return self;
}
pocketSphinxController = [[PocketsphinxController alloc] init];
[pocketSphinxController startListeningWithLanguageModelAtPath:languageModelPath dictionaryAtPath:dictionaryPath languageModelIsJSGF:NO];
}
return self;
}
- (void)pocketsphinxDidReceiveHypothesis:(NSString *)hypothesis recognitionScore:(NSString *)recognitionScore utteranceID:(NSString *)utteranceID {
NSLog(@"why doesn't this fire!!!!");
}
@end