More fixes to the recognizer

This commit is contained in:
Gregory John Casamento 2020-02-06 04:29:51 -05:00
parent 8320300fdd
commit d3c1fd9724
6 changed files with 22 additions and 18 deletions

View file

@ -11,6 +11,7 @@
- (void) startListening;
- (void) stopListening;
- (void) recognize;
@end

View file

@ -18,4 +18,8 @@
{
}
- (void) recognize
{
}
@end

View file

@ -11,7 +11,6 @@
@interface GSSpeechRecognitionServer : NSObject
{
GSSpeechRecognitionEngine *_engine;
id<NSSpeechRecognizerDelegate> _delegate;
}
/**
@ -19,7 +18,7 @@
*/
+ (id)sharedServer;
- (void) setDelegate: (id<NSSpeechRecognizerDelegate>) delegate;
- (void) startListening;
- (void) stopListening;
- (id<NSSpeechRecognizerDelegate>) delegate;
@end

View file

@ -37,35 +37,28 @@ static GSSpeechRecognitionServer *sharedInstance;
[self release];
return nil;
}
else
{
NSLog(@"Got engine %@", _engine);
}
return self;
}
- (id)newRecognizer
{
return [[GSSpeechRecognizer new] autorelease];
GSSpeechRecognizer *r = [[GSSpeechRecognizer alloc] init];
RETAIN(r);
return r;
}
- (void) startListening
{
// abstract nothing to do...
[_engine startListening];
}
- (void) stopListening
{
// abstract nothing to do...
[_engine stopListening];
}
- (void) setDelegate: (id<NSSpeechRecognizerDelegate>)delegate
{
_delegate = delegate;
}
- (id<NSSpeechRecognizerDelegate>) delegate
{
return _delegate;
}
@end

View file

@ -10,8 +10,9 @@ static int clients;
@implementation GSSpeechRecognizer
+ (void)initialize
{
server = [[GSSpeechRecognitionServer sharedServer] retain];
server = [GSSpeechRecognitionServer sharedServer];
RETAIN(server);
if (server != nil)
{
clients++;
@ -58,12 +59,15 @@ static int clients;
self = [super init];
if (self != nil)
{
NSLog(@"self = %@",self);
RETAIN(server);
}
return self;
}
- (void)dealloc
{
NSLog(@"Deallocating recognizer....");
clients--;
if (clients == 0)
{
@ -78,6 +82,7 @@ static int clients;
- (void) startListening
{
NSLog(@"Start Listening");
if (server != nil)
{
[server startListening];
@ -86,6 +91,7 @@ static int clients;
- (void) stopListening
{
NSLog(@"Stop Listening");
if (server != nil)
{
[server stopListening];

View file

@ -174,6 +174,7 @@ static const arg_t cont_args_def[] = {
[[NSThread alloc] initWithTarget: self
selector: @selector(recognize)
object: nil];
NSLog(@"Thread info for speech reconigtion server %@", _listeningThread);
[_listeningThread start];
}