【问题标题】:Define samplerate in Formants Parselmouth Python在 Formants Parselmouth Python 中定义采样率
【发布时间】:2021-10-08 21:37:20
【问题描述】:

我对 python 中的 praat parselmouth 非常陌生,而且我是它的忠实粉丝,因为它可以在没有 Praat 的情况下进行分析。 所以我的挣扎是,我需要特定采样率的共振峰,但我不能在这里改变它。 如果我更改 time_step(以及时间窗口),共振峰列表的长度不会改变。我主要使用这段代码:#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 Hz)。有人可以帮忙吗?

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

【问题讨论】:

    标签: python sample-rate praat


    【解决方案1】:

    所以现在我做了更改(“获取帧数”),我可以定义/修改采样率。它也在为 wav 文件的一部分运行,但在 ~ 一半时我收到此错误消息:PraatError: Argument "Time" has the value "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)
    

    【讨论】:

      【解决方案2】:

      为了记录:最初的问题也在 Gitter 上被问到(或者至少这个问题被链接到);见https://gitter.im/PraatParselmouth/Lobby?at=610be18129b165332e5e61f2

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

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

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

      我看到blog post you link to 也发生了同样的事情。如果您想在 Praat 估计声门脉冲的点对共振峰进行采样,那么它可能是正确的,但这似乎与您的目标略有不同?

      【讨论】:

      • 好的,没错。我还有另一个目标。但是我现在该如何继续,以便代码为我提供时间点的共振峰?
      • 您可以获得共振峰帧的时间,而不是PointProcess:t = praat.call(formants, "Get time from frame number", point)。我还建议写t = praat.call(formants, "Get time from frame number", point + 1) 并删除之前的point += 1 行。
      猜你喜欢
      • 2020-01-13
      • 1970-01-01
      • 2017-03-04
      • 1970-01-01
      • 1970-01-01
      • 2015-10-05
      • 2021-10-10
      • 2016-10-19
      • 2021-12-25
      相关资源
      最近更新 更多