Implement both ignoring all recognizers, but the ones specified and ignoring when app is not active.

This commit is contained in:
Gregory John Casamento 2020-02-08 15:01:31 -05:00
parent efc901b79d
commit 4b1d3c679f
4 changed files with 107 additions and 2 deletions

View file

@ -35,6 +35,7 @@
@interface GSSpeechRecognitionServer : NSObject
{
GSSpeechRecognitionEngine *_engine;
NSMutableArray *_blocking;
}
/**
@ -42,7 +43,13 @@
*/
+ (id)sharedServer;
// Start and stop processing....
- (void) startListening;
- (void) stopListening;
// Add or remove from blocking list...
- (void) addToBlockingRecognizers: (NSString *)s;
- (void) removeFromBlockingRecognizers: (NSString *)s;
- (BOOL) isBlocking: (NSString *)s;
@end

View file

@ -100,7 +100,6 @@ static int _clients = 0;
}
_engine = [GSSpeechRecognitionEngine defaultSpeechRecognitionEngine];
if (nil == _engine)
{
[self release];
@ -110,10 +109,19 @@ static int _clients = 0;
{
NSLog(@"Got engine %@", _engine);
}
_blocking = [[NSMutableArray alloc] initWithCapacity: 10]; // 10 seems reasonable...
return self;
}
- (void) dealloc
{
RELEASE(_engine);
RELEASE(_blocking);
[super dealloc];
}
- (void) startListening
{
[_engine startListening];
@ -124,4 +132,19 @@ static int _clients = 0;
[_engine stopListening];
}
- (void) addToBlockingRecognizers: (NSString *)s
{
[_blocking addObject: s];
}
- (void) removeFromBlockingRecognizers: (NSString *)s
{
[_blocking removeObject: s];
}
- (BOOL) isBlocking: (NSString *)s
{
return [_blocking containsObject: s];
}
@end