mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 19:01:15 +00:00
Cleanup speech synth implementation. Correct recognizer.
This commit is contained in:
parent
a9bc3fe5d9
commit
8320300fdd
5 changed files with 69 additions and 39 deletions
|
@ -186,17 +186,11 @@ BOOL _serverLaunchTested = NO;
|
|||
// Listening
|
||||
- (void) startListening
|
||||
{
|
||||
if (_speechRecognitionServer != nil)
|
||||
{
|
||||
[_speechRecognitionServer startListening];
|
||||
}
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) stopListening
|
||||
{
|
||||
if (_speechRecognitionServer != nil)
|
||||
{
|
||||
[_speechRecognitionServer stopListening];
|
||||
}
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -8,65 +8,80 @@ static GSSpeechServer *sharedInstance;
|
|||
@implementation GSSpeechServer
|
||||
+ (void)initialize
|
||||
{
|
||||
sharedInstance = [self new];
|
||||
sharedInstance = [self new];
|
||||
}
|
||||
|
||||
+ (void)start
|
||||
{
|
||||
NSConnection *connection = [NSConnection defaultConnection];
|
||||
[connection setRootObject: sharedInstance];
|
||||
if (NO == [connection registerName: @"GSSpeechServer"])
|
||||
{
|
||||
return;
|
||||
}
|
||||
[[NSRunLoop currentRunLoop] run];
|
||||
NSConnection *connection = [NSConnection defaultConnection];
|
||||
[connection setRootObject: sharedInstance];
|
||||
if (NO == [connection registerName: @"GSSpeechServer"])
|
||||
{
|
||||
return;
|
||||
}
|
||||
[[NSRunLoop currentRunLoop] run];
|
||||
}
|
||||
|
||||
+ (id)sharedServer
|
||||
{
|
||||
return sharedInstance;
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (nil == (self = [super init])) { return nil; }
|
||||
engine = [GSSpeechEngine defaultSpeechEngine];
|
||||
if (nil == engine)
|
||||
{
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
return self;
|
||||
if (nil == (self = [super init]))
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
engine = [GSSpeechEngine defaultSpeechEngine];
|
||||
if (nil == engine)
|
||||
{
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)newSynthesizer
|
||||
{
|
||||
return [[GSSpeechSynthesizer new] autorelease];
|
||||
return [[GSSpeechSynthesizer new] autorelease];
|
||||
}
|
||||
|
||||
- (BOOL)startSpeakingString: (NSString*)aString notifyWhenDone: (id)client
|
||||
{
|
||||
[engine stopSpeaking];
|
||||
[engine startSpeaking: aString notifyWhenDone: client];
|
||||
return YES;
|
||||
[engine stopSpeaking];
|
||||
[engine startSpeaking: aString notifyWhenDone: client];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)stopSpeaking
|
||||
{
|
||||
[engine stopSpeaking];
|
||||
[engine stopSpeaking];
|
||||
}
|
||||
|
||||
- (BOOL)isSpeaking
|
||||
{
|
||||
return [engine isSpeaking];
|
||||
return [engine isSpeaking];
|
||||
}
|
||||
|
||||
- (NSArray*)voices
|
||||
{
|
||||
return [engine voices];
|
||||
return [engine voices];
|
||||
}
|
||||
|
||||
- (oneway void)setVoice: (NSString*)aVoice
|
||||
{
|
||||
[engine setVoice: aVoice];
|
||||
[engine setVoice: aVoice];
|
||||
}
|
||||
|
||||
- (NSString*)voice
|
||||
{
|
||||
return [engine voice];
|
||||
return [engine voice];
|
||||
}
|
||||
|
||||
- (NSString*)defaultVoice
|
||||
{
|
||||
return [engine defaultVoice];
|
||||
return [engine defaultVoice];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -48,11 +48,13 @@ static GSSpeechRecognitionServer *sharedInstance;
|
|||
- (void) startListening
|
||||
{
|
||||
// abstract nothing to do...
|
||||
[_engine startListening];
|
||||
}
|
||||
|
||||
- (void) stopListening
|
||||
{
|
||||
// abstract nothing to do...
|
||||
[_engine stopListening];
|
||||
}
|
||||
|
||||
- (void) setDelegate: (id<NSSpeechRecognizerDelegate>)delegate
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#import "GSSpeechRecognitionServer.h"
|
||||
#import <AppKit/NSSpeechRecognizer.h>
|
||||
|
||||
|
||||
@interface GSSpeechRecognizer : NSSpeechRecognizer {
|
||||
}
|
||||
- (id)init;
|
||||
@interface GSSpeechRecognizer : NSSpeechRecognizer
|
||||
@end
|
||||
|
|
|
@ -11,6 +11,12 @@ static int clients;
|
|||
+ (void)initialize
|
||||
{
|
||||
server = [[GSSpeechRecognitionServer sharedServer] retain];
|
||||
|
||||
if (server != nil)
|
||||
{
|
||||
clients++;
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(connectionDied:)
|
||||
|
@ -70,4 +76,20 @@ static int clients;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) startListening
|
||||
{
|
||||
if (server != nil)
|
||||
{
|
||||
[server startListening];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) stopListening
|
||||
{
|
||||
if (server != nil)
|
||||
{
|
||||
[server stopListening];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue