【问题标题】:Praat Script :: Printing Frequency OutputPraat Script :: 打印频率输出
【发布时间】:2015-01-20 08:16:26
【问题描述】:

我有兴趣使用 Praat 对数百个 .wav 音频样本(每个大约 10 秒)进行批量分析。 Praat 是否可以分析目录中的所有文件,为每个文件“获取音调”(或获取语音报告),并将所有这些打印到 .csv 或 .txt 文件?

我尝试过修改一些在线可用的脚本,但由于对编程知识很少,我发现这很困难。如果有人提供一些代码让我开始,我将不胜感激!

【问题讨论】:

    标签: nlp linguistics praat


    【解决方案1】:

    Praat 处理目录列表的方式是使用Strings 对象。您可以生成带有文件名或目录名的Strings 对象,然后遍历这些对象以打开每个单独的文件并以您喜欢的方式处理它。

    至于输出,您可以手动输出到文本文件,也可以将分析结果保存在 Table 对象中,然后可以根据需要保存为 csvtxt .您可以在 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, output
    

    【讨论】:

    • 这正是我想要的,我可以从这里轻松调整球场地板和天花板。感谢您的帮助!
    猜你喜欢
    • 2021-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-17
    • 2012-05-20
    • 2017-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多