test_detectSilences.praat 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # test_detectSilences.praat
  2. # djmw 20170808
  3. appendInfoLine: "test_detectSilences.praat"
  4. text$ [0] = "+-, +-+-, ..., +-+-+-+-+-"
  5. text$ [1] = "-+, -+-+, ..., -+-+-+-+-+"
  6. db0 = -30
  7. for k from 0 to 1
  8. appendInfoLine: tab$, text$ [k]
  9. sound [k] = Create Sound from formula: "s"+ string$(k), 1, 0, 1, 44100, "randomGauss (0,0.1)"
  10. for i to 5
  11. selectObject: sound [k]
  12. Formula (part): (2*i-1 -k)*0.1, (2*i-k) *0.1, 1, 1, "self*10^(db0 / 20)"
  13. tg = To TextGrid (silences): 100, 0, -25, 0.01, 0.01, "silent", "sounding"
  14. numberOfIntervals = Get number of intervals: 1
  15. numberOfIntervals2 = i * 2 + (if i < 5 then 1-k else 0 fi)
  16. assert numberOfIntervals = numberOfIntervals2; 'numberOfIntervals' 'i' 'k'
  17. removeObject: tg
  18. endfor
  19. endfor
  20. appendInfoLine: tab$, "silence is +3dB or -3dB w.r.t threshold"
  21. db0 = -30
  22. for k from 0 to 1
  23. for idb to 2
  24. db = -27 - (idb -1) * 6; 3 db around db0
  25. selectObject: sound [k]
  26. tg = To TextGrid (silences): 100, 0, db, 0.01, 0.01, "silent", "sounding"
  27. numberOfIntervals = Get number of intervals: 1
  28. numberOfIntervals2 = if db < db0 then 1 else 10 fi
  29. assert numberOfIntervals = numberOfIntervals2; 'db'
  30. removeObject: tg
  31. endfor
  32. endfor
  33. # sound [0] and sound [1] have 10 intervals
  34. appendInfoLine: tab$, "minimum sounding/silent interval exceeds largest interval"
  35. for k from 0 to 1
  36. selectObject: sound [k]
  37. tg = To TextGrid (silences): 100, 0, db, 0.15, 0.15, "silent", "sounding"
  38. numberOfIntervals = Get number of intervals: 1
  39. assert numberOfIntervals = 1
  40. removeObject: sound [k], tg
  41. endfor
  42. # more tests...
  43. #removeObject: sound
  44. appendInfoLine: "test_detectSilences.praat OK"