[Freeswitch-svn] [commit] r12224 - in freeswitch/trunk: scripts src/mod/asr_tts/mod_pocketsphinx
FreeSWITCH SVN
brian at freeswitch.org
Sat Feb 21 14:47:15 PST 2009
Author: brian
Date: Sat Feb 21 16:47:15 2009
New Revision: 12224
Log:
Revamp mod_pocketsphinx to use jsgf format. Known bugs which are going to be fixed are:
Using words in your grammar that aren't in the dictionary will segfault. Bug is already brought up with the pocketsphinx maintainer.
/b
Added:
freeswitch/trunk/scripts/yes_no.gram
Modified:
freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/Makefile
freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c
Added: freeswitch/trunk/scripts/yes_no.gram
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/yes_no.gram Sat Feb 21 16:47:15 2009
@@ -0,0 +1,14 @@
+#JSGF V1.0;
+
+/**
+ * JSGF Grammar for example
+ */
+
+grammar example;
+
+<yes> = [ yes ];
+<no> = [ no ];
+
+public <results> = [ <yes> | <no> ];
+
+
Modified: freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/Makefile (original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/Makefile Sat Feb 21 16:47:15 2009
@@ -15,7 +15,7 @@
include $(BASE)/build/modmake.rules
$(SPHINXBASE_DIR):
- $(GETLIB) $(SPHINXBASE).tar.gz
+ $(GETLIB) $(SPHINXBASE)-latest.tar.gz
$(SPHINXBASE_DIR)/buildstamp: $(SPHINXBASE_DIR)
test -f $(SPHINXBASE_DIR)/Makefile || (cd $(SPHINXBASE_DIR) && ./configure --with-pic --without-python --disable-shared CFLAGS=)
@@ -26,7 +26,7 @@
$(TOUCH_TARGET)
$(POCKETSPHINX_DIR):
- $(GETLIB) $(POCKETSPHINX).tar.gz
+ $(GETLIB) $(POCKETSPHINX)-latest.tar.gz
$(POCKETSPHINX_DIR)/Makefile: $(POCKETSPHINX_DIR)
cd $(POCKETSPHINX_DIR) && ./configure --with-pic --without-python --disable-shared --with-sphinxbase=$(SPHINXBASE_DIR) CFLAGS=
@@ -51,12 +51,7 @@
mkdir -p $(DESTDIR)$(PREFIX)/grammar/model/wsj1
mv $(POCKETSPHINX_DIR)/model/hmm/wsj1/* $(DESTDIR)$(PREFIX)/grammar/model/wsj1
-grammar_maker:
- @cp -f $(BASE)/scripts/mklm $(DESTDIR)$(PREFIX)/bin/mklm
- @cp -f $(BASE)/scripts/quick_lm.pl $(DESTDIR)$(PREFIX)/bin/quick_lm.pl
- @chmod 755 $(DESTDIR)$(PREFIX)/bin/mklm
- @chmod 755 $(DESTDIR)$(PREFIX)/bin/quick_lm.pl
- @cp -f $(BASE)/scripts/Makefile.gram $(DESTDIR)$(PREFIX)/grammar/Makefile
- @cp -f $(POCKETSPHINX_DIR)/model/lm/cmudict.0.6d $(DESTDIR)$(PREFIX)/conf/cmudict.0.6d
+dictionary:
+ @cp -f $(POCKETSPHINX_DIR)/model/lm/cmudict.0.6d $(DESTDIR)$(PREFIX)/grammar/default.dic
-local_install: $(DESTDIR)$(PREFIX)/grammar/model $(DESTDIR)$(PREFIX)/grammar/model/communicator $(DESTDIR)$(PREFIX)/grammar/model/wsj1 grammar_maker
+local_install: $(DESTDIR)$(PREFIX)/grammar/model $(DESTDIR)$(PREFIX)/grammar/model/communicator $(DESTDIR)$(PREFIX)/grammar/model/wsj1 dictionary
Modified: freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c (original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c Sat Feb 21 16:47:15 2009
@@ -113,7 +113,7 @@
/*! function to load a grammar to the asr interface */
static switch_status_t pocketsphinx_asr_load_grammar(switch_asr_handle_t *ah, const char *grammar, const char *path)
{
- char *lm, *dic, *model, *rate = NULL;
+ char *jsgf, *dic, *model, *rate = NULL;
pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
switch_status_t status = SWITCH_STATUS_FALSE;
@@ -123,11 +123,9 @@
}
if (switch_is_file_path(grammar)) {
- lm = switch_mprintf("%s%s%s.lm", grammar, SWITCH_PATH_SEPARATOR, grammar);
- dic = switch_mprintf("%s%s%s.dic", grammar, SWITCH_PATH_SEPARATOR, grammar);
+ jsgf = switch_mprintf("%s.gram", grammar);
} else {
- lm = switch_mprintf("%s%s%s%s%s.lm", SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_PATH_SEPARATOR, grammar, SWITCH_PATH_SEPARATOR, grammar);
- dic = switch_mprintf("%s%s%s%s%s.dic", SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_PATH_SEPARATOR, grammar, SWITCH_PATH_SEPARATOR, grammar);
+ jsgf = switch_mprintf("%s%s%s.gram", SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_PATH_SEPARATOR, grammar);
}
if (ah->rate == 8000) {
@@ -135,24 +133,27 @@
} else {
model = switch_mprintf("%s%smodel%s%s", SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_PATH_SEPARATOR, SWITCH_PATH_SEPARATOR, globals.model16k);
}
+
+ dic = switch_mprintf("%s%sdefault.dic", SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_PATH_SEPARATOR, grammar);
+
if (switch_file_exists(dic, ah->memory_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open dictionary %s.\n", dic);
goto end;
}
- if (switch_file_exists(lm, ah->memory_pool) != SWITCH_STATUS_SUCCESS) {
+ if (switch_file_exists(jsgf, ah->memory_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't open language model %s.\n", model);
goto end;
}
rate = switch_mprintf("%d", ah->rate);
- switch_assert(lm && dic && model);
+ switch_assert(jsgf && dic && model);
ps->config = cmd_ln_init(ps->config, ps_args(), FALSE,
"-samprate", rate,
"-hmm", model,
- "-lm", lm,
+ "-jsgf", jsgf,
"-dict", dic,
"-frate", "50",
"-silprob", "0.005",
@@ -185,7 +186,7 @@
end:
switch_safe_free(rate);
- switch_safe_free(lm);
+ switch_safe_free(jsgf);
switch_safe_free(dic);
switch_safe_free(model);
@@ -201,15 +202,12 @@
/*! function to close the asr interface */
static switch_status_t pocketsphinx_asr_close(switch_asr_handle_t *ah, switch_asr_flag_t *flags)
{
- char const *hyp;
- int32_t score;
pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
switch_mutex_lock(ps->flag_mutex);
if (switch_test_flag(ps, PSFLAG_ALLOCATED)) {
if (switch_test_flag(ps, PSFLAG_READY)) {
ps_end_utt(ps->ps);
- hyp = ps_get_hyp(ps->ps, &score, &ps->uttid);
}
ps_free(ps->ps);
ps->ps = NULL;
More information about the Freeswitch-svn
mailing list