Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class ViewController: UIViewController, OEEventsObserverDelegate {
- @IBOutlet weak var spokenWord: UILabel!
- // @property (strong, nonatomic) OEEventsObserver *openEarsEventsObserver;
- let openEarsEventsObserver: OEEventsObserver = OEEventsObserver()
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view, typically from a nib.
- OELogging.startOpenEarsLogging()
- OEPocketsphinxController.sharedInstance().verbosePocketSphinx = true
- self.openEarsEventsObserver.delegate = self
- let documentsFolder = NSBundle.mainBundle().resourcePath!
- let dictPath = documentsFolder.stringByAppendingPathComponent("arv.dic")
- let jsgfPath = documentsFolder.stringByAppendingPathComponent("arv.jsgf")
- OEPocketsphinxController.sharedInstance().setActive(true, error: nil)
- OEPocketsphinxController.sharedInstance().startListeningWithLanguageModelAtPath(jsgfPath, dictionaryAtPath: dictPath, acousticModelAtPath: "AcousticModelArabic", languageModelIsJSGF: true)
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- func pocketsphinxDidReceiveHypothesis(hypothesis: String!, recognitionScore: String!, utteranceID: String!) {
- println("The received hypothesis is \(hypothesis) with a score of \(recognitionScore) and an ID of \(utteranceID)")
- }
- func pocketsphinxDidStartListening() {
- println(__FUNCTION__)
- }
- func pocketsphinxDidDetectSpeech() {
- println(__FUNCTION__)
- }
- func pocketsphinxDidDetectFinishedSpeech() {
- println(__FUNCTION__)
- }
- func pocketsphinxDidStopListening() {
- println(__FUNCTION__)
- }
- func pocketsphinxDidSuspendRecognition() {
- println(__FUNCTION__)
- }
- func pocketsphinxDidResumeRecognition() {
- println(__FUNCTION__)
- }
- func pocketsphinxDidChangeLanguageModelToFile(newLanguageModelPathAsString: String!, andDictionary newDictionaryPathAsString: String!) {
- println(__FUNCTION__)
- }
- func pocketSphinxContinuousSetupDidFailWithReason(reasonForFailure: String!) {
- println("\(__FUNCTION__): \(reasonForFailure)")
- }
- func pocketSphinxContinuousTeardownDidFailWithReason(reasonForFailure: String!) {
- println("\(__FUNCTION__): \(reasonForFailure)")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment