programatically start and stop openEars/RapidEars swift

Home Forums OpenEars plugins programatically start and stop openEars/RapidEars swift

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

  • Author
    Posts
  • #1032592
    Saatyagi
    Participant

    Hi,
    I want to programatically start and stop openEars.
    I’ve written following code:-

    
    func stopOpenEars() {
            do {
                try OEPocketsphinxController.sharedInstance().setActive(false) // Setting the shared OEPocketsphinxController active is necessary before any of its properties are accessed.
            } catch {
                print("Error: it wasn't possible to set the shared instance to active: \"\(error)\"")
            }
            OEPocketsphinxController.sharedInstance()?.stopListening()
        }
    

    but above doesn’t perform.

    can you help me with that?

    #1032593
    Halle Winkler
    Politepix

    Hi Saatyagi,

    I wouldn’t set the instance false first or call stop on an optional instance that has been set false. There are a couple of examples of working stopListening() calls in the Swift sample app that is part of the OpenEarsDistribution directory in the file ViewController.swift that can help with this, as well as other complexities you may be seeing such as avoiding calling stop on an already-stopped instance.

    #1032594
    Saatyagi
    Participant
    func stopOpenEars() {
            OEPocketsphinxController.sharedInstance()?.stopListening()
        }
    

    I’ve tried above as well but it always starts again.

    #1032595
    Saatyagi
    Participant

    It worked. Thanks you.
    Can you point me to the tutorial where you’ve shown how to change dictionary on the fly ?
    for eg on landing page I’ve different dictionary and after navigation I need other one. how can I achieve that ?

    #1032596
    Halle Winkler
    Politepix

    You’re welcome! Switching dictionaries is also in the sample app, so I recommend opening it up and checking out its code.

    #1032597
    Saatyagi
    Participant

    Change from one language model to another. This lets you change which words you are listening for depending on the context in your app. If you have already started the recognition loop and you want to switch to a different language model, you can use this and the model will be changed at the earliest opportunity. Will not have any effect unless recognition is already in progress. It isn’t possible to change acoustic models in the middle of an already-started listening loop, just language model and dictionary.
    Swift 3: changeLanguageModel(toFile: String!, withDictionary: String!)

    This is what I got from Documentation. but I don’t see where to change set of words array in that.

    #1032598
    Halle Winkler
    Politepix

    Hi,

    There is a sample app written in Swift which shows a working example of this and many other operations. It is in OpenEarsDistribution/OpenEarsSampleAppSwift/OpenEarsSampleAppSwift.xcodeproj

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