libs-gui/Tools/say/say.m
gcasa ef7248efba * config.make.in: Change to include BUILD_SPEECH in output
* configure: Regenerated
	* configure.ac: Check for flite library and flite.h header.
	* Tools/GNUmakefile: Add ${BUILD_SPEECH} to subproject list.
	* Tools/say/GNUmakefile
	* Tools/say/say.m: Say utility
	* Tools/speech/FliteSpeechEngine.m: 
	* Tools/speech/GNUmakefile
	* Tools/speech/GSSpeechEngine.[hm]
	* Tools/speech/GSSpeechServer.[hm]
	* Tools/speech/GSSpeechSynthesizer.[hm]: Speech synthesis engine
	implementation using flite.
	* Tools/speech/main.m: main for the server application.
	Speech code by David Chisnall <theraven@sucs.org>
	Changes to makefiles and config by Gregory Casamento.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28430 72102866-910b-0410-8b05-ffd578937521
2009-08-02 00:33:19 +00:00

62 lines
1.4 KiB
Objective-C

#import <AppKit/AppKit.h>
#include <unistd.h>
#include <getopt.h>
@interface SpeechDelegate : NSObject @end
@implementation SpeechDelegate
- (void)speechSynthesizer: (NSSpeechSynthesizer*)sender
didFinishSpeaking: (BOOL)success
{
exit((int)success);
}
@end
int main(int argc, char **argv)
{
[NSAutoreleasePool new];
NSMutableString *words = [NSMutableString string];
NSString *outFile = nil;
NSString *voice = nil;
NSString *inFile = nil;
int ch;
while ((ch = getopt(argc, argv, "o:v:f:")) != -1)
{
switch (ch)
{
case 'o':
outFile = [NSString stringWithUTF8String: optarg];
break;
case 'f':
inFile = [NSString stringWithUTF8String: optarg];
break;
case 'v':
voice = [NSString stringWithUTF8String: optarg];
break;
}
}
int i;
for (i=optind ; i<argc ; i++)
{
[words appendString: [NSString stringWithUTF8String: argv[i]]];
[words appendString: @" "];
}
NSSpeechSynthesizer *say = [[NSSpeechSynthesizer alloc] initWithVoice: voice];
if (nil != inFile)
{
[words release];
NSData *file = [NSData dataWithContentsOfFile: inFile];
words = [NSString stringWithCString: [file bytes]];
}
// Don't interrupt other apps.
while ([NSSpeechSynthesizer isAnyApplicationSpeaking])
{
[NSThread sleepForTimeInterval: 0.1];
}
[say setDelegate: [SpeechDelegate new]];
[say startSpeakingString: words];
[[NSRunLoop currentRunLoop] run];
// Not reached.
return 0;
}