Pregunta

Tengo un programa escrito en C # y los valores calculados por (software) fonética Praat. Ya tengo un script que se ejecuta con praat praatcon.exe que imprime los resultados en una consola de Windows (cmd.exe). ¿Puedo utilizar este resultado en mi aplicación C #? ¿Cómo?

O hay una mejor manera de obtener los resultados, por ejemplo, con el comando "sendsocket"? Cómo utilizar este?

Editar funciona muy bien con este código:

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();

Es muy importante utilizar el parámetro "-a" con praatcon.exe. Ver explicación aquí .

¿Fue útil?

Solución

Así es como para capturar la salida de la consola de otro exe.

Esto es todo en el espacio de nombres System.Diagnostics.

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();

Otros consejos

Creo que debe ser un servicio que le conecta a Praat para obtener los datos requeridos.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top