Advertisement
maeblythe

Textgrid to Lab for Diffsinger Praat Script

Jan 4th, 2024 (edited)
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. # still yoinking code from Hataori-P
  2. # select the textgrid you want to convert then run this - only one grid at a time
  3. # rename praat.lab as soon as it finishes because running again deletes the old one
  4. # I open all of it in VLabeler afterwards just to make sure it's good
  5.  
  6. grid = selected: "TextGrid", 1
  7.  
  8. selectObject: grid
  9.  
  10. gNumTiers = Get number of tiers
  11. if gNumTiers <> 1
  12. exitScript: "TextGrid doesn't have only 1 tier"
  13. endif
  14.  
  15. gIsInterval = Is interval tier: 1
  16. if not gIsInterval
  17. exitScript: "TextGrid's tier is not Interval Tier"
  18. endif
  19.  
  20. deleteFile: "praat.lab"
  21.  
  22. gNumInts = Get number of intervals: 1
  23.  
  24.  
  25. for .i to gNumInts
  26. selectObject: grid
  27. ts = Get start time of interval: 1, .i
  28. tsX = ts * 10000000
  29. te = Get end time of interval: 1, .i
  30. teX = te * 10000000
  31. lbl$ = Get label of interval: 1, .i
  32.  
  33. if lbl$ = ""
  34. lbl$ = "pau"
  35. endif
  36.  
  37. if lbl$ = "_"
  38. lbl$ = "pau"
  39. endif
  40.  
  41.  
  42. appendFileLine: "praat.lab", round(tsX), " ", round(teX), " ", lbl$
  43. endfor
  44.  
  45.  
  46.  
  47.  
  48. writeInfoLine: "File Praat.lab created"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement