Advertisement
maeblythe

Praat Textgrid to Lab for Diffsinger

Nov 19th, 2023
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | Source Code | 0 0
  1. # Original code by Hataori-P
  2. # Select textgrid to convert in the object list
  3. # Rename each lab afterwards - previous praat.lab is deleted when you run this
  4. # Only works with one tier
  5. # All empty labels are set to pau. Don't know if this is an issue.
  6. # can't figure out how to make lowercase - can fix in notepad++
  7.  
  8. grid = selected: "TextGrid", 1
  9.  
  10. selectObject: grid
  11.  
  12. gNumTiers = Get number of tiers
  13. if gNumTiers <> 1
  14. exitScript: "TextGrid doesn't have only 1 tier"
  15. endif
  16.  
  17. gIsInterval = Is interval tier: 1
  18. if not gIsInterval
  19. exitScript: "TextGrid's tier is not Interval Tier"
  20. endif
  21.  
  22. deleteFile: "praat.lab"
  23.  
  24. gNumInts = Get number of intervals: 1
  25.  
  26.  
  27. for .i to gNumInts
  28. selectObject: grid
  29. ts = Get start time of interval: 1, .i
  30. tsX = ts * 10000000
  31. te = Get end time of interval: 1, .i
  32. teX = te * 10000000
  33. lbl$ = Get label of interval: 1, .i
  34.  
  35. if lbl$ = ""
  36. lbl$ = "pau"
  37. endif
  38.  
  39.  
  40. appendFileLine: "praat.lab", round(tsX), " ", round(teX), " ", lbl$
  41. endfor
  42.  
  43.  
  44.  
  45.  
  46. writeInfoLine: "File Praat.lab created"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement