mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-18 17:41:53 +00:00
confidence scores are 0 best to 100 worst
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8989 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
04d1d7afb1
commit
dd01445d2a
@ -33,6 +33,7 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <pocketsphinx.h>
|
#include <pocketsphinx.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <logmath.h>
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_pocketsphinx_load);
|
SWITCH_MODULE_LOAD_FUNCTION(mod_pocketsphinx_load);
|
||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_pocketsphinx_shutdown);
|
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;
|
pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
|
||||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
int32_t score;
|
int32_t conf, lconf;
|
||||||
|
|
||||||
if (switch_test_flag(ps, PSFLAG_BARGE)) {
|
if (switch_test_flag(ps, PSFLAG_BARGE)) {
|
||||||
switch_clear_flag_locked(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_mutex_lock(ps->flag_mutex);
|
||||||
switch_clear_flag(ps, PSFLAG_HAS_TEXT);
|
switch_clear_flag(ps, PSFLAG_HAS_TEXT);
|
||||||
|
|
||||||
score = ps_get_prob(ps->ps, &ps->uttid);
|
conf = ps_get_prob(ps->ps, &ps->uttid);
|
||||||
ps->confidence = score - score - score / 1000;
|
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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Recognized: %s, Score: %d\n", ps->hyp, ps->confidence);
|
||||||
switch_mutex_unlock(ps->flag_mutex);
|
switch_mutex_unlock(ps->flag_mutex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user