在praat中改变音高

时间:2013-12-14 19:29:54

标签: praat

我想在wav文件的两个不同部分修改音高。为此,我从wav文件的相应textgrid文件中获取开始时间和结束时间的信息。是否可以在两个部分修改音高。

1 个答案:

答案 0 :(得分:2)

您可以使用Manipulation对象对原始声音的音高进行任何更改。

# Original sound made of three consecutive notes
snd[1] = Create Sound as pure tone: "A", 1, 0, 0.3, 44100, 220, 0.2, 0.01, 0.01
snd[2] = Create Sound as pure tone: "B", 1, 0, 0.3, 44100, 247, 0.2, 0.01, 0.01
snd[3] = Create Sound as pure tone: "C", 1, 0, 0.3, 44100, 277, 0.2, 0.01, 0.01

selectObject(snd[1], snd[2], snd[3])
sound = Concatenate
Rename: "original"

removeObject(snd[1], snd[2], snd[3])

selectObject(sound)
Play

# We will invert the pitch, so that the notes play in the opposite direction
manipulation = To Manipulation: 0.01, 200, 300
pitchtier = Extract pitch tier

# We copy it because we want to modify it, not create one from scratch
# and we want to be able to read the values of the original from somewhere
original = Copy: "old"
points = Get number of points

# This for loop looks at the values of the original pitch tier and writes them
# onto the new pitch tier
for p to points
  selectObject(original)
  f = Get value at index: points - p + 1
  t = Get time from index: p
# If you uncomment the if block, the changes will only affect the first and last
# quarter of the sound
#  if t < 0.25 or t > 0.75
    selectObject(pitchtier)
    Remove point: p
    Add point: t, f
#  endif
endfor

# We replace the pitch tier
selectObject(pitchtier, manipulation)
Replace pitch tier

# Resynthesize
selectObject(manipulation)
new_sound = Get resynthesis (overlap-add)

# And clean up
removeObject(original, pitchtier, manipulation)
selectObject(new_sound)
Rename: "modified"
Play 

您可以通过在不同时间使用不同的音高值(以赫兹为单位)添加点来更改音高等级,当您进行重新合成时,Praat将修改原始值,使其与您指定的值相匹配。

在您的情况下,您可以使用TextGrid中的时间值来了解何时需要添加修改后的PitchTier点,其余部分单独使用。你也可以像这样操纵持续时间。

在该示例中,脚本使用反转顺序中的点值更改原始音高层中每个点的值,以便第一个点具有最后一个点的值。 if中的for块是将这些更改限制为音高层子集的一种方法,但是如何执行此操作取决于您尝试进行的更改类型。