| 1 |
# test_DTW.praat |
| 2 |
# djmw 20100504, 20120223, 20221114 |
| 3 |
|
| 4 |
printline DTW_test start |
| 5 |
|
| 6 |
stepSize = 0.005 |
| 7 |
s1 = Create Sound from formula... s1 Mono 0 1 44100 1/2 * sin(2*pi*377*x) + randomGauss(0,0.1) |
| 8 |
s2 = Copy... s2 |
| 9 |
plus s1 |
| 10 |
dtw = To DTW... 0.015 stepSize 0.1 1/2 < slope < 2 |
| 11 |
# the save crashed before praat6.3 |
| 12 |
Save as binary file: "dtw_willberemovedXXX.DTW" |
| 13 |
dtwcopy = Read from file: "dtw_willberemovedXXX.DTW" |
| 14 |
deleteFile: "dtw_willberemovedXXX.DTW" |
| 15 |
removeObject: dtwcopy |
| 16 |
|
| 17 |
selectObject: dtw |
| 18 |
printline 'tab$' Slope constraint |
| 19 |
nx = Get maximum consecutive steps... X |
| 20 |
assert nx <= 2 |
| 21 |
ny = Get maximum consecutive steps... Y |
| 22 |
assert ny <= 2 |
| 23 |
for i to 20 |
| 24 |
t = i * 0.04 |
| 25 |
ty = Get y time... t |
| 26 |
assert (ty - stepSize) < t and t < (ty + stepSize) |
| 27 |
tx = Get x time... t |
| 28 |
assert (tx - stepSize) < t and t < (tx + stepSize) |
| 29 |
endfor |
| 30 |
|
| 31 |
select dtw |
| 32 |
printline 'tab$' To Polygon... |
| 33 |
pol = To Polygon... 0.1 1/2 < slope < 2 |
| 34 |
Remove |
| 35 |
select dtw |
| 36 |
pol = To Polygon... 0.1 1/3 < slope < 3 |
| 37 |
Remove |
| 38 |
select dtw |
| 39 |
pol = To Polygon... 0.1 2/3 < slope < 3/2 |
| 40 |
Remove |
| 41 |
printline 'tab$' To Matrix |
| 42 |
select dtw |
| 43 |
mat = To Matrix (distances) |
| 44 |
Remove |
| 45 |
select dtw |
| 46 |
To Matrix (cum. distances)... 0.05 2/3 < slope < 3/2 |
| 47 |
Remove |
| 48 |
select dtw |
| 49 |
plus s1 |
| 50 |
plus s2 |
| 51 |
Remove |
| 52 |
printline test_DTW end O.K. |