Guest User

sampleOpenEars

a guest
Jul 20th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 2.56 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController, OEEventsObserverDelegate {
  4.  
  5.     @IBOutlet weak var spokenWord: UILabel!
  6. //    @property (strong, nonatomic) OEEventsObserver *openEarsEventsObserver;
  7.     let openEarsEventsObserver: OEEventsObserver = OEEventsObserver()
  8.    
  9.    
  10.     override func viewDidLoad() {
  11.         super.viewDidLoad()
  12.         // Do any additional setup after loading the view, typically from a nib.
  13.         OELogging.startOpenEarsLogging()
  14.         OEPocketsphinxController.sharedInstance().verbosePocketSphinx = true
  15.         self.openEarsEventsObserver.delegate = self
  16.        
  17.         let documentsFolder = NSBundle.mainBundle().resourcePath!
  18.         let dictPath = documentsFolder.stringByAppendingPathComponent("arv.dic")
  19.         let jsgfPath = documentsFolder.stringByAppendingPathComponent("arv.jsgf")
  20.        
  21.         OEPocketsphinxController.sharedInstance().setActive(true, error: nil)
  22.         OEPocketsphinxController.sharedInstance().startListeningWithLanguageModelAtPath(jsgfPath, dictionaryAtPath: dictPath, acousticModelAtPath: "AcousticModelArabic", languageModelIsJSGF: true)
  23.        
  24.        
  25.     }
  26.  
  27.     override func didReceiveMemoryWarning() {
  28.         super.didReceiveMemoryWarning()
  29.         // Dispose of any resources that can be recreated.
  30.     }
  31.    
  32.     func pocketsphinxDidReceiveHypothesis(hypothesis: String!, recognitionScore: String!, utteranceID: String!) {
  33.         println("The received hypothesis is \(hypothesis) with a score of \(recognitionScore) and an ID of \(utteranceID)")
  34.     }
  35.    
  36.     func pocketsphinxDidStartListening() {
  37.         println(__FUNCTION__)
  38.     }
  39.    
  40.     func pocketsphinxDidDetectSpeech() {
  41.         println(__FUNCTION__)
  42.     }
  43.    
  44.     func pocketsphinxDidDetectFinishedSpeech() {
  45.         println(__FUNCTION__)
  46.     }
  47.    
  48.     func pocketsphinxDidStopListening() {
  49.         println(__FUNCTION__)
  50.     }
  51.    
  52.     func pocketsphinxDidSuspendRecognition() {
  53.         println(__FUNCTION__)
  54.     }
  55.    
  56.     func pocketsphinxDidResumeRecognition() {
  57.         println(__FUNCTION__)
  58.     }
  59.    
  60.     func pocketsphinxDidChangeLanguageModelToFile(newLanguageModelPathAsString: String!, andDictionary newDictionaryPathAsString: String!) {
  61.         println(__FUNCTION__)
  62.     }
  63.    
  64.     func pocketSphinxContinuousSetupDidFailWithReason(reasonForFailure: String!) {
  65.         println("\(__FUNCTION__): \(reasonForFailure)")
  66.     }
  67.    
  68.     func pocketSphinxContinuousTeardownDidFailWithReason(reasonForFailure: String!) {
  69.         println("\(__FUNCTION__): \(reasonForFailure)")
  70.     }
  71.  
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment