首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用C#程序从praat中获取值

使用C#程序从praat中获取值
EN

Stack Overflow用户
提问于 2010-11-22 15:59:18
回答 2查看 1.2K关注 0票数 4

我有一个用C#编写的程序和由praat (语音学软件)计算的值。我已经有一个与praatcon.exe一起运行的praat脚本,它在Windows (cmd.exe)上打印结果。我可以在我的C#应用程序中使用这个结果吗?多么?

或者是否有更好的方法来获得结果,例如使用命令“send套接字”?这个怎么用?

编辑:--它使用以下代码工作得很好:

代码语言:javascript
复制
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();

在-a中使用“praatcon.exe”参数是非常重要的。参见解释这里

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-11-22 16:03:33

下面是如何捕获另一个exe的控制台输出。

这都在System.Diagnostics命名空间中。

代码语言:javascript
复制
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();
票数 5
EN

Stack Overflow用户

发布于 2010-11-22 16:03:09

我认为应该有一个服务,连接您与praat,以获得所需的数据。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4247376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档