Skip to content

Commit aa89939

Browse files
Update
1 parent a3bd2c6 commit aa89939

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

scripts/generate-tts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ npm run generate -- --voice Alex --rate 170
1818
npm run generate -- --force # regenerate existing files (needed after voice/TTS fixes)
1919
```
2020

21-
Single letters and digits use macOS `[[char U+....]]` notation so `say` pronounces "A" instead of "Capital A". Optional per-entry `"speak"` in the manifest overrides that text.
21+
Single letters are spoken as `A.` (trailing period) so `say` pronounces the letter, not "Capital A". Optional per-entry `"speak"` in the manifest overrides that text.
2222

2323
Copy the generated `sd-card/` folder contents to the root of a FAT32 microSD card, then insert the card into the CoreS3.

scripts/generate-tts/generate.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,29 @@ function usageToFilename(usageHex) {
4343
return `u${value.toString(16).padStart(3, "0")}.wav`;
4444
}
4545

46-
/** Text passed to macOS `say` (avoids e.g. "Capital A" for label "A"). */
46+
/**
47+
* Text for macOS `say`. Single letters need a trailing "." so Samantha says
48+
* "A" instead of "Capital A". Do not use [[char U+...]] — modern voices read
49+
* that markup aloud.
50+
*/
4751
function speakTextForEntry(entry) {
4852
if (entry.speak) {
4953
return entry.speak;
5054
}
5155
const { label } = entry;
52-
if (label.length === 1) {
53-
const code = label.toUpperCase().charCodeAt(0);
54-
if (
55-
(code >= 0x41 && code <= 0x5a) ||
56-
(code >= 0x30 && code <= 0x39)
57-
) {
58-
return `[[char U+${code.toString(16).padStart(4, "0").toUpperCase()}]]`;
59-
}
56+
if (label.length === 1 && /[A-Za-z]/.test(label)) {
57+
return `${label.toUpperCase()}.`;
6058
}
6159
return label;
6260
}
6361

6462
function runSay(entry, voice, rate, aiffPath) {
6563
const text = speakTextForEntry(entry);
64+
const textPath = path.join(tmpDir, "speak.txt");
65+
fs.writeFileSync(textPath, text, "utf8");
6666
spawnSync(
6767
"say",
68-
["-v", voice, "-r", String(rate), "-o", aiffPath, text],
68+
["-v", voice, "-r", String(rate), "-o", aiffPath, "-f", textPath],
6969
{ stdio: "inherit" }
7070
);
7171
}

0 commit comments

Comments
 (0)