4

私は C# で書かれたプログラムと praat (音声学ソフトウェア) によって計算された値を持っています。Windows コンソール (cmd.exe) に結果を出力する praatcon.exe で実行されている praat スクリプトが既にあります。この結果を C# アプリケーションで使用できますか? どのように?

または、コマンド「sendsocket」などを使用して、結果を取得するためのより良い方法はありますか? これをどのように使用しますか?

編集:このコードでうまく機能します:

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

praatcon.exe で「-a」パラメータを使用することは非常に重要です。ここで説明を参照してください。

4

2 に答える 2

5

別の exe のコンソール出力をキャプチャする方法を次に示します。

これはすべて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();
于 2010-11-22T16:03:33.240 に答える
0

必要なデータを取得するために praat に接続するサービスが必要だと思います。

于 2010-11-22T16:03:09.040 に答える