- This topic has 7 replies, 2 voices, and was last updated 8 years, 7 months ago by Halle Winkler.
-
AuthorPosts
-
August 11, 2014 at 3:03 pm #1022168ThatGuyParticipant
Hello World,
My application has multiple view controllers which all have[self.pocketsphinxController startListeningWithLanguageModelAtPath:lmPath dictionaryAtPath:dicPath acousticModelAtPath:[AcousticModel pathToModel:@"AcousticModelEnglish"] languageModelIsJSGF:NO];
in the viewDidLoad method and[self.pocketsphinxController stopListening];
when dismissing the view controller with a button. However, when I enter one view controller, exit, and then go to another view controller it displays the same statements over and over again in the NSLog depending on how many view controllers I have visited. My app works perfectly fine, but I would like to get this fixed.NSLog (without the date and time, or my personal stuff):
acousticModelPath is Pocketsphinx calibration has started. Pocketsphinx calibration is complete. Pocketsphinx is now listening. Pocketsphinx has stopped listening. acousticModelPath is Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx is now listening. Pocketsphinx is now listening. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. acousticModelPath is Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx is now listening. Pocketsphinx is now listening. Pocketsphinx is now listening. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. acousticModelPath is Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. acousticModelPath is Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration has started. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx calibration is complete. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening. Pocketsphinx has stopped listening.
etc…
So I don’t know what the problem is and was wondering if you guys could help?
August 11, 2014 at 3:21 pm #1022169Halle WinklerPolitepixHello,
You either have many PocketsphinxControllers in your app (you can only have one) or you have one PocketsphinxController but many instantiated OpenEarsEventsObserver delegates. Either of these will probably be due to your view controllers having an issue that prevents ARC from releasing them.
August 11, 2014 at 3:42 pm #1022170ThatGuyParticipantSo are you saying that I should only declare
PocketSphinxController *pocketsphinxController
in only one header file and reference it from different view controllers? I have[self.openEarsEventsObserver setDelegate:self];
in the viewDidLoad methods of all of the view controllers and this as well- (OpenEarsEventsObserver *)openEarsEventsObserver { if (openEarsEventsObserver == nil) { openEarsEventsObserver = [[OpenEarsEventsObserver alloc] init]; } return openEarsEventsObserver; }
regarding the openEarsEventsObserver.
August 11, 2014 at 3:50 pm #1022171Halle WinklerPolitepixSo are you saying that I should only declare PocketSphinxController *pocketsphinxController in only one header file and reference it from different view controllers?
This isn’t quite how object declaration and definitions work in Objective-C. From the docs:
Warning
There can only be one PocketsphinxController instance in your app.That means a single declaration and definition, and a single instance of that declaration/definition. It’s fine (and intended) to have lots of OpenEarsEventsObserver instances, but if you have lots of them instantiated at once you’ll need to do some logical control in order to prevent them all from sending callbacks simultaneously if that isn’t the result you want.
August 11, 2014 at 5:55 pm #1022172ThatGuyParticipantOk, so I just put NSLog
(@"%@", self.pocketsphinxController);
in the viewDidLoad methods and they showed different instances<PocketsphinxController: 0x987f590>
and<PocketsphinxController: 0x98a3ab0>
. So how does one make them the same instance.August 11, 2014 at 6:31 pm #1022173Halle WinklerPolitepixSorry, it isn’t possible to help out with learning Objective-C here – I can only give support for OpenEars questions.
This is a good book for getting started learning Objective-C and Cocoa Touch for iOS development: http://www.bignerdranch.com/we-write/ios-programming.html
This is an good free course if classes are more your thing: https://itunes.apple.com/us/course/developing-ios-7-apps-for/id733644550
August 11, 2014 at 7:13 pm #1022174ThatGuyParticipantHey, it was just a problem with ARC I believe, I just put
self.openEarsEventsObserver = nil;
when exiting the view controller. Thanks for your assistance Halle.August 11, 2014 at 7:18 pm #1022175Halle WinklerPolitepixOK, nice troubleshooting.
-
AuthorPosts
- You must be logged in to reply to this topic.