2020-02-01 10:43:06 +00:00
|
|
|
#import "GSSpeechRecognitionEngine.h"
|
2020-02-03 06:02:50 +00:00
|
|
|
#include <pocketsphinx/pocketsphinx.h>
|
2020-01-30 21:28:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-02-01 10:43:06 +00:00
|
|
|
* Implementation of a speech engine using pocketsphinx. This should be the default
|
2020-01-30 21:28:18 +00:00
|
|
|
* for resource-constrained platforms.
|
|
|
|
*/
|
2020-02-03 12:56:55 +00:00
|
|
|
|
|
|
|
#define MODELDIR "/share/pocketsphinx/model"
|
|
|
|
|
|
|
|
/*
|
|
|
|
ps_decoder_t *ps = NULL;
|
|
|
|
cmd_ln_t *config = NULL;
|
|
|
|
|
|
|
|
config = cmd_ln_init(NULL, ps_args(), TRUE,
|
|
|
|
"-hmm", MODELDIR "/en-us/en-us",
|
|
|
|
"-lm", MODELDIR "/en-us/en-us.lm.bin",
|
|
|
|
"-dict", MODELDIR "/en-us/cmudict-en-us.dict",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
*/
|
2020-02-01 10:57:32 +00:00
|
|
|
@interface PocketsphinxSpeechRecognitionEngine : GSSpeechRecognitionEngine
|
2020-02-01 10:43:06 +00:00
|
|
|
{
|
2020-02-03 12:56:55 +00:00
|
|
|
ps_decoder_t *ps;
|
|
|
|
cmd_ln_t *config;
|
2020-01-30 21:28:18 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2020-02-01 10:57:32 +00:00
|
|
|
@implementation PocketsphinxSpeechRecognitionEngine
|
2020-02-03 12:56:55 +00:00
|
|
|
|
2020-01-30 21:28:18 +00:00
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)init
|
|
|
|
{
|
2020-02-03 12:56:55 +00:00
|
|
|
if (nil != (self = [super init]))
|
|
|
|
{
|
|
|
|
config = cmd_ln_init(NULL, ps_args(), TRUE,
|
|
|
|
"-hmm", MODELDIR "/en-us/en-us",
|
|
|
|
"-lm", MODELDIR "/en-us/en-us.lm.bin",
|
|
|
|
"-dict", MODELDIR "/en-us/cmudict-en-us.dict",
|
|
|
|
NULL);
|
|
|
|
ps = ps_init(config);
|
|
|
|
}
|
2020-01-30 21:28:18 +00:00
|
|
|
return self;
|
|
|
|
}
|
2020-02-03 06:02:50 +00:00
|
|
|
|
|
|
|
- (void) startListening
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) stopListening
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-01-30 21:28:18 +00:00
|
|
|
@end
|
|
|
|
|
2020-02-01 10:43:06 +00:00
|
|
|
@implementation GSSpeechRecognitionEngine (Pocketsphinx)
|
2020-02-03 12:56:55 +00:00
|
|
|
|
2020-02-01 10:43:06 +00:00
|
|
|
+ (GSSpeechRecognitionEngine*)defaultSpeechRecognitionEngine
|
2020-01-30 21:28:18 +00:00
|
|
|
{
|
2020-02-01 10:43:06 +00:00
|
|
|
return [[[PocketsphinxSpeechRecognitionEngine alloc] init] autorelease];
|
2020-01-30 21:28:18 +00:00
|
|
|
}
|
2020-02-03 12:56:55 +00:00
|
|
|
|
2020-01-30 21:28:18 +00:00
|
|
|
@end
|