简体   繁体   中英

OpenEars speech recognition detecting other words as correct ones

I am using OpenEars framework in my app to detect speech recognition. The idea is to listen for few words and then execute some actions depending on the word that has been said. Well, recognition works and words are detected, but the problem is that with word "SNAPPIE" I am having some issues - other words that don't sound like it also get recognized as "SNAPPIE", sometimes even if I cough. Here is a piece of code I am using to set up listener:

private func setupOpenEars() {

    _openEarsEventsObserver = OEEventsObserver()
    _openEarsEventsObserver.delegate = self

    OEPocketsphinxController.sharedInstance().disablePreferredBufferSize = true

    do {
      try OEPocketsphinxController.sharedInstance().setActive(true)
    } catch let error {
      print("There was an error setting Pocketsphinx as active: \(error.localizedDescription)")
    }

    let grammarDictionary = ["ThisCanBeSaidOnce": [ "SNAPPIE", "TAKE SNAPSHOT" ]]
    let languageModelGenerator = OELanguageModelGenerator()
    let fileName = "FirstOpenEarsDynamicLanguageModel"
    let error = languageModelGenerator.generateGrammar(from: grammarDictionary, withFilesNamed: fileName, forAcousticModelAtPath: OEAcousticModel.path(toModel: "AcousticModelEnglish"))

    if let languageError = error {
      print("Dynamic language generator reported error: \(languageError.localizedDescription)")
    } else {
      _pathToGeneratedLanguageModel = languageModelGenerator.pathToSuccessfullyGeneratedLanguageModel(withRequestedName: fileName)
      _pathToGeneratedDictionary = languageModelGenerator.pathToSuccessfullyGeneratedDictionary(withRequestedName: fileName)
    }

    _correctPathToMyLanguageModelFile = "\(NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.cachesDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)[0])/\(fileName).gram"
    OEPocketsphinxController.sharedInstance().vadThreshold = 3.5
  }

Is it possible that it could be a problem because "SNAPPIE" actually isn't a "valid" word?

You can create a random list of words using any online random word generator tool and then append your specific keywords that you want to recognise to the vocabulary. This will improve the recognition of your specific keyword. You will still have to compare the hypothesis text against your list of keywords though but the solution is good enough most of the times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM