From dd01445d2a0afeb8a80a59f1fc9012fc63586896 Mon Sep 17 00:00:00 2001 From: Brian West Date: Thu, 10 Jul 2008 19:32:43 +0000 Subject: [PATCH] confidence scores are 0 best to 100 worst git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8989 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c index 726e97f322..897806642c 100644 --- a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c +++ b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c @@ -33,6 +33,7 @@ #include #include #include +#include SWITCH_MODULE_LOAD_FUNCTION(mod_pocketsphinx_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_pocketsphinx_shutdown); @@ -354,7 +355,7 @@ static switch_status_t pocketsphinx_asr_get_results(switch_asr_handle_t *ah, cha { pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info; switch_status_t status = SWITCH_STATUS_SUCCESS; - int32_t score; + int32_t conf, lconf; if (switch_test_flag(ps, PSFLAG_BARGE)) { switch_clear_flag_locked(ps, PSFLAG_BARGE); @@ -365,8 +366,13 @@ static switch_status_t pocketsphinx_asr_get_results(switch_asr_handle_t *ah, cha switch_mutex_lock(ps->flag_mutex); switch_clear_flag(ps, PSFLAG_HAS_TEXT); - score = ps_get_prob(ps->ps, &ps->uttid); - ps->confidence = score - score - score / 1000; + conf = ps_get_prob(ps->ps, &ps->uttid); + lconf = logmath_log_to_ln(ps_get_logmath(ps->ps), conf); + ps->confidence = lconf - lconf - lconf; + /* 0(confident) to 100(not confident) score */ + if (ps->confidence > 100) { + ps->confidence = 100; + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Recognized: %s, Score: %d\n", ps->hyp, ps->confidence); switch_mutex_unlock(ps->flag_mutex);