Skip to content

Commit 8aebba7

Browse files
committed
WIP mod_pocketsphinx
1 parent c538297 commit 8aebba7

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,14 @@ PKG_CHECK_MODULES([AMQP], [librabbitmq >= 0.5.2], [
15631563
AM_CONDITIONAL([HAVE_AMQP], [false])
15641564
])
15651565

1566+
PKG_CHECK_MODULES([SPHINXBASE], [sphinxbase >= 5],[
1567+
AM_CONDITIONAL([HAVE_SPHINXBASE],[true])],[
1568+
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SPHINXBASE],[false])])
1569+
1570+
PKG_CHECK_MODULES([POCKETSPHINX], [pocketsphinx >= 5],[
1571+
AM_CONDITIONAL([HAVE_POCKETSPHINX],[true])],[
1572+
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_POCKETSPHINX],[false])])
1573+
15661574
PKG_CHECK_MODULES([H2O], [libh2o-evloop >= 0.11.0],[
15671575
AM_CONDITIONAL([HAVE_H2O],[true])],[
15681576
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_H2O],[false])])

debian/control-modules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ Build-Depends: libflite-dev | flite1-dev
232232
Module: asr_tts/mod_pocketsphinx
233233
Description: mod_pocketsphinx
234234
Adds mod_pocketsphinx.
235+
Build-Depends: libsphinxbase-dev, libpocketsphinx-dev
235236

236237
Module: asr_tts/mod_tts_commandline
237238
Description: mod_tts_commandline

src/mod/asr_tts/mod_pocketsphinx/Makefile.am

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ SPHINXMODEL=communicator_semi_6000_20080321
1616

1717
mod_LTLIBRARIES = mod_pocketsphinx.la
1818
mod_pocketsphinx_la_SOURCES = mod_pocketsphinx.c
19+
mod_pocketsphinx_la_LDFLAGS = -avoid-version -module -no-undefined -shared
20+
if HAVE_POCKETSPHINX
21+
mod_pocketsphinx_la_CFLAGS = $(AM_CFLAGS) $(SPHINXBASE_CFLAGS) $(POCKETSPHINX_CFLAGS)
22+
mod_pocketsphinx_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(POCKETSPHINX_LDFLAGS) $(SPHINXBASE_LDFLAGS)
23+
else
1924
mod_pocketsphinx_la_CFLAGS = $(AM_CFLAGS) -I$(SPHINXBASE_DIR)/include -I$(POCKETSPHINX_DIR)/include
2025
mod_pocketsphinx_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
21-
mod_pocketsphinx_la_LDFLAGS = -avoid-version -module -no-undefined -shared
2226

2327
BUILT_SOURCES=$(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
28+
endif
2429

2530
$(SPHINXBASE_DIR):
2631
$(GETLIB) $(SPHINXBASE).tar.gz
@@ -66,5 +71,8 @@ $(DESTDIR)$(grammardir)/model/communicator:
6671
dictionary:
6772
@install -m0644 $(POCKETSPHINX_DIR)/model/lm/en_US/cmu07a.dic $(DESTDIR)$(grammardir)/default.dic
6873

74+
if HAVE_POCKETSPHINX
75+
install-data-local: $(POCKETSPHINX_DIR) $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary
76+
else
6977
install-data-local: $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary
70-
78+
endif

src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static switch_status_t pocketsphinx_asr_load_grammar(switch_asr_handle_t *ah, co
203203
}
204204
switch_mutex_unlock(ps->flag_mutex);
205205

206-
ps_start_utt(ps->ps, NULL);
206+
ps_start_utt(ps->ps);
207207
ps->silence_time = switch_micro_time_now();
208208
switch_clear_flag(ps, PSFLAG_START_OF_SPEECH);
209209
switch_clear_flag(ps, PSFLAG_NOINPUT_TIMEOUT);
@@ -338,22 +338,22 @@ static switch_status_t pocketsphinx_asr_feed(switch_asr_handle_t *ah, void *data
338338
char const *hyp;
339339

340340
switch_mutex_lock(ps->flag_mutex);
341-
if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
341+
if ((hyp = ps_get_hyp(ps->ps, &ps->score))) {
342342
if (!zstr(hyp)) {
343343
ps_end_utt(ps->ps);
344344
switch_clear_flag(ps, PSFLAG_READY);
345-
if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
345+
if ((hyp = ps_get_hyp(ps->ps, &ps->score))) {
346346
if (zstr(hyp)) {
347347
if (!switch_test_flag(ps, PSFLAG_SPEECH_TIMEOUT)) {
348348
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost the text, never mind....\n");
349-
ps_start_utt(ps->ps, NULL);
349+
ps_start_utt(ps->ps);
350350
switch_set_flag(ps, PSFLAG_READY);
351351
}
352352
} else {
353353
/* get match and confidence */
354354
int32_t conf;
355355

356-
conf = ps_get_prob(ps->ps, &ps->uttid);
356+
conf = ps_get_prob(ps->ps);
357357

358358
ps->confidence = (conf + 20000) / 200;
359359

@@ -427,7 +427,7 @@ static switch_status_t pocketsphinx_asr_resume(switch_asr_handle_t *ah)
427427
if (!switch_test_flag(ps, PSFLAG_READY)) {
428428
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Manually Resuming\n");
429429

430-
if (ps_start_utt(ps->ps, NULL)) {
430+
if (ps_start_utt(ps->ps)) {
431431
status = SWITCH_STATUS_GENERR;
432432
} else {
433433
switch_set_flag(ps, PSFLAG_READY);
@@ -474,7 +474,7 @@ static switch_status_t pocketsphinx_asr_get_results(switch_asr_handle_t *ah, cha
474474
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto Resuming\n");
475475
switch_set_flag(ps, PSFLAG_READY);
476476

477-
ps_start_utt(ps->ps, NULL);
477+
ps_start_utt(ps->ps);
478478
}
479479

480480
status = SWITCH_STATUS_SUCCESS;

0 commit comments

Comments
 (0)