| 1 |
writeInfoLine: "testing SpeechSynthesizer..." |
| 2 |
if 1 |
| 3 |
appendInfoLine: "testing French..." |
| 4 |
my.SpeechSynthesizer = Create SpeechSynthesizer: "French (France)", "Female1" |
| 5 |
text$ = "voici les clés de ton bonheur" |
| 6 |
phonemes$ = Get phonemes from text: text$ |
| 7 |
writeInfoLine: length (text$), " ", length (phonemes$), " ", phonemes$ |
| 8 |
assert length (text$) = 29 |
| 9 |
assert length (phonemes$) = 27 |
| 10 |
assert phonemes$ = "vwasi le- kle də- tɔ̃ bɔnœʁ" |
| 11 |
Remove |
| 12 |
endif |
| 13 |
|
| 14 |
if 1 |
| 15 |
appendInfoLine: "testing Hindi..." |
| 16 |
my.SpeechSynthesizer = Create SpeechSynthesizer: "Hindi", "Female1" |
| 17 |
text$ = "अवग्रहः" |
| 18 |
phonemes$ = Get phonemes from text: text$ |
| 19 |
appendInfoLine: length (text$), " ", length (phonemes$), " ", phonemes$ |
| 20 |
assert phonemes$ = "ʌʋʌɡɾəhəh" |
| 21 |
Remove |
| 22 |
endif |
| 23 |
|
| 24 |
# |
| 25 |
# bug solved on 2024-09-23: too long sound after "Get phonemes from text" |
| 26 |
# (wav-buffer was cleared late instead of at the beginning) |
| 27 |
# |
| 28 |
if 1 |
| 29 |
appendInfoLine: "testing clearing of buffer..." |
| 30 |
my.SpeechSynthesizer = Create SpeechSynthesizer: "English (Great Britain)", "Female1" |
| 31 |
text$ = "This is some text." |
| 32 |
my.Sound = To Sound: text$, "no" |
| 33 |
duration = Get total duration |
| 34 |
Remove |
| 35 |
assert duration > 1.0 |
| 36 |
assert duration < 1.2 |
| 37 |
selectObject: my.SpeechSynthesizer |
| 38 |
ipa$ = Get phonemes from text: text$ |
| 39 |
assert ipa$ = "ðɪs ɪz sʌm tɛkst" |
| 40 |
ipa$ = Get phonemes from text: text$ |
| 41 |
assert ipa$ = "ðɪs ɪz sʌm tɛkst" |
| 42 |
my.Sound = To Sound: text$, "no" |
| 43 |
duration = Get total duration |
| 44 |
Remove |
| 45 |
assert duration > 1.0 |
| 46 |
assert duration < 1.2 |
| 47 |
removeObject: my.SpeechSynthesizer |
| 48 |
endif |
| 49 |
|
| 50 |
# |
| 51 |
# The following was correct in 6.2 through 6.4.17, |
| 52 |
# but showed empty clause and word tiers in 6.4.18 through 6.4.20. |
| 53 |
# Still existing on 2024-09-23. |
| 54 |
# |
| 55 |
if 1 |
| 56 |
appendInfoLine: "testing appearance of clause and word tiers..." |
| 57 |
my.SpeechSynthesizer = Create SpeechSynthesizer: "English (Great Britain)", "Female1" |
| 58 |
Speech output settings: 44100, 0.01, 1, 1, 130, "IPA" |
| 59 |
To Sound: "This is some text.", "yes" |
| 60 |
my.Sound = selected ("Sound") |
| 61 |
my.TextGrid = selected ("TextGrid") |
| 62 |
selectObject: my.TextGrid |
| 63 |
# |
| 64 |
# Tier 1: "sentence". Should contain the original text. |
| 65 |
# |
| 66 |
numberOfIntervals = Get number of intervals: 1 |
| 67 |
assert numberOfIntervals = 1 |
| 68 |
sentence$ = Get label of interval: 1, 1 |
| 69 |
assert sentence$ = "This is some text." |
| 70 |
# |
| 71 |
# Tier 2: "clause". Should contain the original text, followed by a space. |
| 72 |
# |
| 73 |
numberOfIntervals = Get number of intervals: 2 |
| 74 |
assert numberOfIntervals = 2 |
| 75 |
clause$ = "" |
| 76 |
for interval to numberOfIntervals |
| 77 |
interval$ = Get label of interval: 2, interval |
| 78 |
clause$ += if interval$ = "" then "·" else interval$ fi |
| 79 |
endfor |
| 80 |
assert clause$ = "This is some text.·" |
| 81 |
# |
| 82 |
# Tier 3: "word". Should contain the words, separated by empty intervals. |
| 83 |
# |
| 84 |
numberOfIntervals = Get number of intervals: 3 |
| 85 |
assert numberOfIntervals = 9 |
| 86 |
word$ = "" |
| 87 |
for interval to numberOfIntervals |
| 88 |
interval$ = Get label of interval: 3, interval |
| 89 |
word$ += if interval$ = "" then "·" else interval$ fi |
| 90 |
endfor |
| 91 |
assert word$ = "·This·is·some·text.·" |
| 92 |
# |
| 93 |
# Tier 4: "phoneme". Should contain the IPA version of the text, with words separated by empty intervals. |
| 94 |
# |
| 95 |
numberOfIntervals = Get number of intervals: 4 |
| 96 |
assert numberOfIntervals = 18 |
| 97 |
phonemes$ = "" |
| 98 |
for interval to numberOfIntervals |
| 99 |
interval$ = Get label of interval: 4, interval |
| 100 |
phonemes$ += if interval$ = "" then "·" else interval$ fi |
| 101 |
endfor |
| 102 |
assert phonemes$ = "·ðɪs·ɪz·sʌm·tɛkst·" |
| 103 |
# |
| 104 |
# The following crashed in 6.4.17. |
| 105 |
# |
| 106 |
;selectObject: my.Sound, my.TextGrid |
| 107 |
;View & Edit |
| 108 |
# |
| 109 |
# Clean up. |
| 110 |
# |
| 111 |
removeObject: my.SpeechSynthesizer, my.Sound, my.TextGrid |
| 112 |
endif |
| 113 |
|
| 114 |
appendInfoLine: "OK" |