mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 00:00:48 +00:00
* Headers/AppKit/NSSpeechSynthesizer.h:
* Source/NSSpeechSynthesizer.m: Implementation of NSSpeechSynthesizer. Patch by David Chisnall <theraven@sucs.org> git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28327 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
82e5af8ba4
commit
a1d6980672
3 changed files with 77 additions and 40 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,10 @@
|
||||||
|
2009-06-05 18:21-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSSpeechSynthesizer.h:
|
||||||
|
* Source/NSSpeechSynthesizer.m: Implementation of
|
||||||
|
NSSpeechSynthesizer.
|
||||||
|
Patch by David Chisnall <theraven@sucs.org>
|
||||||
|
|
||||||
2009-06-02 Fred Kiefer <FredKiefer@gmx.de>
|
2009-06-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSDocument.m (-runModalSavePanelForSaveOperation:...):
|
* Source/NSDocument.m (-runModalSavePanelForSaveOperation:...):
|
||||||
|
@ -62,7 +69,8 @@
|
||||||
|
|
||||||
2009-04-27 Fred Kiefer <FredKiefer@gmx.de>
|
2009-04-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSBezierPath.m (-appendBezierPathWithRoundedRect:xRadius:yRadius:):
|
* Source/NSBezierPath.m (-appendBezierPathWithRoundedRect:xRadius:
|
||||||
|
yRadius:):
|
||||||
Small rearangment of code.
|
Small rearangment of code.
|
||||||
Patch by Fred Morcos <fred.morcos@gmail.com>
|
Patch by Fred Morcos <fred.morcos@gmail.com>
|
||||||
|
|
||||||
|
|
|
@ -95,17 +95,6 @@ extern NSString *NSSpeechDictionaryEntryPhonemes;
|
||||||
|
|
||||||
// class declaration...
|
// class declaration...
|
||||||
@interface NSSpeechSynthesizer : NSObject
|
@interface NSSpeechSynthesizer : NSObject
|
||||||
{
|
|
||||||
NSString *_voice;
|
|
||||||
BOOL _usesFeedbackWindow;
|
|
||||||
float _rate;
|
|
||||||
float _volume;
|
|
||||||
id _delegate;
|
|
||||||
NSMutableArray *_dictionaries;
|
|
||||||
NSMutableDictionary *_properties;
|
|
||||||
BOOL _isSpeaking;
|
|
||||||
id _module;
|
|
||||||
}
|
|
||||||
|
|
||||||
// init...
|
// init...
|
||||||
- (id) initWithVoice: (NSString *)voice;
|
- (id) initWithVoice: (NSString *)voice;
|
||||||
|
|
|
@ -29,7 +29,10 @@
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
|
#include <Foundation/NSThread.h>
|
||||||
#include <Foundation/NSError.h>
|
#include <Foundation/NSError.h>
|
||||||
|
#include <Foundation/NSConnection.h>
|
||||||
|
#include "AppKit/NSWorkspace.h"
|
||||||
#include "AppKit/NSSpeechSynthesizer.h"
|
#include "AppKit/NSSpeechSynthesizer.h"
|
||||||
|
|
||||||
// Keys for properties...
|
// Keys for properties...
|
||||||
|
@ -83,53 +86,106 @@ NSString *NSSpeechDictionaryAbreviations = @"NSSpeechDictionaryAbreviations";
|
||||||
NSString *NSSpeechDictionaryEntrySpelling = @"NSSpeechDictionaryEntrySpelling";
|
NSString *NSSpeechDictionaryEntrySpelling = @"NSSpeechDictionaryEntrySpelling";
|
||||||
NSString *NSSpeechDictionaryEntryPhonemes = @"NSSpeechDictionaryEntryPhonemes";
|
NSString *NSSpeechDictionaryEntryPhonemes = @"NSSpeechDictionaryEntryPhonemes";
|
||||||
|
|
||||||
// class declaration...
|
// Speech daemon
|
||||||
|
static id server;
|
||||||
|
// Flag indicating whether we should wait for the daemon to finish launching.
|
||||||
|
static BOOL serverLaunchTested;
|
||||||
|
// Class of the NSSpeechSynthesizer
|
||||||
|
static Class NSSpeechSynthesizerClass;
|
||||||
|
// Informal protocol used for the server.
|
||||||
|
@interface NSObject (GSSpeechServer)
|
||||||
|
- (NSSpeechSynthesizer*)newSynthesizer;
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSSpeechSynthesizer
|
@implementation NSSpeechSynthesizer
|
||||||
// init...
|
|
||||||
- (id) initWithVoice: (NSString *)voice
|
- (id) initWithVoice: (NSString *)voice
|
||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
NSSpeechSynthesizerClass = [NSSpeechSynthesizer class];
|
||||||
|
server = [[NSConnection rootProxyForConnectionWithRegisteredName: @"GSSpeechServer"
|
||||||
|
host: nil] retain];
|
||||||
|
if (nil == server)
|
||||||
|
{
|
||||||
|
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
|
||||||
|
[ws launchApplication: @"GSSpeechServer"
|
||||||
|
showIcon: NO
|
||||||
|
autolaunch: NO];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ (BOOL)isAnyApplicationSpeaking
|
||||||
|
{
|
||||||
|
return [server isSpeaking];
|
||||||
|
}
|
||||||
|
// Never really allocate one of these.
|
||||||
|
+ (id)allocWithZone: (NSZone*)aZone
|
||||||
|
{
|
||||||
|
if (self == NSSpeechSynthesizerClass)
|
||||||
|
{
|
||||||
|
if (nil == server && !serverLaunchTested)
|
||||||
|
{
|
||||||
|
unsigned int i=0;
|
||||||
|
// Wait for up to five seconds for the server to launch, then give up.
|
||||||
|
for (i=0 ; i<50 ; i++)
|
||||||
|
{
|
||||||
|
server =
|
||||||
|
[[NSConnection rootProxyForConnectionWithRegisteredName:
|
||||||
|
@"GSSpeechServer"
|
||||||
|
host: nil]
|
||||||
|
retain];
|
||||||
|
if (nil != server)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
[NSThread sleepForTimeInterval: 0.1];
|
||||||
|
}
|
||||||
|
// Set a flag so we don't bother waiting for the speech server to
|
||||||
|
// launch the next time if it didn't work this time.
|
||||||
|
serverLaunchTested = YES;
|
||||||
|
}
|
||||||
|
// If there is no server, this will return nil
|
||||||
|
return [server newSynthesizer];
|
||||||
|
}
|
||||||
|
return [super allocWithZone: aZone];
|
||||||
|
}
|
||||||
|
|
||||||
// configuring speech synthesis
|
// configuring speech synthesis
|
||||||
- (BOOL) usesFeebackWindow
|
- (BOOL) usesFeebackWindow
|
||||||
{
|
{
|
||||||
return _usesFeedbackWindow;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setUsesFeebackWindow: (BOOL)flag
|
- (void) setUsesFeebackWindow: (BOOL)flag
|
||||||
{
|
{
|
||||||
_usesFeedbackWindow = flag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) voice
|
- (NSString *) voice
|
||||||
{
|
{
|
||||||
return _voice;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setVoice: (NSString *)voice
|
- (void) setVoice: (NSString *)voice
|
||||||
{
|
{
|
||||||
ASSIGN(_voice, voice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) rate
|
- (float) rate
|
||||||
{
|
{
|
||||||
return _rate;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setRate: (float)rate
|
- (void) setRate: (float)rate
|
||||||
{
|
{
|
||||||
_rate = rate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) volume
|
- (float) volume
|
||||||
{
|
{
|
||||||
return _volume;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setVolume: (float)volume
|
- (void) setVolume: (float)volume
|
||||||
{
|
{
|
||||||
_volume = volume;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) addSpeechDictionary: (NSDictionary *)speechDictionary
|
- (void) addSpeechDictionary: (NSDictionary *)speechDictionary
|
||||||
|
@ -145,18 +201,16 @@ NSString *NSSpeechDictionaryEntryPhonemes = @"NSSpeechDictionaryEntryPhonemes";
|
||||||
forProperty: (NSString *)property
|
forProperty: (NSString *)property
|
||||||
error: (NSError **)error
|
error: (NSError **)error
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) delegate
|
- (id) delegate
|
||||||
{
|
{
|
||||||
return _delegate;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setDelegate: (id)delegate
|
- (void) setDelegate: (id)delegate
|
||||||
{
|
{
|
||||||
_delegate = delegate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting information...
|
// Getting information...
|
||||||
|
@ -172,57 +226,43 @@ NSString *NSSpeechDictionaryEntryPhonemes = @"NSSpeechDictionaryEntryPhonemes";
|
||||||
|
|
||||||
+ (NSString *) defaultVoice
|
+ (NSString *) defaultVoice
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting state...
|
|
||||||
+ (BOOL) isAnyApplicationSpeaking
|
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Synthesizing..
|
// Synthesizing..
|
||||||
- (BOOL) isSpeaking
|
- (BOOL) isSpeaking
|
||||||
{
|
{
|
||||||
return _isSpeaking;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) startSpeakingString: (NSString *)text
|
- (BOOL) startSpeakingString: (NSString *)text
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) startSpeakingString: (NSString *)text toURL: (NSURL *)url
|
- (BOOL) startSpeakingString: (NSString *)text toURL: (NSURL *)url
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) stopSpeaking
|
- (void) stopSpeaking
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) stopSpeakingAtBoundary: (NSSpeechBoundary)boundary
|
- (void) stopSpeakingAtBoundary: (NSSpeechBoundary)boundary
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) pauseSpeakingAtBoundary: (NSSpeechBoundary)boundary
|
- (void) pauseSpeakingAtBoundary: (NSSpeechBoundary)boundary
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) continueSpeaking
|
- (void) continueSpeaking
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) phonemesFromText: (NSString *)text
|
- (NSString *) phonemesFromText: (NSString *)text
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue