test_textGrid_and_DurationTier.praat 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # test_TextGrid_and_DurationTier.praat
  2. # check the interface
  3. # Create a TextGrid
  4. appendInfoLine: "test_TextGrid_and_DurationTier.praat"
  5. for i to 10
  6. f = randomUniform (100, 400)
  7. sound[i] = Create Sound as pure tone: string$ (f), 1, 0, 0.4, 44100, f, 0.2, 0.01, 0.01
  8. endfor
  9. selectObject: sound[1]
  10. for i from 2 to 10
  11. plusObject: sound[i]
  12. endfor
  13. Concatenate recoverably
  14. sound = selected ("Sound")
  15. textgrid = selected ("TextGrid")
  16. for i to 10
  17. removeObject: sound[i]
  18. endfor
  19. # some duration manipulations
  20. selectObject: sound
  21. duration = Get total duration
  22. durationTier = Create DurationTier: "chain", 0, duration
  23. selectObject: textgrid
  24. numberOfIntervals = Get number of intervals: 1
  25. deltaTime = 0.0000001
  26. for i to numberOfIntervals
  27. if i mod 2 = 0
  28. selectObject: textgrid
  29. t1 = Get start time of interval: 1, i
  30. t2 = Get end time of interval: 1, i
  31. selectObject: durationTier
  32. Add point: t1, 1
  33. Add point: t1+deltaTime, 1.9
  34. Add point: t2-deltaTime, 1.9
  35. Add point: t2, 1
  36. endif
  37. endfor
  38. selectObject: durationTier, textgrid
  39. textgrid2 = To TextGrid (scale times)
  40. selectObject: sound
  41. manipulation = To Manipulation: 0.01, 75, 600
  42. plusObject: durationTier
  43. Replace duration tier
  44. selectObject: manipulation
  45. sound2 = Get resynthesis (overlap-add)
  46. removeObject: sound, sound2, textgrid, textgrid2, manipulation, durationTier
  47. appendInfoLine: "test_TextGrid_and_DurationTier.praat OK"