【问题标题】:How to automate voice reports for Praat如何为 Praat 自动化语音报告
【发布时间】:2022-05-12 16:28:30
【问题描述】:

有没有办法为 Praat 自动生成语音报告(在“查看和编辑”窗口中的“脉冲”下),因为我必须为 100 多个文件执行此操作。我需要整个文件的语音报告,并且最好在 Python 中执行此操作,因为我对此很熟悉。

【问题讨论】:

    标签: python report voice praat


    【解决方案1】:

    [免责声明:我是上述蛇佬腔图书馆的作者]

    根据您的实际目标,您似乎可以在声音编辑器菜单之外获得相同的“语音报告”输出(使用 View & Edit 打开):选择一个声音对象,分析其音高(选择 Sound,单击Analyse periodicity > To Pitch...) 和脉冲(选择 SoundPitch 对象,单击 To PointProcess (cc))。之后,选择所有 3 个对象(SoundPitchPointProcess)和操作 Voice report... 将允许您获得输出。

    这甚至适用于 Praat 的批处理版本(即,没有图形用户界面)。我不是编写 Praat 脚本的专家,但转换此工作流程似乎相当简单。

    至于您问题的另一部分:使用Parselmouth 库实际上可以使用 Python。这是我一直在创建的一个开源库,它允许以 Python 直观的方式从 Python 访问 Praat:

    import parselmouth
    sound = parselmouth.Sound("the_north_wind_and_the_sun.wav")
    pitch = sound.to_pitch()
    pulses = parselmouth.praat.call([sound, pitch], "To PointProcess (cc)")
    voice_report_str = parselmouth.praat.call([sound, pitch, pulses], "Voice report", 0.0, 0.0, 75, 600, 1.3, 1.6, 0.03, 0.45)
    

    对于某些事情,对象上存在 Python 方法,对于其他一些功能,您需要使用 parselmouth.praat.call,直到在库上完成更多工作。但它适用于 Python。

    但是,如果您只对语音报告的一部分感兴趣并希望将这些作为实际的数字变量(例如,因为您想对所有 100 个文件运行一些统计信息?),则可以访问所有这些内容独立于Voice report 功能。例如,仅获取某个声音文件的平均音高为 Python float

    mean_pitch = parselmouth.praat.call(pitch, "Get mean", 0.0, 0.0, "Hertz")
    

    【讨论】:

      【解决方案2】:

      语音报告是一个 editor 命令,因此在 Praat 的批处理实例中不可用。您将需要一个连接到 GUI 的 Praat 实例(否则您将收到 Cannot view or edit a Sound from batch 错误)。

      我不熟悉当前的 Python 特定库,所以我不知道是否有可以回避这个问题的库(我对此表示怀疑)。也就是说,您可以通过使用sendpraat 程序控制远程Praat 实例来避免这种情况,该实例又可以连接到GUI。见this answer for some more info on how that would work

      您可以在下面找到使用 Praat 本身的脚本语言的答案。这可以放入脚本中并作为系统命令(或使用sendpraat 发送)从您喜欢的任何语言中执行。

      form Voice report...
        positive F0_min 50
        positive F0_max 500
      endform
      
      sound = selected("Sound")
      end = Get total duration
      
      View & Edit
      editor: sound
        # Optimise settings for voice research 
        # and make sure things are turned on
        Pitch settings: f0_min, f0_max, 
          ... "Hertz", "cross-correlation", "automatic"
        info$ = Editor info
        if !extractNumber(info$, "Pulses show:")
          Show pulses
        endif
      
        Select: 0, end
        report$ = Voice report
      endeditor
      
      # Remove header from report
      # This leaves text that is parsable as YAML
      report$ = replace_regex$(report$, "-- Voice report .*\n", "", 1)
      report$ = replace_regex$(report$, "\nTime range .*\n", "", 1)
      report$ = replace_regex$(report$, "\s*From 0 to .*\n", "", 1)
      
      writeInfoLine: report$
      

      语音报告(与 Praat 的大多数输出​​一样)主要计划供人类使用,因此机器解析并非易事。我在我的回答中添加了一些额外的命令来预处理语音报告,以使输出至少可以被 YAML 解析,这可能会让你的情况变得更容易。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-09-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多