Fix conflicts

This commit is contained in:
Gregory John Casamento 2020-01-31 04:43:30 -05:00
commit 7e9fb9ed53
5 changed files with 87 additions and 84 deletions

View file

@ -18,8 +18,8 @@
/* Define to 1 if you have the <flite/flite.h> header file. */
#undef HAVE_FLITE_FLITE_H
/* Define to 1 if you have the <pocketsphinx/pocketsphinx.h> header file */
#undef HAVE_LIBPOCKETSPHINX
/* Define to 1 if you have the pocketsphinx.h header file */
#undef HAVE_POCKETSPHINX_POCKETSPHINX_EXPORT_H
/* Define to 1 if you have the `floorf' function. */
#undef HAVE_FLOORF

View file

@ -28,7 +28,7 @@ include ../config.make
include ../Version
SUBPROJECTS = $(BUILD_SPEECH) $(BUILD_SOUND)
SUBPROJECTS = $(BUILD_SPEECH) $(BUILD_SOUND) $(BUILD_SPEECH_RECOGNITION)
TOOL_NAME = make_services set_show_service gopen gclose gcloseall
SERVICE_NAME = GSspell

View file

@ -8,114 +8,119 @@ cst_voice *register_cmu_us_kal16();
* for resource-constrained platforms.
*/
@interface FliteSpeechEngine : GSSpeechEngine {
/** The audio device used for sound output. */
cst_audiodev *ad;
/** The current voice. Only one supported at the moment. */
cst_voice *v;
/** Flag set to tell the playback thread to exit. */
volatile BOOL shouldEndSpeaking;
/** Flag indicating whether the engine is currently speaking. */
volatile BOOL isSpeaking;
/** The audio device used for sound output. */
cst_audiodev *ad;
/** The current voice. Only one supported at the moment. */
cst_voice *v;
/** Flag set to tell the playback thread to exit. */
volatile BOOL shouldEndSpeaking;
/** Flag indicating whether the engine is currently speaking. */
volatile BOOL isSpeaking;
}
@end
@implementation FliteSpeechEngine
+ (void)initialize
{
flite_init();
flite_init();
}
- (id)init
{
if (nil == (self = [super init])) { return nil; }
// Only one voice supported by flite unless others are compiled in.
v = register_cmu_us_kal16();
if (NULL == v)
{
[self release];
return nil;
}
// Each wave should be the same format.
cst_wave *w = flite_text_to_wave("test", v);
ad = audio_open(w->sample_rate, w->num_channels, CST_AUDIO_LINEAR16);
delete_wave(w);
if (NULL == ad)
{
[self release];
return nil;
}
return self;
if (nil == (self = [super init])) { return nil; }
// Only one voice supported by flite unless others are compiled in.
v = register_cmu_us_kal16();
if (NULL == v)
{
[self release];
return nil;
}
// Each wave should be the same format.
cst_wave *w = flite_text_to_wave("test", v);
ad = audio_open(w->sample_rate, w->num_channels, CST_AUDIO_LINEAR16);
delete_wave(w);
if (NULL == ad)
{
[self release];
return nil;
}
return self;
}
- (void)sayString: (NSArray*)args
{
id pool = [NSAutoreleasePool new];
NSString *aString = [args objectAtIndex: 0];
int i,n,r;
int num_shorts;
BOOL didFinish = YES;
cst_wave *w = flite_text_to_wave([aString UTF8String], v);
num_shorts = w->num_samples * w->num_channels;
for (i=0; i < num_shorts; i += r/2)
{
if (num_shorts > i+CST_AUDIOBUFFSIZE)
{
n = CST_AUDIOBUFFSIZE;
}
else
{
n = num_shorts-i;
}
r = audio_write(ad, &w->samples[i], n*2);
if (shouldEndSpeaking)
{
didFinish = NO;
break;
}
}
isSpeaking = NO;
NS_DURING
[[args objectAtIndex: 1] didFinishSpeaking: didFinish];
NS_HANDLER
NS_ENDHANDLER
[args release];
[pool release];
delete_wave(w);
id pool = [NSAutoreleasePool new];
NSString *aString = [args objectAtIndex: 0];
int i,n,r;
int num_shorts;
BOOL didFinish = YES;
cst_wave *w = flite_text_to_wave([aString UTF8String], v);
num_shorts = w->num_samples * w->num_channels;
for (i=0; i < num_shorts; i += r/2)
{
if (num_shorts > i+CST_AUDIOBUFFSIZE)
{
n = CST_AUDIOBUFFSIZE;
}
else
{
n = num_shorts-i;
}
r = audio_write(ad, &w->samples[i], n*2);
if (shouldEndSpeaking)
{
didFinish = NO;
break;
}
}
isSpeaking = NO;
NS_DURING
[[args objectAtIndex: 1] didFinishSpeaking: didFinish];
NS_HANDLER
NS_ENDHANDLER;
[args release];
[pool release];
delete_wave(w);
}
- (void)startSpeaking: (NSString*)aString notifyWhenDone: (id)aDelegate
{
[[[aDelegate delegate] connectionForProxy] enableMultipleThreads];
NSArray *arg = [[NSArray alloc] initWithObjects: aString, aDelegate, nil];
shouldEndSpeaking = NO;
isSpeaking = YES;
[NSThread detachNewThreadSelector: @selector(sayString:)
toTarget: self
withObject: arg];
[[[aDelegate delegate] connectionForProxy] enableMultipleThreads];
NSArray *arg = [[NSArray alloc] initWithObjects: aString, aDelegate, nil];
shouldEndSpeaking = NO;
isSpeaking = YES;
[NSThread detachNewThreadSelector: @selector(sayString:)
toTarget: self
withObject: arg];
}
- (BOOL)isSpeaking
{
return isSpeaking;
return isSpeaking;
}
- (void)stopSpeaking
{
shouldEndSpeaking = YES;
// Spin until the other thread has died.
while (isSpeaking) {}
shouldEndSpeaking = YES;
// Spin until the other thread has died.
while (isSpeaking) {}
}
- (void)dealloc
{
[self stopSpeaking];
audio_close(ad);
[super dealloc];
[self stopSpeaking];
audio_close(ad);
[super dealloc];
}
@end
@implementation GSSpeechEngine (Flite)
+ (GSSpeechEngine*)defaultSpeechEngine
{
return [[[FliteSpeechEngine alloc] init] autorelease];
return [[[FliteSpeechEngine alloc] init] autorelease];
}
@end

1
configure vendored
View file

@ -5735,7 +5735,6 @@ fi
done
if test $have_pocketsphinx = yes -a $have_speech_recognizer = yes -a $enable_speech_recognizer = yes; then
#if test $have_speech_recognizer = yes -a $enable_speech_recognizer = yes; then
BUILD_SPEECH_RECOGNIZER="speech_recognizer"
POCKETSPHINX_BASE_LIBS="-lpocketsphinx"
fi

View file

@ -550,7 +550,6 @@ BUILD_SPEECH_RECOGNIZER=
AC_CHECK_LIB(pocketsphinx, ps_start_utt, have_speech_recognizer=yes, have_speech_recognizer=no)
AC_CHECK_HEADERS(pocketsphinx/pocketsphinx_export.h, have_pocketsphinx=yes, have_pocketsphinx=no)
if test $have_pocketsphinx = yes -a $have_speech_recognizer = yes -a $enable_speech_recognizer = yes; then
#if test $have_speech_recognizer = yes -a $enable_speech_recognizer = yes; then
BUILD_SPEECH_RECOGNIZER="speech_recognizer"
POCKETSPHINX_BASE_LIBS="-lpocketsphinx"
fi