mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-27 14:50:45 +00:00
* 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
62 lines
1.4 KiB
Objective-C
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;
|
|
}
|