Advertisement
maeblythe

Import Midi Textgrid to lab + @ support

May 25th, 2024
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1.  
  2.  
  3. grid = selected: "TextGrid", 1
  4.  
  5. selectObject: grid
  6.  
  7. gNumTiers = Get number of tiers
  8. if gNumTiers <> 1
  9. exitScript: "TextGrid doesn't have only 1 tier"
  10. endif
  11.  
  12. gIsInterval = Is interval tier: 1
  13. if not gIsInterval
  14. exitScript: "TextGrid's tier is not Interval Tier"
  15. endif
  16.  
  17. deleteFile: "praat.lab"
  18.  
  19. gNumInts = Get number of intervals: 1
  20.  
  21.  
  22. for .i to gNumInts
  23. selectObject: grid
  24. ts = Get start time of interval: 1, .i
  25. tsX = ts * 10000000
  26. te = Get end time of interval: 1, .i
  27. teX = te * 10000000
  28. lbl$ = Get label of interval: 1, .i
  29.  
  30.  
  31. # if lbl$ = "_"
  32. # part$ = "pau"
  33. # elsif lbl$ = " "
  34. # part$ = "pau"
  35. # else
  36. dot = rindex(lbl$, " ")
  37. numCharsPart = dot - 1
  38. part$ = left$ (lbl$, numCharsPart)
  39.  
  40. if part$ = ""
  41. part$ = "pau"
  42. endif
  43.  
  44. if part$ = "_"
  45. part$ = "pau"
  46. endif
  47.  
  48. # endif
  49.  
  50. rhotMid = tsX + ((teX - tsX) / 2)
  51.  
  52.  
  53. if part$ = "Q@"
  54. appendFileLine: "praat.lab", round(tsX), " ", round(rhotMid), " aa"
  55. appendFileLine: "praat.lab", round(rhotMid), " ", round(teX), " r"
  56. elsif part$ = "O@"
  57. appendFileLine: "praat.lab", round(tsX), " ", round(rhotMid), " ao"
  58. appendFileLine: "praat.lab", round(rhotMid), " ", round(teX), " r"
  59. elsif part$ = "I@"
  60. appendFileLine: "praat.lab", round(tsX), " ", round(rhotMid), " ih"
  61. appendFileLine: "praat.lab", round(rhotMid), " ", round(teX), " r"
  62. elsif part$ = "U@"
  63. appendFileLine: "praat.lab", round(tsX), " ", round(rhotMid), " uh"
  64. appendFileLine: "praat.lab", round(rhotMid), " ", round(teX), " r"
  65. elsif part$ = "e@"
  66. appendFileLine: "praat.lab", round(tsX), " ", round(rhotMid), " eh"
  67. appendFileLine: "praat.lab", round(rhotMid), " ", round(teX), " r"
  68. else
  69. appendFileLine: "praat.lab", round(tsX), " ", round(teX), " ", part$
  70. endif
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. endfor
  79.  
  80.  
  81.  
  82.  
  83. writeInfoLine: "File Praat.lab created"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement