speechsynthesizer_test.praat 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # speechsynthesizer_test.praat
  2. # djmw 20151209
  3. # show memory leaks of espeak
  4. synth = Create SpeechSynthesizer: "English (Great Britain)", "Female1"
  5. numberOfTries = 500
  6. table = Create Table with column names: "m", numberOfTries, "run bytes"
  7. for i to numberOfTries
  8. selectObject: synth
  9. s = To Sound: "This is some text.", "no"
  10. removeObject: s
  11. @get_memoryTotalCreated
  12. selectObject: table
  13. Set numeric value: i, "run", i
  14. Set numeric value: i, "bytes", get_memoryTotalCreated.bytes
  15. endfor
  16. selectObject: table
  17. Append column: "diff"
  18. Formula (column range): "diff", "diff", ~ self [row, "bytes"] - self [row-1, "bytes"]
  19. result = Extract rows where: "row > 1"
  20. removeObject: table
  21. selectObject: result
  22. minimum = Get minimum: "diff"
  23. Append column: "rdiff"
  24. Formula (column range): "rdiff", "rdiff", ~ self ["diff"] - minimum
  25. Erase all
  26. @asSpectrum: result, 3
  27. selectObject: asSpectrum.sound
  28. Select outer viewport: 0, 6, 0, 4
  29. Draw: 0, 0, 0, 0, "yes", "poles"
  30. Text top: "no", "espeak version 1.47.04"
  31. selectObject: asSpectrum.spectrum
  32. Select outer viewport: 0, 6, 4, 8
  33. Draw: 0, 0, 0, 0, "yes"
  34. Marks bottom every: 1, 50 , "yes", "yes", "yes"
  35. ;removeObject: result, asSpectrum.spectrum, asSpectrum.sound
  36. procedure get_memoryTotalCreated
  37. .report$ = Report memory use
  38. .end = index (.report$, " bytes)")
  39. .power = 0
  40. .bytes = 0
  41. while .end > 0
  42. .end -= 1
  43. .ch$ = mid$ (.report$, .end, 1)
  44. if .ch$ = ","
  45. ; continue
  46. elsif .ch$ = "("
  47. .end = 0
  48. else
  49. .bytes += 10^.power * number (.ch$)
  50. .power += 1
  51. endif
  52. endwhile
  53. endproc
  54. procedure asSpectrum: .table, .column
  55. selectObject: .table
  56. .tor = Down to TableOfReal: "run"
  57. .mat = To Matrix
  58. .matt = Transpose
  59. .sound1 = To Sound
  60. .sound = Extract one channel: .column
  61. Override sampling frequency: 1000
  62. .spectrum = To Spectrum: "no"
  63. Formula: ~ if col > 1 then self else 0 fi
  64. removeObject: .tor, .mat, .matt, .sound1
  65. selectObject: .spectrum
  66. endproc