在共振峰Parselmouth Python中定义samplerate

2024-09-27 09:24:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我对python中的praat parselmouth非常陌生,我是一个超级粉丝,因为它可以在不使用praat的情况下进行分析。 所以我的难题是,我需要特定采样率的共振峰,但我不能在这里改变它。 如果我改变时间步长(以及时间窗口),共振峰列表的长度不会改变。我主要使用以下代码:#http://blog.syntheticspeech.de/2021/03/10/how-to-extract-formant-tracks-with-praat-and-python/

看起来是这样的

f0min= 75
f0max=300
pointProcess = praat.call(sound, "To PointProcess (periodic, cc)", f0min, f0max)

time_step = 0.01          # or 0.002 see picture
max_formant_num = 5
max_formant_freq = 5000   # men 5000, women 5500
window_length =  0.01      # or 0.002 see picture   
preemphasis = 50

formants = praat.call(sound, "To Formant (burg)", time_step, max_formant_num, max_formant_freq, window_length, preemphasis) 

numPoints = praat.call(pointProcess, "Get number of points")
print(numPoints)
f1_list = []
f2_list = []
f3_list = []
for point in range(0, numPoints):
    point += 1
    t = praat.call(pointProcess, "Get time from index", point)
    f1 = praat.call(formants, "Get value at time", 1, t, 'Hertz', 'Linear')
    f2 = praat.call(formants, "Get value at time", 2, t, 'Hertz', 'Linear')
    f3 = praat.call(formants, "Get value at time", 3, t, 'Hertz', 'Linear')
    f1_list.append(f1)
    f2_list.append(f2)
    f3_list.append(f3)

我无法得到我想要的采样率(如30赫兹)。有人能帮忙吗

here I am plotting f1 for both time_steps, but it is still the same length (323) and timepoints


Tags: gettimecalllengthmaxlistf2point
2条回答

记录在案:最初的问题也是在Gitter上提出的(或者至少这个问题与Gitter有关联);见https://gitter.im/PraatParselmouth/Lobby?at=610be18129b165332e5e61f2

这两个问题似乎都有相同的根本原因:您使用parselmouth.praat.call查询PointProcess对象的长度,或者使用该对象将索引转换为时间,但随后使用Formant对象的结果

在第一种情况下,这就是为什么您总是得到相同数量的点(时间点在pointProcess),而您想要的是formants中的“帧”数量。它还解释了为什么在绘图中得到相同的点,但曲线更粗糙(插值)

在第二种情况下,您需要的是PointProcess中各点的时间,而不是估计共振峰的时间样本

我看到同样的情况也发生在blog post you link to地区。如果你想在Praat估计的声门脉冲点取样共振峰,那么它可能是正确的,但这似乎与你的目标略有不同

现在我做了更改(“获取帧数”),我可以定义/修改采样率。它也在为wav文件的一部分运行,但在大约一半的时候,我收到了以下错误消息:praterror:Argument“Time”的值为“undefined”。对于要定义f1的行

numPoints = praat.call(formants, "Get number of frames")
print(numPoints)
f1_list = []
f2_list = []
f3_list = []
t_list  = [] # timing
i= 0
for point in range(0, numPoints):
    point += 1
    t = praat.call(pointProcess, "Get time from index", point)
    f1 = praat.call(formants, "Get value at time", 1, t, 'Hertz', 'Linear')
    f2 = praat.call(formants, "Get value at time", 2, t, 'Hertz', 'Linear')
    f3 = praat.call(formants, "Get value at time", 3, t, 'Hertz', 'Linear')
    t_list.append(t)
    f1_list.append(f1)
    f2_list.append(f2)
    f3_list.append(f3)

相关问题 更多 >

    热门问题