如何从一个praatscript打开praat

时间:2017-06-28 14:06:26

标签: praat

我想允许一个praatscript打开praat对象线。这将允许我打开praat然后自动允许脚本将对象加载到对象窗口。

例如脚本

run_something.praat 1.wav 1.TextGrid 0.1 0.2

可以打开praat,然后在音频文件“1.wav”中打开编辑器0.1和0.2。这对我来说很容易

我不能事先打开祈祷来插入我需要的东西。

现在我的脚本看起来像这样:

form Info
    text Sound
    text Textgrid
    real Start
    real End
endform


if sound$ != "" and textgrid$ != ""
     Read from file: sound$
     Read Strings from raw text file: textgrid$
     @read_lab()

selectObject: 1, 3
View & Edit
editor = 3
editor: editor
Select: start , end
Zoom to selection
endeditor

endif

当然它会告诉我View和Edit不起作用,因为GUI没有打开。我不能使用环境,因为它必须在Windows和Linux上工作

2 个答案:

答案 0 :(得分:2)

您可以使用 world_region: { required:true, valueNotEquals: "default" } 选项启动Praat以打开您想要的文件。这将以GUI模式启动Praat,并打开指定的文件(和/或脚本):

--open

但是如果你想以编程方式向Praat实例发出命令(=没有你点击任何东西),你可能不得不使用sendpraat,这应该可以在Praat运行的所有平台上使用。

请注意,该页面中的编译说明至少有点过时了:我可以在我的机器上编译

praat --open sound.wav annotation.TextGrid script.praat

使用sendpraat,您必须根据自己的喜好启动Praat的GUI实例,然后在单独的语句中发送脚本的执行:

gcc -std=gnu99 -o sendpraat -DSTAND_ALONE -DUNIX \
  `pkg-config --cflags gtk+-2.0 glib-2.0` \
  sendpraat.c \
  `pkg-config --libs   gtk+-2.0 glib-2.0`
Praat手册中提供了

Instructions for using sendpraat。第一个参数是以秒为单位的超时(=如果当时未完成操作则死亡),然后是程序名称,然后是顺序运行的命令列表。

据我所知,没有简单的方法可以运行单个脚本,只需一步打开Praat 的GUI版本,使该实例的Praat执行命令。但我可能错了。

答案 1 :(得分:0)

对于那些在sendpraat中苦苦挣扎的人:

尝试:

sendpraat praat 'execute "pathtoyourscript"'