首页 > 解决方案 > Parselmouth 批量全语音报告

问题描述

我想知道是否有一种方法可以批量处理音频文件并使用 parselmouth 或其他 pythonic 实现的 praat 生成完整的语音报告。到目前为止,我只能获得中间音高,但我需要能够计算出脉冲和周期的总数、声音中断的程度和微光。如果使用 python 无法做到这一点,是否可以使用 praat 脚本? praat 生成的语音报告

标签: reportbatch-processingvoicepraat

解决方案


[免责声明:我是提到的 Parselmouth 图书馆的作者]

这个问题是在 Parselmouth 的Gitter 聊天框中提出并解决的,但为了将来参考,这是我在那里建议的解决方案:

之前在 StackOverflow 上提出了一个类似的问题:How toautomated voice reports for Praat,解释了如何在没有 Praat 'View & Edit' 窗口的情况下获取语音报告(即,使用SoundPitchPointProcess对象)。

所以首先你得到这三个对象,Sound sound、Pitch pitch 和 PointProcess 脉冲,可能会改变你想要不同的参数:

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)")

之后,您可以通过不同的方式查询要提取的不同数量。例如,PointProcess 中的脉冲数可以通过以下方式提取:

n_pulses = parselmouth.praat.call(pulses, "Get number of points")

和其他人:

n_periods = parselmouth.praat.call(pulses, "Get number of periods", 0.0, 0.0, 0.0001, 0.02, 1.3)
shimmer_local = parselmouth.praat.call([sound, pulses], "Get shimmer (local)...", 0.0, 0.0, 0.0001, 0.02, 1.3, 1.6)

获得语音中断的程度在某种程度上更难。不知道为什么普拉特没有命令得到这个。

在 Python 中获得此功能的一种快速方法是:

max_voiced_period = 0.02  # This is the "longest period" parameter in some of the other queries
periods = [parselmouth.praat.call(pulses, "Get time from index", i+1) -
           parselmouth.praat.call(pulses, "Get time from index", i)
           for i in range(1, n_pulses)]

degree_of_voice_breaks = sum(如果 period > max_voiced_period,则 period for period in period)/ sound.duration

您还可以在“语音报告”的输出字符串中找到报告此百分比的行;见https://stackoverflow.com/a/51657044/2043407

如果您查看 Praat 用户界面,确实没有“获取中位数”按钮,这就是该行不起作用的原因。但是,Praat 中有一个“获取分位数”命令所以我建议

parselmouth.praat.call(pitch, "Get quantile", 0.0, 0.0, 0.5, "Hertz")

(那 0.5 就是 50% 的分位数,即中位数)


推荐阅读