所以首先你得到这三个对象,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)
获得语音中断的程度有点困难。不知道为什么 Praat 没有命令得到这个。
在 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 for period in periods if period > max_voiced_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% 的分位数,即中位数)