OpenEars语音识别将其他单词检测为正确的单词

时间:2017-06-01 07:31:21

标签: ios swift speech-recognition pocketsphinx openears

我在我的应用程序中使用OpenEars框架来检测语音识别。 这个想法是听几个单词,然后根据已经说过的单词执行一些操作。好吧,识别工作和单词被检测到,但问题是用词" SNAPPIE"我有一些问题 - 其他的话听起来并没有被认可为#34; SNAPPIE",有时即使我咳嗽。这是我用来设置监听器的一段代码:

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
  }

它可能是一个问题,因为" SNAPPIE"实际上并不是一个有效的"字?

1 个答案:

答案 0 :(得分:0)

您可以使用任何在线随机字生成器工具创建一个随机的单词列表,然后将您想要识别的特定关键字附加到词汇表中。这将改善您对特定关键字的识别。您仍然需要将假设文本与关键字列表进行比较,但解决方案在大多数情况下都足够好。