【发布时间】:2013-02-19 16:26:37
【问题描述】:
我正在尝试在 MacBook(OS 10.8.2)上进行语音识别,但我从未在委托方法上收到任何回调。将 XCode 4.6 与 ARC 一起使用,这是我的简单测试代码。我确实在控制台中得到了“监听”输出。 “麦克风”出现在屏幕上,如果我按下 ESC 键,那么我可以在麦克风的显示屏上看到我的讲话模式,但仍然没有任何代表回调。肯定少了一些基本的东西,但我没找到。
我查看了许多 SO 问题,但没有一个能解决这个问题。有人在控制面板中谈论校准,但我发现那里没有校准(可能是以前的操作系统?)。
完整的项目源代码在github。
#import "RBListener.h"
@interface RBListener() <NSSpeechRecognizerDelegate>
@property (nonatomic, strong, readonly) NSSpeechRecognizer* recognizer;
@property (nonatomic, strong) NSArray* commands;
@end
@implementation RBListener
@synthesize recognizer = _recognizer;
- (id)init
{
self = [super init];
if (self) {
// initialize
_commands = @[@"hi", @"yes", @"no", @"hello", @"good", @"time"];
_recognizer = [[NSSpeechRecognizer alloc] init];
_recognizer.delegate = self;
_recognizer.commands = _commands;
_recognizer.listensInForegroundOnly = NO;
_recognizer.blocksOtherRecognizers = YES;
[_recognizer startListening];
DLog(@"listening");
}
return self;
}
#pragma mark -
#pragma mark NSSpeechRecognizerDelegate methods
- (void)speechRecognizer:(NSSpeechRecognizer*)sender didRecognizeCommand:(id)command
{
DLog(@"command: %@", command);
}
@end
【问题讨论】:
-
我不确定它是否与您的整个问题有很大关系,但 Calibrate 仍然存在。在“系统偏好设置”中选择“辅助功能”,选择左侧的“Speakable Items”,然后选择“Settings”选项卡。
-
@NJones 啊哈,这解释了为什么我找不到校准,我在“首选项”中的“听写和语音”下查看。我会尝试校准,但我不确定它是否会有所帮助。
-
校准是的问题。由于我已经校准它现在可以工作了。
标签: macos cocoa speech-recognition speech