我正在尝试将 OpenEars 包含在我正在制作的 theos 项目中,这是针对越狱 iDevices 的调整,因为我的调整需要语音识别。我可以通过将 OpenEars 框架与我的私有框架放在同一个文件夹中来链接它,我目前正在尝试让教程代码正常工作。这是我当前的代码:
#import <OpenEars/LanguageModelGenerator.h>
#import <OpenEars/PocketsphinxController.h>
#import <OpenEars/AcousticModel.h>
%hook SBLockScreenView
-(void)setCustomSlideToUnlockText:(id)arg1 {
LanguageModelGenerator *lmGenerator = [[LanguageModelGenerator alloc] init];
NSArray *words = [NSArray arrayWithObjects:@"WORD", @"STATEMENT", @"OTHER WORD", @"A PHRASE", nil];
NSString *name = @"NameIWantForMyLanguageModelFiles";
NSError *err = [lmGenerator generateLanguageModelFromArray:words withFilesNamed:name forAcousticModelAtPath:[AcousticModel pathToModel:@"AcousticModelEnglish"]];
//NSError* err = [lmGenerator generateLanguageModelFromArray:words withFilesNamed:name forAcousticModelAtPath:imagePath];
//NSError* err = [[NSError alloc] init];
NSDictionary *languageGeneratorResults = nil;
NSString *lmPath = nil;
NSString *dicPath = nil;
if([err code] == noErr) {
languageGeneratorResults = [err userInfo];
lmPath = [languageGeneratorResults objectForKey:@"LMPath"];
dicPath = [languageGeneratorResults objectForKey:@"DictionaryPath"];
}
else {
NSLog(@"Error: %@",[err localizedDescription]);
}
%orig;
}
%end
这编译得很好,但是当它运行时,我收到这些错误消息并且我的设备崩溃:“在尝试引用预期位于路径(null)的请求的声学模型包时,没有找到包。这意味着当监听循环开始时,由于缺少所需的资源,它将崩溃。找到声学模型包的问题可能是因为包的名称没有以它可以使用的方式提供给此方法;例如,如果您正在尝试要使用英语声学模型并且您已将该捆绑包添加到您的应用程序项目中,您可以通过传递[AcousticModel pathToAcousticModel:@"AcousticModelEnglish"]
(或[AcousticModel pathToAcousticModel:@"AcousticModelSpanish"]
对于西班牙语包),不要在末尾附加“.bundle”,并确保包名的拼写与实际包名中的拼写完全一致(可以在此发行版的文件夹“Framework”中看到包。
如果这不能解决问题,很可能是由于声学模型包没有成功导入到您的应用项目及其 mainBundle 的根级别。这通常是因为声学模型包在最初应该被拖入“框架”文件夹时从未被拖入您的应用程序项目,或者因为它被拖入但没有使用设置“为任何添加的文件夹创建组”在 Xcode 的“添加文件”对话框中,无意中选择了“为任何添加的文件夹创建文件夹引用”选项。要解决此问题,只需从您的应用程序中删除声学模型包或“框架”文件夹,然后使用正确的“为任何添加的文件夹创建组”设置将其再次添加到您的应用程序项目中
我还在我的系统日志中收到这些消息:
May 27 00:54:49 Phillips-iPhone SpringBoard[17785] <Warning>: acousticModelPath is (null)
May 27 00:54:49 Phillips-iPhone SpringBoard[17785] <Warning>: Error: the default phonetic dictionary (null)/LanguageModelGeneratorLookupList.text can't be found in the app bundle but the app is attempting to access it, most likely there will be a crash now.
May 27 00:54:49 Phillips-iPhone SpringBoard[17785] <Warning>: Error while trying to load the pronunciation dictionary: Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x1883cbb0 {NSFilePath=(null)/LanguageModelGeneratorLookupList.text, NSUnderlyingError=0x1883cb40 "The operation couldn’t be completed. No such file or directory"}
May 27 00:54:49 Phillips-iPhone SpringBoard[17785] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid domain=nil in -[NSError initWithDomain:code:userInfo:]'
非常感谢任何帮助完成这项工作。谢谢!