Reply To: Recognize short Command in nonEnglish

Home Forums OpenEars Recognize short Command in nonEnglish Reply To: Recognize short Command in nonEnglish

#1032317
iKK
Participant

Sure:

func startListening()
{
if OEPocketsphinxController.sharedInstance().isListening {
stopListening()
}

var acousticModelName = “AcousticModelGerman”
var fileName = “GermanModel”

OEPocketsphinxController.sharedInstance().vadThreshold = 3.6;

var error: Error?

error = lmGenerator.generateGrammar(from: [OneOfTheseWillBeSaidOnce : words], withFilesNamed: fileName, forAcousticModelAtPath: OEAcousticModel.path(toModel: acousticModelName))

var lmPath = “”
var dictPath = “”

if(error == nil) {

lmPath = lmGenerator.pathToSuccessfullyGeneratedLanguageModel(withRequestedName: fileName)
dictPath = lmGenerator.pathToSuccessfullyGeneratedDictionary(withRequestedName: fileName)
lmPath = lmGenerator.pathToSuccessfullyGeneratedGrammar(withRequestedName: fileName)

} else {
print(“Error: \(error!.localizedDescription)”)
}

try? OEPocketsphinxController.sharedInstance().setActive(true)
OEPocketsphinxController.sharedInstance().startListeningWithLanguageModel(atPath: lmPath, dictionaryAtPath: dictPath, acousticModelAtPath: OEAcousticModel.path(toModel: acousticModelName), languageModelIsJSGF: true)
}