Pitch modification in praat

1.7k views Asked by At

I want to modify the pitch at two different parts of a wav file. To do that , i have the information of starting time and ending time from the corresponding textgrid file of the wav file. Is it possible to modify the pitch at two parts.

1

There are 1 answers

6
jja On BEST ANSWER

You can use a Manipulation object to make any changes you want to the original sound's pitch.

# 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 

You change the pitch tier by adding points at different times with different pitch values (in Hertz), and when you do the resynthesis Praat will modify the original values so they match the ones you specified.

In your case, you can use the time values from the TextGrid to know when the modified PitchTier points need to be added and leave the rest alone. You can also manipulate duration like this.

In the example, the script changes the value of each of the points in the original pitch tier with the value of the points in the inverted order, so that the first point will have the value of the last one. The if block inside the for is one way of limiting those changes to a subset of the pitch tier, but how you do this will depend on the sort of changes you are trying to make.