[Resolved] sharedInstance SetActive: usage question

Home Forums OpenEars [Resolved] sharedInstance SetActive: usage question

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

  • Author
    Posts
  • #1023565
    tbreslow
    Participant

    Another API change is that before you start setting properties of OEPocketsphinxController for the first time, it is necessary to call its setActive method

    Forgive me if this is an ignorant question, but does this mean I have to keep track of whether it is the first time I am setting properties so that I can know if I need to call this?

    I have upgraded to 2.0 per the guide and it is fantastic, but I am not setting this to true and therefore did not expect it to start recognition. This call is for setting properties only, not for starting recognition?

    Many Thanks!

    #1023566
    Halle Winkler
    Politepix

    Hi,

    It isn’t harmful to call it more than once.

    #1023793
    Halle Winkler
    Politepix

    To clarify a bit now that I’ve seen some code which does this, I think the question is probably usually being asked in order to put the setActive: code into a lazy accessor to avoid getting rid of the OEPocketsphinxController lazy accessor pattern from 1.x.

    I would recommend both against having a lazy accessor and from putting setActive: into it, since I’m not offering an API contract that I will never put anything in setActive: that would be preferable to do fewer times, although currently I don’t see a potential issue from calling setActive: multiple times.

    Therefore, the best way to go would be to get rid of the lazy accessor, now or soonish, and then you will have less and simpler code, and you will also know pretty well where your first invocation of OEPocketsphinxController is so you can call setActive: one time, before it. Hope this is helpful.

    #1024022
    tbreslow
    Participant

    Many thanks!

    (I removed the lazy accessors during my switch to 2.0.)

    There are two different parts of my application where it is possible to use voice recognition and the sharedInstance. Right now I am checking isListening to determine whether I need to setActive:YES and call startListeningWithLanguageModelAtPath.

    Is this a valid approach?

    #1024023
    Halle Winkler
    Politepix

    That sounds reasonable!

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