2

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

4

1 回答 1

3

您可以使用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需要添加修改的点,而不要管其余的。您也可以像这样操纵持续时间。

在示例中,脚本将原始音高层中每个点的值更改为倒序的点值,以便第一个点具有最后一个点的值。内部的iffor是将这些更改限制在音高层子集的一种方式,但是您如何执行此操作将取决于您尝试进行的更改类型。

于 2014-02-18T18:44:13.200 回答