#include <switch.h>
#include <pocketsphinx.h>
#include <err.h>
+#include <logmath.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_pocketsphinx_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_pocketsphinx_shutdown);
{
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);
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);