我对使用Praat对数百个.wav音频样本(每个样本大约10秒)进行批量分析很感兴趣。普拉特有没有可能分析一个目录中的所有文件,为每个文件“获取音调”(或获取语音报告),并将所有这些文件打印到.csv或.txt文件中?
我试着修改了一些在线可用的脚本,但由于几乎没有编程知识,我发现这很困难。如果有人提供一些代码让我入门,我将非常感激!
发布于 2015-01-21 21:56:47
Praat处理目录列表的方式是使用Strings对象。您可以生成一个带有文件名或目录名的Strings对象,然后循环遍历这些名称,以打开每个单独的文件并以您喜欢的任何方式处理它。
至于输出,您可以手动输出到文本文件,或者可以将分析结果保存在Table对象中,然后可以根据需要将其保存为csv或txt。您可以在my related answer中看到这一点。
在本例中,您需要的内容如下所示
form Process files...
sentence Path /path/to/your/files
endform
# Optional: make sure the path has a trailing slash
path$ = if right$(path$) = "/" then path$ else path$ + "/" fi
output = Create Table with column names: "output", 0,
... "file mean_pitch"
files = Create Strings as file list: "files", path$ + "*wav"
total_files = Get number of strings
for i to total_files
selectObject: files
filename$ = Get string: i
sound = Read from file: path$ + filename$
# Run whatever kind of analysis you want here
# For example, get the mean pitch for each file
pitch = To Pitch: 0, 75, 600
mean = Get mean: 0, 0, "Hertz"
selectObject: output
Append row
row = Get number of rows
Set string value: row, "file", filename$
Set numeric value: row, "mean_pitch", mean
removeObject: sound, pitch
endfor
selectObject: output
Save as comma-separated file: path$ + "output.csv"
removeObject: files, outputhttps://stackoverflow.com/questions/28040481
复制相似问题