IOS Open Ears无法启动

时间:2012-09-18 07:14:11

标签: ios openears

我正在尝试为我的应用程序创建简单的帮助程序类,它将加载打开的默认设置。问题是一切似乎都很正常但是当我创建新的帮助程序对象并运行方法startListening时它没有做任何事情。

我认为问题在于设置代理但我无法弄清楚

OpenEarsHelper.h

#import <Foundation/Foundation.h>
#import <OpenEars/PocketsphinxController.h>
#import <OpenEars/LanguageModelGenerator.h>
@interface OpenEarsHelper : NSObject<OpenEarsEventsObserverDelegate>{
    OpenEarsEventsObserver *openEarsEventsObserver;
    PocketsphinxController *pocketsphinxController;
}
@property (strong, nonatomic) OpenEarsEventsObserver *openEarsEventsObserver;
@property (strong, nonatomic) PocketsphinxController *pocketsphinxController;
-(void)prepare;
@end

OpenEarsHelper.m

#import "OpenEarsHelper.h"

@implementation OpenEarsHelper
@synthesize openEarsEventsObserver;

-(void)prepare{

    [self.openEarsEventsObserver setDelegate:self];//Problem should be here

    LanguageModelGenerator *lmGenerator = [[LanguageModelGenerator alloc] init];
    NSArray *words = [NSArray arrayWithObjects:@"WORD", @"STATEMENT", @"OTHER WORD", @"A PHRASE", nil];
    NSString *name = @"NameIWantForMyLanguageModelFiles";
    NSError *err = [lmGenerator generateLanguageModelFromArray:words withFilesNamed:name];


    NSDictionary *languageGeneratorResults = nil;
    NSString *lmPath = nil;
    NSString *dicPath = nil;
    languageGeneratorResults = [err userInfo];
    lmPath = [languageGeneratorResults objectForKey:@"LMPath"];
    dicPath = [languageGeneratorResults objectForKey:@"DictionaryPath"];
    [self.pocketsphinxController startListeningWithLanguageModelAtPath:lmPath dictionaryAtPath:dicPath languageModelIsJSGF:NO];
}

- (void) pocketsphinxDidReceiveHypothesis:(NSString *)hypothesis recognitionScore:(NSString *)recognitionScore utteranceID:(NSString *)utteranceID {
    NSLog(@"The received hypothesis is %@ with a score of %@ and an ID of %@", hypothesis, recognitionScore, utteranceID);
}

- (PocketsphinxController *)pocketsphinxController {
    if (pocketsphinxController == nil) {
        pocketsphinxController = [[PocketsphinxController alloc] init];
    }
    return pocketsphinxController;
}

- (OpenEarsEventsObserver *)openEarsEventsObserver {
    if (openEarsEventsObserver == nil) {
        openEarsEventsObserver = [[OpenEarsEventsObserver alloc] init];
        openEarsEventsObserver.delegate = self;
    }
    return openEarsEventsObserver;
}
@end

我在viewDidLoad方法中使用它,如

 OpenEarsHelper *helper=[[OpenEarsHelper alloc]init];
  [helper prepare];

0 个答案:

没有答案