[Asterisk-Users] Sphinx

Mauricio Nuñez mauricio at chile.com
Fri Dec 19 08:29:17 MST 2003


Hi,

I'm, doing the same, but with a php agi, and invoking a modified script to use 
sphinx:

/usr/local/bin/decoder2
#!/bin/sh
BASE=6403
S2BATCH=sphinx2-continuous
HMM=/usr/local/share/sphinx2/model/hmm/6k
TASK=/usr/local/share/sphinx2/model/lm/${BASE}
CTLFILE=/usr/local/share/sphinx2/model/lm/${BASE}/${BASE}.ctl
#BASE=$1
$S2BATCH -nbest 1 -nbestdir /tmp -verbose 0 -adcin TRUE -adcext wav -ctlfn 
${CTLFILE} -ctloffset 0 -ctlcount 100000000 -datadir ${TASK} -samp 8000 
-agcmax TRUE -langwt 6.5 -fwdflatlw 8.5 -rescorelw 9.5 -ugwt 0.5 -fillpen 
1e-10 -silpen 0.005 -inspen 0.65 -top 1 -topsenfrm 3 -topsenthresh -70000 
-beam 2e-06 -npbeam 2e-06 -lpbeam 2e-05 -lponlybeam 0.0005 -nwbeam 0.0005 
-fwdflat FALSE -fwdflatbeam 1e-08 -fwdflatnwbeam 0.0003 -bestpath TRUE 
-kbdumpdir ${TASK} -lmfn ${TASK}/${BASE}.lm -dictfn ${TASK}/${BASE}.dic 
-noisedict ${HMM}/noisedict -phnfn ${HMM}/phone -mapfn ${HMM}/map -hmmdir 
${HMM} -hmmdirlist ${HMM} -8bsen TRUE -sendumpfn ${HMM}/sendump -cbdir ${HMM}


My php-test.agi:

function __write__($line)
{
        print $line."\n";
}

function __read__()
{
        global $in;
        $input=str_replace("\n","",fgets($in,4096));
        return $input;
}

function festival($texto)
{
        __write__("EXEC FESTIVAL \"$texto\"");
        return __read__();
}

function record($filename, $digits)
{
        __write__("RECORD FILE $filename wav $digits 15000 BEEP");
        return __read__();
}

$in=fopen("php://stdin","r");
festival("ingrese su mensaje");
record("mensaje","#");
$comando="/usr/local/bin/decoder2";                
$value=file("/tmp/mensaje.hyp");
$value=$value[0];
$numero=trim(substr($value,strpos($value,">")+1));
if($numero!="")
	festival("usted a seleccionado el numero $numero");
exec($comando);









El Jueves 18 Diciembre 2003 17:40, Kevin Bockman escribió:
> Hi. I just started trying to play with Sphinx.  I followed their site as
> far as running sphinx-server.  It is listening on the default port.  I
> copied sphinx2-simple to another file and changed sphinx2-continuous to
> sphinx2-server.
>
> So, I ran eagi-sphinx-test under asterisk.  What exactly is it supposted to
> do?  Here's what I get:
>
> debian:~# sphinx2-simple2
>
> sphinx2-simple:
>   Demo CMU Sphinx2 decoder called with command line arguments.
>
> <executing /usr/local/bin/sphinx2-server, please wait>
> ioctl(SETDUPLEX) failed: Invalid argument
> Calibrating background noise level...done
> server.c(443): Bad or missing port# argument, using 7027
> srvcore.c(382): Listening at port 7027
> srvcore.c(409): Connected >>>>>>>> 192.168.1.99 at Thu Dec 18 15:24:19 2003
>
> Hit <CR> to start listening, q<CR> to quit client connection
>
>     -- Executing Answer("SIP/test-ff55", "") in new stack
>     -- Executing EAGI("SIP/test-ff55", "eagi-sphinx-test") in new stack
>     -- Launched AGI Script /var/lib/asterisk/agi-bin/eagi-sphinx-test
> Environment: 'agi_request' is 'eagi-sphinx-test'
> Environment: 'agi_channel' is 'SIP/test-ff55'
> Environment: 'agi_language' is 'en'
> Environment: 'agi_type' is 'sip'
> Environment: 'agi_uniqueid' is '1071786651.21'
> Environment: 'agi_callerid' is '"blah" <1234>'
> Environment: 'agi_dnid' is 'unknown'
> Environment: 'agi_rdnis' is 'unknown'
> Environment: 'agi_context' is 'default'
> Environment: 'agi_extension' is '911'
> Environment: 'agi_priority' is '2'
> Environment: 'agi_enhanced' is '1.0'
> Environment: 'agi_accountcode' is ''
> Ooh, got a response from Asterisk: '200 result=0 endpos=46560'
> 1. Result is '200 result=0 endpos=46560'
> Ooh, got a response from Asterisk: '200 result=0 endpos=30720'
> 2. Result is '200 result=0 endpos=30720'
>     -- Playing 'digits/20' (language 'en')
>     -- Playing 'digits/3' (language 'en')
>     -- Playing 'digits/million' (language 'en')
>     -- Playing 'digits/4' (language 'en')
>     -- Playing 'digits/hundred' (language 'en')
>     -- Playing 'digits/50' (language 'en')
>     -- Playing 'digits/2' (language 'en')
>     -- Playing 'digits/thousand' (language 'en')
>     -- Playing 'digits/3' (language 'en')
>     -- Playing 'digits/hundred' (language 'en')
>     -- Playing 'digits/40' (language 'en')
>     -- Playing 'digits/5' (language 'en')
> Ooh, got a response from Asterisk: '200 result=0'
> 3. Result is '200 result=0'
>     -- Playing 'demo-enterkeywords' (language 'en')
> Ooh, got a response from Asterisk: '200 result= (timeout)'
> 4. Result is '200 result= (timeout)'
> Ooh, got a response from Asterisk: '200 result=0 endpos=9440'
> 5. Result is '200 result=0 endpos=9440'
>     -- AGI Script eagi-sphinx-test completed, returning 0
>
> Is the endpos number something significant?  What is it referring to?
>
> Am I doing this right?
>
> Does anyone have any other EAGI Sphinx examples?  Maybe something that asks
> for you to say a word and it puts it into text?
>
> Sorry, this is pretty neat but there's hardly any information on it.  I've
> tried searching the lists and I see a couple people that have used it but
> that's all.
>
> Thanks,
>
> Kevin B.
>
> _____________________________________________________________
> Are you a Techie? Get Your Free Tech Email Address Now! Visit
> http://www.TechEmail.com _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users




More information about the asterisk-users mailing list