Last active
October 25, 2016 14:35
-
-
Save a1len1234/b962972d64904d2217bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController, OEEventsObserverDelegate { | |
var openEarsEventsObserver = OEEventsObserver() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
openEarsEventsObserver.delegate = self | |
var lmGenerator = OELanguageModelGenerator() | |
var words = ["OPEN EARS", "HELLO REDDIT", "DOES THIS WORK"] | |
var name = "languageModelFiles" | |
var err: NSError? = lmGenerator.generateLanguageModelFromArray(words, withFilesNamed: name, forAcousticModelAtPath: OEAcousticModel.pathToModel("AcousticModelEnglish")) | |
var lmPath: String? | |
var dicPath: String? | |
if err == nil { | |
lmPath = lmGenerator.pathToSuccessfullyGeneratedLanguageModelWithRequestedName(name) | |
dicPath = lmGenerator.pathToSuccessfullyGeneratedDictionaryWithRequestedName(name) | |
} else { | |
println("Error: \(err!)") | |
} | |
OEPocketsphinxController.sharedInstance().setActive(true, error: nil) | |
OEPocketsphinxController.sharedInstance().startListeningWithLanguageModelAtPath(lmPath, dictionaryAtPath: dicPath, acousticModelAtPath: OEAcousticModel.pathToModel("AcousticModelEnglish"), languageModelIsJSGF: false) | |
} | |
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("Pocketsphinx is now listening.") | |
} | |
func pocketsphinxDidDetectSpeech() { | |
println("Pocketsphinx has detected speech.") | |
} | |
func pocketsphinxDidDetectFinishedSpeech() { | |
println("Pocketsphinx has detected a period of silence, concluding an utterance.") | |
} | |
func pocketsphinxDidStopListening() { | |
println("Pocketsphinx has stopped listening.") | |
} | |
func pocketsphinxDidSuspendRecognition() { | |
println("Pocketsphinx has suspended recognition.") | |
} | |
func pocketsphinxDidResumeRecognition() { | |
println("Pocketsphinx has resumed recognition.") | |
} | |
func pocketsphinxDidChangeLanguageModelToFile(newLanguageModelPathAsString: String!, andDictionary newDictionaryPathAsString: String!) { | |
println("Pocketsphinx is now using the following language model: \(newLanguageModelPathAsString) and the following dictionary: \(newDictionaryPathAsString)") | |
} | |
func pocketSphinxContinuousSetupDidFailWithReason(reasonForFailure: String!) { | |
println("Listening setup wasn't successful and returned the failure reason: \(reasonForFailure)") | |
} | |
func pocketSphinxContinuousTeardownDidFailWithReason(reasonForFailure: String!) { | |
println("Listening teardown wasn't successful and returned the failure reason: \(reasonForFailure)") | |
} | |
func testRecognitionCompleted() { | |
println("A test file that was submitted for recognition is now complete.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment