[Freeswitch-users] Stumped on speech recognition

Greg Thoen gregt at cgicommunications.com
Wed Jul 29 13:28:32 PDT 2009


Still stumped on trying to write a streamlined pocketsphinx speech  
recognition. I went through SpeechTools.jm and I think I pulled out  
the necessary pieces, but the speech event is not being fired. I get  
dtmf events if I push a key, but not speech. I must be missing a  
piece, but I have stared at SpeechTools.jm until I can't see straight.  
Here is my code:

    function onInput(s, type, inputEvent, _this) {
    		console_log("debug", "EVENT:" + type + "\n");	
	}

     session.answer();


	var blankobj = new Object();
	var rv;
	var hit;
	var dup;
	var grammar_name="pizza_yesno";
	var collected_index=0;
	var req=1;
	var obj_path="result";
	var halt=true;
	var min_score=20;
	var confirm_score=10;
	
	console_log('INFO', "Setting grammar\n");
	session.execute("detect_speech", "nogrammar " + grammar_name);
	session.execute("detect_speech", "pocketsphinx " + grammar_name);
	session.execute("detect_speech", "resume");
	console_log('INFO', "entering while loop\n");
	session.streamFile( "audiofile.wav", onInput, "blankobj") ;
	
	while(session.ready() && collected_index < req) {
		var x;
		
		if (!rv) {
			rv = session.collectInput(onInput, "blankobj", 500);
			if (rv && !rv[0]) {
				rv = false;
			}				
		}
		if (!rv) {
			session.execute("detect_speech", "resume");
			rv = session.collectInput(onInput, "blankobj", 5000);
		}
		hit = false;
		if (rv) {
			var items = rv;
			rv = undefined;
			for (y = 0; y < items.length; y++) {
				console_log("debug", "---- "+items[y]+"\n");
			}
		}
	
		if (!rv) {
			rv = session.collectInput(onInput, "blankobj", 1000);
		}
	
	}

////////////////////////////////////////////
////////////////////////////////////////////

And here is some of the output from the console:

2009-07-29 16:10:09 [INFO] stest-examp.js:1 console_log() Setting  
grammar
EXECUTE sofia/internal/+*@199.173.94.88:5060 detect_speech(nogrammar  
pizza_yesno)
EXECUTE sofia/internal/+*@199.173.94.88:5060  
detect_speech(pocketsphinx pizza_yesno)
EXECUTE sofia/internal/+*@199.173.94.88:5060 detect_speech(resume)
2009-07-29 16:10:09 [INFO] stest-examp.js:1 console_log() entering  
while loop
2009-07-29 16:10:09 [DEBUG] switch_ivr_play_say.c:1084  
switch_ivr_play_file() Codec Activated L16 at 8000hz 1 channels 20ms
2009-07-29 16:10:09 [DEBUG] switch_core_io.c:649  
switch_core_session_write_frame() sofia/internal/+*@199.173.94.88:5060  
receive message [TRANSCODING_NECESSARY]
2009-07-29 16:10:09 [DEBUG] sofia.c:2979 sofia_handle_sip_i_state()  
Channel sofia/internal/+*@199.173.94.88:5060 entering state [ready][200]
2009-07-29 16:10:12 [DEBUG] switch_ivr_play_say.c:1379  
switch_ivr_play_file() done playing file
EXECUTE sofia/internal/+*@199.173.94.88:5060 detect_speech(resume)
2009-07-29 16:10:16 [DEBUG] switch_rtp.c:1876  
switch_rtp_dequeue_dtmf() RTP RECV DTMF 5:2440
2009-07-29 16:10:16 [DEBUG] stest-examp.js:45 console_log() EVENT:dtmf
EXECUTE sofia/internal/+*@199.173.94.88:5060 detect_speech(resume)
EXECUTE sofia/internal/+*@199.173.94.88:5060 detect_speech(resume)
2009-07-29 16:10:27 [DEBUG] switch_rtp.c:1876  
switch_rtp_dequeue_dtmf() RTP RECV DTMF 5:2320
2009-07-29 16:10:27 [DEBUG] stest-examp.js:45 console_log() EVENT:dtmf


Greg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20090729/59a117ad/attachment-0002.html 


More information about the FreeSWITCH-users mailing list