I am a Python and Lisp guy learning C++ and have come across a need to “concatenate” for lack of more precise terms, 3 C++ programs. I am unsure what would be the best way to do the following:
1) pocketsphinx takes input from the microphone, does real-time automatic speech recognition, outputs text to terminal, I want to send the output to the input of:
2) Chatscript, a chat program, which parses the incoming text (at the moment from keyboard) and generates a response which is sent to terminal, I want to send the output to the input of:
3) Festival, a text to speech that reads text input from the terminal and generates a voice output of that text.
I am exploring different ways to do this, as I understand it I could run pipes from pocketsphinx to Chatscript to festival, but some of what I’ve read leads me to believe this is a less than efficient way due to overhead. Also, regarding pipes, am I correct in thinking I would set 2 one way pipes (pid == 0) with the text outputs?
I think I could (once I learn a great deal more) combine all 3 programs (they are all open source) by essentially determining required libraries/files etc and “concatenating” the 3 void main()’s while changing the output statements?
Could someone offer some guidance/tutelage on this and opine as to which of these (or suggest other methods?) would be the most economical and effective?
regards, Richard
Watch for the cout or printf in the source, and add it to a buffer string variable, that will allow you to each time the buffer fills in, you can call the next program and execute it with the buffer gotten. If you dont need the “real time” processing, you can do what @zch pointed out, since if i recall (i might be wrong) pipes need the program to end before send the data to the next binary.