SpeechBackground() over FastAGI

I am trying to get speech recognition working via LumenVox. I have tested a simple dial plan application, and it detects voice just fine.

However, when I try to apply the code to a FastAGI script, SpeechBackground() plays the voice prompt, but just sits there forever waiting for voice (which it never detects). The only way to get it to continue is to send DTMF tones, which it happily accepts and then moves on to the next steps in the script.

I’m trying to figure out how this could work as a dialplan, but not in a FastAGI script. I’m starting to wonder if you can even do voice recognition via a FastAGI script.

Some version information:
Asterisk: 1.6
LumenVox: 9
I am using the Digium connector bridge.

Here is a snippet of the relevant code in the script:

[code]$AGI->answer();
my $retval;
$AGI->exec(“SpeechCreate”);
$AGI->exec(“SpeechActivateGrammar”, “yesno”);

my $vpf = "enter-cust-id";
$AGI->exec("SpeechBackground", $vpf, "5");
	
# get the results
my $score = $AGI->get_variable('SPEECH_SCORE(0)');
my $text = $AGI->get_variable('SPEECH_TEXT(0)');
  	
$tscore = $score['data'];
$AGI->noop("User said: ".$text['data']." (score: ".$score['data']);
  		
$AGI->exec("SpeechDeactivateGrammar", "yesno");[/code]

I am loading the grammars via the config file (as calling the agi function to load them simply did not work).

Any idea how this would work in a dialplan, but not in a FastAGI script? Am I missing something obvious?