[Tutor] receiving string from shell
Dave Angel
d at davea.name
Fri Aug 10 04:44:04 CEST 2012
On 08/09/2012 10:24 PM, richard kappler wrote:
> The summer of intensive learning continues. Working on subprocess today.
> I figured out how to send data out, for example to my festival tts engine:
>
> [code]response = k.respond(input, "richard")
> festivalCmd = '(SayText "%s")' % response
> subprocess.Popen(['/usr/bin/festival', '-b', festivalCmd])[/code]
>
> and that works fine. Now I'm trying to go the other way, starting up my
> speech recognition engine. The trivial bit is starting it up:
>
> [code]subprocess.Popen(['pocketsphinx_continuous -logfn /dev/null'])[/code]
>
> I'm at a loss, however, as to how to retrieve the text that pocketsphinx
> generates from speech into my python program. In other words, the above
> starts the speech rec engine, and when I say something the recognizer grabs
> it and prints what I said out as text on the command line. But I'm
> struggling how to get that text string into my Python program. Should I be
> looking at pipes, communicate(), Popen.returncode(), something completely
> different :wink: ?
>
> It's probably obvious but I've been working on face recognition all day and
> now have turned to this, so perhaps I'm a bit burned out. Any guidance
> would be greatly appreciated so I can get a fresh start in the morning.
>
> And now that I think about it, it's even more complex. The speech rec
> program would be started when my python program starts and keep running. So
> the python program would have to continuously monitor the terminal for text
> output to import to python, but would have to ignore the "Ready" or
> "Listening" prompt within pocketshpinx that shows while waiting for speech
> input.
>
> And I thought this would be easy. Back to the 2.7 docs.
>
> Perhaps a few hours of sleep first, Richard
>
>
Your first question should be to find out the behavior of this speech
rec. engine application, assuming you don't have the option of changing
it. So try running it from bash, redirecting stdout to a file. Do a
tail -f on that file and see if that's exactly what you'd like your
python app to see. If it's not, check to see if there are cmdline
options for the engine that change its behavior. It's possible that it
sends the prompts to stderr. Anyway, you can investigate that way,
before trying to get a pipe working from Python.
--
DaveA
More information about the Tutor
mailing list