Repeats in NSLog

Home Forums OpenEars Repeats in NSLog

Viewing 8 posts - 1 through 8 (of 8 total)

  • Author
    Posts
  • #1022168
    ThatGuy
    Participant

    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?

    #1022169
    Halle Winkler
    Politepix

    Hello,

    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.

    #1022170
    ThatGuy
    Participant

    So 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.

    #1022171
    Halle Winkler
    Politepix

    So 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.

    #1022172
    ThatGuy
    Participant

    Ok, 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.

    #1022173
    Halle Winkler
    Politepix

    Sorry, 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

    #1022174
    ThatGuy
    Participant

    Hey, 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.

    #1022175
    Halle Winkler
    Politepix

    OK, nice troubleshooting.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.