From 80ddc15155df7dd12a4f53c8875bf551acfa1aff Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 29 Jul 2008 01:25:29 +0000 Subject: [PATCH] lets flip it around. 0 bad 100 good in pocketsphinx now. Scoring in the lib was changed so I had to do this change git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9194 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- scripts/js_modules/SpeechTools.jm | 41 ++++++------------- scripts/ps_pizza.js | 6 +-- .../mod_pocketsphinx/mod_pocketsphinx.c | 11 ++--- 3 files changed, 19 insertions(+), 39 deletions(-) diff --git a/scripts/js_modules/SpeechTools.jm b/scripts/js_modules/SpeechTools.jm index e1c6995a89..b371bf3e9e 100644 --- a/scripts/js_modules/SpeechTools.jm +++ b/scripts/js_modules/SpeechTools.jm @@ -181,43 +181,26 @@ function SpeechDetect(session, mod, ip) { console_log("debug", "----Hit score " + interp.@score + "/" + grammar_object.min_score + "/" + grammar_object.confirm_score + "\n"); } - if (_this.mod == "pocketsphinx") { - /* pocketsphinx scores 0 best to 100 worst. */ - if (interp.@score >= grammar_object.min_score) { - if (interp.@score >= grammar_object.confirm_score) { - rv.push("_confirm_"); - } + if (interp.@score >= grammar_object.min_score) { + if (interp.@score < grammar_object.confirm_score) { + rv.push("_confirm_"); + } - eval("xo = interp." + grammar_object.obj_path + ";"); - for (x = 0; x < xo.length(); x++) { - rv.push(xo[x]); - console_log("info", "----" +xo[x] + "\n"); - } - } else { - rv.push("_no_idea_"); + eval("xo = interp." + grammar_object.obj_path + ";"); + for (x = 0; x < xo.length(); x++) { + rv.push(xo[x]); + console_log("info", "----" +xo[x] + "\n"); } } else { - if (interp.@score >= grammar_object.min_score) { - if (interp.@score < grammar_object.confirm_score) { - rv.push("_confirm_"); - } - - eval("xo = interp." + grammar_object.obj_path + ";"); - for (x = 0; x < xo.length(); x++) { - rv.push(xo[x]); - console_log("info", "----" +xo[x] + "\n"); - } - } else { - rv.push("_no_idea_"); - } + rv.push("_no_idea_"); } - delete interp; - return rv; } + delete interp; + return rv; } } -} +} /* Constructor for SpeechObtainer Class (Class to collect data from a SpeechDetect Class) */ function SpeechObtainer(asr, req, wait_time) { diff --git a/scripts/ps_pizza.js b/scripts/ps_pizza.js index 75ea2ea58b..8a251d4b53 100644 --- a/scripts/ps_pizza.js +++ b/scripts/ps_pizza.js @@ -33,8 +33,8 @@ include("js_modules/SpeechTools.jm"); function on_dtmf(a, b, c) {} -var dft_min = 0; -var dft_confirm = 78; +var dft_min = 40; +var dft_confirm = 70; /***************** Initialize The Speech Detector *****************/ var asr = new SpeechDetect(session, "pocketsphinx"); @@ -142,7 +142,7 @@ pizza.arsoObtainer.addItemAlias("^remove\\s*", "rem_topping"); /***************** Yes? No? Maybe So? *****************/ pizza.yesnoObtainer = new SpeechObtainer(asr, 1, 5000); -pizza.yesnoObtainer.setGrammar("pizza_yesno", "", "result", dft_min, 40, true); +pizza.yesnoObtainer.setGrammar("pizza_yesno", "", "result", dft_min, 20, true); pizza.yesnoObtainer.setBadSound("GP-NI"); pizza.yesnoObtainer.addItemAlias("^yes,^correct", "yes"); pizza.yesnoObtainer.addItemAlias("^no", "no"); diff --git a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c index f30cce767b..244132a7a1 100644 --- a/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c +++ b/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c @@ -365,7 +365,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 conf, lconf; + int32_t conf; if (switch_test_flag(ps, PSFLAG_BARGE)) { switch_clear_flag_locked(ps, PSFLAG_BARGE); @@ -375,14 +375,11 @@ static switch_status_t pocketsphinx_asr_get_results(switch_asr_handle_t *ah, cha if (switch_test_flag(ps, PSFLAG_HAS_TEXT)) { switch_mutex_lock(ps->flag_mutex); switch_clear_flag(ps, PSFLAG_HAS_TEXT); - conf = ps_get_prob(ps->ps, &ps->uttid); - lconf = (int32_t)logmath_log_to_ln(ps_get_logmath(ps->ps), conf); - ps->confidence = lconf - lconf - lconf; - if (ps->confidence > 1000) { - ps->confidence = 1000; - } else if (ps->confidence < 0) { + ps->confidence = (conf + 20000) / 200; + + if (ps->confidence < 0) { ps->confidence = 0; }