Question

I have a program written in C# and values calculated by praat (phonetics software). I already have a praat script running with praatcon.exe which prints the results on a Windows console (cmd.exe). Can I use this result in my C# application? How?

Or is there a better way to get the results, e.g. with the command "sendsocket"? How to use this one?

Edit: It works great with this code:

ProcessStartInfo si = new ProcessStartInfo();
si.FileName = "praatcon.exe"; //name of the handle program from sysinternals
//assumes that it is in the exe directory or in your path
//environment variable

//the following three lines are required to be able to read the output (StandardOutput)
//and hide the exe window. 
si.RedirectStandardOutput = true;
si.WindowStyle = ProcessWindowStyle.Hidden;
si.UseShellExecute = false;

si.Arguments = "-a example.praat filename.wav"; //you can specify whatever parameters praatcon.exe needs here; -a is mandatory!

//these 4 lines create a process object, start it, then read the output to
//a new string variable "s"
Process p = new Process();
p.StartInfo = si;
p.Start();
string s = p.StandardOutput.ReadToEnd();

It is VERY important to use the "-a" parameter with praatcon.exe. See explanation here.

Was it helpful?

Solution

Here's how to capture the console output of another exe.

This is all in the System.Diagnostics namespace.

ProcessStartInfo si = new ProcessStartInfo();
si.FileName = "praat.exe";     //name of the program
                                //assumes that its in the exe directory or in your path 
                                //environment variable

//the following three lines are required to be able to read the output (StandardOutput)
//and hide the exe window.
si.RedirectStandardOutput = true;
si.WindowStyle = ProcessWindowStyle.Hidden;
si.UseShellExecute = false;

si.Arguments = "InputArgsHere";     //You can specify whatever parameters praat.exe needs here

//these 4 lines create a process object, start it, then read the output to 
//a new string variable "s"
Process p = new Process();
p.StartInfo = si;
p.Start();
string s = p.StandardOutput.ReadToEnd();

OTHER TIPS

I think there should be a service which connects you to praat to get required data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top