Pergunta

Eu tenho um programa escrito em C# e valores calculados pelo Praat (Software Phonetics). Eu já tenho um script Praat em execução com Praatcon.exe que imprime os resultados em um console do Windows (cmd.exe). Posso usar esse resultado no meu aplicativo C#? Como?

Ou existe uma maneira melhor de obter os resultados, por exemplo, com o comando "sendsocket"? Como usar este?

Editar: Funciona muito bem com 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();

É muito importante usar o parâmetro "-a" com praatcon.exe. Veja explicação aqui.

Foi útil?

Solução

Veja como capturar a saída do console de outro exe.

Isso é tudo no System.Diagnostics espaço para nome.

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

Outras dicas

Eu acho que deve haver um serviço que o conecta a Praat para obter os dados necessários.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top