- This topic has 15 replies, 3 voices, and was last updated 10 years, 2 months ago by Halle Winkler.
-
AuthorPosts
-
July 3, 2013 at 9:45 pm #1017607phunkytubeParticipant
Are there any known issues (read: any past issues) with the OpenEarsEventsObserverDelegate protocol? When I send startOpenEarsLogging to the OpenEarsLogging class, it indicates that my implementation of PocketsphinxController’s speech recognition is working and that the system recognizes my speech correctly. But none of the delegate methods are being fired, and I know I’ve hooked everything up correctly. Thanks!
July 3, 2013 at 9:49 pm #1017608Halle WinklerPolitepixWelcome,
Nope, no reported issues with this in 3 years. Even though you’ve checked it out, it’s possible that there is something minor that isn’t quite right — would you like to show your code so I can check?
July 3, 2013 at 10:10 pm #1017609phunkytubeParticipantHi 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
July 3, 2013 at 10:28 pm #1017612Halle WinklerPolitepixDoes it work if you use the lazy allocation style shown in the tutorial and sample app?
July 3, 2013 at 10:31 pm #1017613phunkytubeParticipantUnfortunately not. It’s not an issue with my device, either, since the sample app runs correctly. And the ‘private’ instance variables (instead of, say, in the public header interface declaration) aren’t the problem either :(
July 4, 2013 at 7:37 am #1017617Halle WinklerPolitepixDoes the sample app work for you? Do any of the delegate methods used in the sample app work in your app?
July 4, 2013 at 8:49 am #1017619phunkytubeParticipantPerfectly.
No, the delegate methods used in the sample app don’t work correctly in my app – none of the delegate methods are called. I can’t imagine what is wrong with my setup… Do you have any other ideas of where to look?
July 4, 2013 at 9:29 am #1017620Halle WinklerPolitepixVery interesting. Do you want to send it over, or send over a reduced version if you have some IP in there that you don’t want to email? If so you can drop me a note via the contact form at https://www.politepix.com/contact and I’ll get back to you with an email address.
// out of curiosity why is the ‘s’ in “sphinx” lowercase???
Pocketsphinx isn’t camel-cased: https://cmusphinx.sourceforge.net
Just respecting their orthography.July 4, 2013 at 9:30 am #1017621phunkytubeParticipantWill do, thanks!
It seems inconsistent on their website. Although the second most recent blog post has “Pocketsphinx” in the title, it also has “PocketSphinx” in the body. The API docs also have “PocketSphinx” (http://cmusphinx.sourceforge.net/api/pocketsphinx/). :)
July 4, 2013 at 9:41 am #1017623Halle WinklerPolitepixYep, you can also find incidences of it all-lowercase. Well, CMU is a research institution so they probably don’t worry much about their brand ID :) .
July 8, 2013 at 7:00 pm #1017632Halle WinklerPolitepixHi,
Thanks for waiting. The minor issue in the test app is that it has a slightly idiosyncratic accessor style by providing itself to the hosting class as a non-singleton class method that initializes other multithreaded or thread-conscious and persistence-needing objects inside of that class method by invoking their inits inside the class init method, and then returns.
This started working for me when I made it a little more boring by removing the class method, made the wrapper class a property of the hosting class, instantiated it with the standard init in that class, and then did all of the setup in a separate method on the already-instantiated object.
So I ultimately had no “+” method, used the default init, and had a method where I put all the setup that used to be in the class method, called:
– (void) setupWithWordsArray:(NSArray *)_words filename:(NSString *)_filename;That got called by the wrapper object (as a class property of the hosting class) once it was instantiated.
Without more time to look into it, I don’t know if the fundamental issue is multithreading related, something with ARC optimization, or just that the observer delegate needs the observing object to have returned from its initialization. I did not continue to troubleshoot how the delegate of the wrapper functioned since I had to stop after the OpenEarsEventsObserver started working, so I don’t know if those are working or not. Let me know if this helps or if you need more details. It’s also a good idea to put all the OpenEars code into your root view controller rather than the app delegate since it is business code. You can still instantiate OpenEarsEventsObservers wherever you need them, so this won’t pin you down to a single view controller.
-Halle
February 19, 2014 at 2:50 pm #1020216nbhagatParticipantI am also facing similar issue like phunkytube mentioned. OpenEarsLogging shows perfect logs of “listening”, “Speech detected…” when I perform actions, but none of the delegate methods are called. I am converting the whole ViewController’s functionality to a class super-classed by NSObject.
February 19, 2014 at 2:59 pm #1020217Halle WinklerPolitepixWelcome,
Just take a look at the sample app or tutorial which have different known-to-work examples and compare either or both with your implementation – it will come down to memory management or similar.
February 19, 2014 at 2:59 pm #1020218Halle WinklerPolitepixAlso, be sure to compare both the header and implementations, since setting up delegates has to start with importing their protocols in the header.
February 19, 2014 at 3:17 pm #1020220nbhagatParticipantThanks a lot. I just figured out to make it working. I created property for my class and then initialised the class using that property. It works as expected now. :)
February 19, 2014 at 3:23 pm #1020221Halle WinklerPolitepixExcellent, glad to hear it.
-
AuthorPosts
- You must be logged in to reply to this topic.