Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragging Project Into Xcode #45

Open
sdliv opened this issue May 17, 2018 · 25 comments
Open

Dragging Project Into Xcode #45

sdliv opened this issue May 17, 2018 · 25 comments

Comments

@sdliv
Copy link

sdliv commented May 17, 2018

Hello,

I'm trying to make use of your project. I dragged it into Xcode, but I am not able to make use of the framework. "#import TLSphinx" also throws an error, stating that there is no such module. I'm trying to install this manually, not using Carthage or Cocoapods.

Any help would be appreciated. I've been trying to make use of pocketsphinx for nearly two weeks now; I'm trying to avoid OpenEars at all cost because it doesn't allow for some of the use cases I need.

Thanks.

@BrunoBerisso
Copy link
Contributor

BrunoBerisso commented May 17, 2018 via email

@sdliv
Copy link
Author

sdliv commented May 17, 2018 via email

@sdliv
Copy link
Author

sdliv commented May 18, 2018

Hi Bruno,

Here is a screenshot of my directory structure.
screen shot 2018-05-18 at 1 38 59 am

@BrunoBerisso
Copy link
Contributor

Hey,

I just try the integration by dragging the project and you need to do one more thing. Select your project and under the General settings go to Linked Frameworks and Libraries, click the + icon and select TLSphinx from the top of the list.

You should end with something like this:
image

Once you have that set, there are going to be many compilation errors because this codebase is highly outdated :( Sorry about that.

Let me know if I can help you further. I'm going to work on bring some order to the project as soon as I can.

@sdliv
Copy link
Author

sdliv commented May 18, 2018 via email

@sdliv
Copy link
Author

sdliv commented May 18, 2018 via email

@BrunoBerisso
Copy link
Contributor

Yes, I think that's expected because you need to update some search paths for Sphinx core engine. Also, try to pull the latest changes from master because I just push some quick fixes.

Are you running this on the simulator or on a real device?

@sdliv
Copy link
Author

sdliv commented May 31, 2018 via email

@sdliv
Copy link
Author

sdliv commented May 31, 2018 via email

@sdliv
Copy link
Author

sdliv commented May 31, 2018 via email

@BrunoBerisso
Copy link
Contributor

Those are the models used by the Sphinx engine. You could use the ones shipped with TLSphinx or build your own using the standard Sphinx tools..

For an example of how to load this check the basic test.. Keep in mind that the models shipped here has all the words in the dictionary and will have bad performance.

@sdliv
Copy link
Author

sdliv commented May 31, 2018 via email

@BhavinGupta
Copy link

How to use the shipped with TLSphinx model with my current project as i am not able to get the model from the path specified in it.

please help me on this as i am very nearest to use this wrapper with proper implementation.

@BrunoBerisso
Copy link
Contributor

Hi @BhavinGupta ,

Could you please open another issue so we can help you? Please add as much info as you can like screenshots or any error message.

Thanks!

@BhavinGupta
Copy link

See this i am getting these errors when search path and header paths are updated can you explain me again how to go with the TLSphinx integration once again after importing the TLSphinx i ma getting 10 errors i have followed your steps still the same see the screenshot below
screen shot 2018-06-11 at 5 33 34 pm

@BhavinGupta
Copy link

See this screenshot as below
screen shot 2018-06-11 at 5 36 39 pm

@BrunoBerisso
Copy link
Contributor

@BhavinGupta did you saw the settings here? If that didn't work, try switching the target to TLSphinx, build that one, switch back to your project and build it again.

Also, If you still have errors after that try copy those and paste it here.

@BhavinGupta
Copy link

k now i have resolved with all the errors @BrunoBerisso
now i want to get this code below to give me proper path
func getModelPath() -> NSString? {
return Bundle(for: ViewController.self).path(forResource: "en-us", ofType: nil) as NSString?
}
which i am always getting nil path what to do

@BhavinGupta
Copy link

This is the code i am running below:-

import UIKit
import TLSphinx

class ViewController: UIViewController {

//MARK:- View life Cycle
override func viewDidLoad() {
    super.viewDidLoad()
    self.testSpeechRecognition()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

//MARK:- Get Model Path Method
func getModelPath() -> NSString? {
    return Bundle(for: ViewController.self).path(forResource: "en-us", ofType: nil) as NSString?
}

//MARK:- Test Speech Recognition Method
func testSpeechRecognition() {
    guard let modelPath = getModelPath() else {
        print("Can't access pocketsphinx model. Bundle root: \(Bundle.main)")
        return
    }
    
    let hmm = modelPath.appendingPathComponent("en-us")
    let lm = modelPath.appendingPathComponent("en-us.lm.dmp")
    let dict = modelPath.appendingPathComponent("cmudict-en-us.dict")
    
    if let config = Config(args: ("-hmm", hmm), ("-lm", lm), ("-dict", dict)) {
        if let decoder = Decoder(config:config) {
            try! decoder.startDecodingSpeech {
                if let hyp: Hypothesis = $0 {
                    print(hyp)
                } else {
                    // Can't decode any speech because an error
                }
            }
        } else {
            // Handle Decoder() fail
        }
    } else {
        // Handle Config() fail
    }
    
    //At some point in the future stop listen to the mic
    //decoder.stopDecodingSpeech()
}

}

@BrunoBerisso
Copy link
Contributor

Some things to check:

  • is the folder copied to the app bundle?
  • is the folder appearing in Xcode like a group (yellow) or a folder (blue)?

@BhavinGupta
Copy link

When i am adding the sphinx folder which consist of share>phoneix>model> then i am getting lex error telling me that you have same file in the project so how to add the en-us file

@BhavinGupta
Copy link

k i have also get the path from the model by adding it properly in the bundle as per your instruction
now the issue is how to get the spoken word in this below code @BrunoBerisso
try! decoder.startDecodingSpeech {
if let hyp: Hypothesis = $0 {
print(hyp)
} else {
// Can't decode any speech because an error
}
}
which i have called in viewDidLoad()

please guide me @BrunoBerisso

@BhavinGupta
Copy link

I tried this code but its not working please provide me the proper solution for decoding the code after trying this code below

guard let modelPath = getModelPath() else {
print("Can't access pocketsphinx model. Bundle root: (Bundle.main)")
return
}

    let hmm = modelPath.appendingPathComponent("en-us")
    let lm = modelPath.appendingPathComponent("en-us.lm.dmp")
    let dict = modelPath.appendingPathComponent("cmudict-en-us.dict")
    
    guard let config = Config(args: ("-hmm", hmm), ("-lm", lm), ("-dict", dict)) else {
        print("Can't run test without a valid config")
        return
    }
    
    config.showDebugInfo = false
    
    guard let decoder = Decoder(config:config) else {
        print("Can't run test without a decoder")
        return
    }
    
    try! decoder.startDecodingSpeech {
        print("Utterance: \(String(describing: $0))")
    }
    decoder.stopDecodingSpeech()

I am not getting the uttering string @BrunoBerisso

@BhavinGupta
Copy link

what happened you didnt reply to my above code in the comment how to proceed @BrunoBerisso ?
how to get the utterance in startDecodingSpeech method once it is initalized from viewDidLoad().

Please let me know soon as i want to integrate this in my live project @BrunoBerisso

@sdliv
Copy link
Author

sdliv commented Jun 13, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants