]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
WIP mod_pocketsphinx pcre2_2
authorAndrey Volk <andywolk@gmail.com>
Sat, 12 Jul 2025 22:38:29 +0000 (01:38 +0300)
committerAndrey Volk <andywolk@gmail.com>
Sat, 12 Jul 2025 22:49:28 +0000 (01:49 +0300)
configure.ac
debian/control-modules
src/mod/asr_tts/mod_pocketsphinx/Makefile.am
src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c

index a0967774bc06ce49bb4695314c2541d0d7b6f69f..c0b8a756dc5a988d3b6df8d5276f6b5a31f55bca 100644 (file)
@@ -1563,6 +1563,14 @@ PKG_CHECK_MODULES([AMQP], [librabbitmq >= 0.5.2], [
        AM_CONDITIONAL([HAVE_AMQP], [false])
    ])
 
+PKG_CHECK_MODULES([SPHINXBASE], [sphinxbase >= 5],[
+  AM_CONDITIONAL([HAVE_SPHINXBASE],[true])],[
+  AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SPHINXBASE],[false])])
+
+PKG_CHECK_MODULES([POCKETSPHINX], [pocketsphinx >= 5],[
+  AM_CONDITIONAL([HAVE_POCKETSPHINX],[true])],[
+  AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_POCKETSPHINX],[false])])
+
 PKG_CHECK_MODULES([H2O], [libh2o-evloop >= 0.11.0],[
   AM_CONDITIONAL([HAVE_H2O],[true])],[
   AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_H2O],[false])])
index 469d7c7181a246021e2be199842e6fba6ec621b7..0136d01addf0a66f3b5329abf2027acc880ee12d 100755 (executable)
@@ -232,6 +232,7 @@ Build-Depends: libflite-dev | flite1-dev
 Module: asr_tts/mod_pocketsphinx
 Description: mod_pocketsphinx
  Adds mod_pocketsphinx.
+Build-Depends: libsphinxbase-dev, libpocketsphinx-dev
 
 Module: asr_tts/mod_tts_commandline
 Description: mod_tts_commandline
index a3968732509ba82ca928a72b61a329e5c1d2244a..d0dc6f99cfd26d2604ba085df4e8311f65e2c69f 100644 (file)
@@ -16,11 +16,16 @@ SPHINXMODEL=communicator_semi_6000_20080321
 
 mod_LTLIBRARIES = mod_pocketsphinx.la
 mod_pocketsphinx_la_SOURCES  = mod_pocketsphinx.c
+mod_pocketsphinx_la_LDFLAGS  = -avoid-version -module -no-undefined -shared
+if HAVE_POCKETSPHINX
+mod_pocketsphinx_la_CFLAGS   = $(AM_CFLAGS) $(SPHINXBASE_CFLAGS) $(POCKETSPHINX_CFLAGS)
+mod_pocketsphinx_la_LIBADD   = $(switch_builddir)/libfreeswitch.la $(POCKETSPHINX_LDFLAGS) $(SPHINXBASE_LDFLAGS)
+else
 mod_pocketsphinx_la_CFLAGS   = $(AM_CFLAGS) -I$(SPHINXBASE_DIR)/include -I$(POCKETSPHINX_DIR)/include
 mod_pocketsphinx_la_LIBADD   = $(switch_builddir)/libfreeswitch.la $(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
-mod_pocketsphinx_la_LDFLAGS  = -avoid-version -module -no-undefined -shared
 
 BUILT_SOURCES=$(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
+endif
 
 $(SPHINXBASE_DIR):
        $(GETLIB) $(SPHINXBASE).tar.gz
@@ -66,5 +71,8 @@ $(DESTDIR)$(grammardir)/model/communicator:
 dictionary:
        @install -m0644 $(POCKETSPHINX_DIR)/model/lm/en_US/cmu07a.dic $(DESTDIR)$(grammardir)/default.dic
 
+if HAVE_POCKETSPHINX
+install-data-local: $(POCKETSPHINX_DIR) $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary
+else
 install-data-local: $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary
-
+endif
index f7cef9957309ac6e8181a98a891ccae7377bfa95..5a988f90983646faf9b0410bdee26d47e741044b 100644 (file)
@@ -203,7 +203,7 @@ static switch_status_t pocketsphinx_asr_load_grammar(switch_asr_handle_t *ah, co
        }
        switch_mutex_unlock(ps->flag_mutex);
 
-       ps_start_utt(ps->ps, NULL);
+       ps_start_utt(ps->ps);
        ps->silence_time = switch_micro_time_now();
        switch_clear_flag(ps, PSFLAG_START_OF_SPEECH);
        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
                        char const *hyp;
 
                        switch_mutex_lock(ps->flag_mutex);
-                       if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
+                       if ((hyp = ps_get_hyp(ps->ps, &ps->score))) {
                                if (!zstr(hyp)) {
                                        ps_end_utt(ps->ps);
                                        switch_clear_flag(ps, PSFLAG_READY);
-                                       if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
+                                       if ((hyp = ps_get_hyp(ps->ps, &ps->score))) {
                                                if (zstr(hyp)) {
                                                        if (!switch_test_flag(ps, PSFLAG_SPEECH_TIMEOUT)) {
                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost the text, never mind....\n");
-                                                               ps_start_utt(ps->ps, NULL);
+                                                               ps_start_utt(ps->ps);
                                                                switch_set_flag(ps, PSFLAG_READY);
                                                        }
                                                } else {
                                                        /* get match and confidence */
                                                        int32_t conf;
 
-                                                       conf = ps_get_prob(ps->ps, &ps->uttid);
+                                                       conf = ps_get_prob(ps->ps);
 
                                                        ps->confidence = (conf + 20000) / 200;
 
@@ -427,7 +427,7 @@ static switch_status_t pocketsphinx_asr_resume(switch_asr_handle_t *ah)
        if (!switch_test_flag(ps, PSFLAG_READY)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Manually Resuming\n");
 
-               if (ps_start_utt(ps->ps, NULL)) {
+               if (ps_start_utt(ps->ps)) {
                        status = SWITCH_STATUS_GENERR;
                } else {
                        switch_set_flag(ps, PSFLAG_READY);
@@ -474,7 +474,7 @@ static switch_status_t pocketsphinx_asr_get_results(switch_asr_handle_t *ah, cha
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto Resuming\n");
                        switch_set_flag(ps, PSFLAG_READY);
 
-                       ps_start_utt(ps->ps, NULL);
+                       ps_start_utt(ps->ps);
                }
 
                status = SWITCH_STATUS_SUCCESS;