macintalk: PlainTalk high quality voices

Agnes, Bruce and Victoria high quality now decode and speak: their units
are on 8-byte boundaries and their codebook has 2-sample vectors. The
fetch script keeps them (as agnes-hq.gtss and so on), with live voices
live-plaintalk-*-hq.

Unit offsets above 0xffff were skipped when counting units, which put
the period lists out of step with the units in every voice; fixing that
brings the recogniser's word error rate down from about 30% to 23%.
The base pitch is now the median recorded period, not header word 1
(70 in Victoria high quality, which is wrong).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRAKCKq1gSHpownvFE
This commit is contained in:
Claude committed 2026-11-11 02:53:23 +00:00
1 parent 04936f13a5
commit 3a0aad5e8b
12 files changed
+140 -35

No files matched your search

+2 -1
View File
@@ -108,7 +108,8 @@ voices, belong to their owners:
- **PlainTalk, live** (`live-plaintalk-*`): no recordings in this
repository. Each sentence is spoken on the Asterisk machine by the same
`synth/macintalk`, which joins the recorded diphones of Apple's PlainTalk
(MacinTalk Pro) voices Agnes, Bruce and Victoria. Those recordings are
(MacinTalk Pro) voices Agnes, Bruce and Victoria (standard and high
quality). Those recordings are
Apple's (© Apple Computer, Inc. 1992-1998) and are not in this
repository: `tools/fetch-macintalk.py` downloads them from a Mac OS 8.6
disk image on the Internet Archive. PlainTalk is a trademark of Apple
+2 -1
View File
@@ -76,7 +76,8 @@ stroke, it will be four fifteen and twenty seconds."), a little ahead of
when it is needed, so the call never waits on it. The `live-dectalk-*` and
`live-sam-*` voices run DECtalk's `say` and `sam`. The `live-macintalk-*`
voices (Fred, Ralph, Kathy, Zarvox and the other 15 MacInTalk 3 voices) and
the `live-plaintalk-*` voices (Agnes, Bruce and Victoria) run
the `live-plaintalk-*` voices (Agnes, Bruce and Victoria, standard and
high quality) run
[synth/macintalk](synth/macintalk), our own synthesiser, which reads
Apple's voice data (`cd synth/macintalk && make && make voices && sudo make
install` builds it and fetches the data; the PlainTalk voices also need
+15 -14
View File
@@ -1,7 +1,8 @@
# PlainTalk voice files
What `synth/macintalk` knows about Apple's PlainTalk voices (MacinTalk Pro
1.5: Agnes, Bruce and Victoria). It was worked out from the voices' data
1.5: Agnes, Bruce and Victoria, each in a standard and a high quality
version). It was worked out from the voices' data
alone: by reading the tables, decoding the sound and checking the result
by ear and with a speech recogniser. No Apple code was run, emulated,
disassembled or read to find it.
@@ -28,8 +29,8 @@ and these resources:
| `vers`, `STR `, `ftag` | version 1.4.2, "English Text-To-Speech 1.5.3", © 1992-98 |
The script writes each voice's `gtss` 3 to `<voice>.gtss` (`agnes.gtss`,
`bruce.gtss`, `victoria.gtss`). The three "high quality" voices code their
sound differently (see the end) and are left out for now.
`bruce.gtss`, `victoria.gtss`, and `agnes-hq.gtss` and so on for the files
called "Agnes, high quality" and so on).
The MacinTalk Pro extension itself holds the English text rules and
dictionary (`gtst`), the phoneme and allophone lists (`gtsp`, `gtsa`) and
@@ -44,9 +45,9 @@ All big-endian. A 16-byte header, then twelve 32-bit offsets of sections
| Header word | Agnes, Bruce, Victoria | What it is |
|---|---|---|
| 0 | 50 | the number of wave-phonemes (the tables are 50 × 50) |
| 1, 2 | 100, 185, 125 | the speaker's typical pitch period, samples at 22050 Hz |
| 1, 2 | 100, 185, 125 (Victoria high quality: 70) | about the speaker's pitch period, samples at 22050 Hz; the median of the recorded periods (101, 191, 108) is better |
| 4 | 5739, 3922, 7804 | unknown |
| 7 | 0x0702 (high quality: 0x0403) | the coding |
| 7 | 0x0702, high quality 0x0403 | the coding |
| Section | Size (Agnes) | What it is |
|---|---|---|
@@ -60,7 +61,7 @@ All big-endian. A 16-byte header, then twelve 32-bit offsets of sections
| 7 | 21668 | period lengths of the units in section 3 |
| 8 | 52 | a class for each wave-phoneme: 0, 1 (vowels and sonorants) or 2 (f, th, s, sh) |
| 9 | 172 | for each of the 86 allophones, its wave-phoneme and a second one (for ch, j and syllabic consonants) |
| 10 | 2048 | the codebook: 256 vectors of 4 signed 16-bit samples |
| 10 | 2048 | the codebook: 256 vectors of 4 signed 16-bit samples (high quality: 1024 bytes, 256 vectors of 2) |
| 11 | 352 | unknown (the same in every voice) |
### The wave-phonemes
@@ -88,7 +89,8 @@ the middle of *right*). An entry is two 32-bit words:
- `0xffffffff, …`: no such diphone.
- `0x0000ffff, (l << 16) | r`: use diphone *l*–*r* instead.
- otherwise the unit's offset in its section divided by 4, then a second
- otherwise the unit's offset in its section divided by 4 (by 8 in the
high quality voices; it can be more than 0xffff), then a second
word: for a voiced unit a running count of the frames before it in its
section, for a consonant unit the number of whole frames (high half)
and a value up to about 120 (low half, unknown).
@@ -99,7 +101,7 @@ are in 2 or 3. Silence has no halves of its own.
### A unit
Each unit starts on a 4-byte boundary with one byte (unknown, mostly 100 to
Each unit starts on a 4-byte boundary (8 in high quality) with one byte (unknown, mostly 100 to
170), then frames. A unit is one stretch of sound at 22050 Hz, cut into
frames of *N* samples; *N* is 96 for Agnes and Victoria and 160 for Bruce
(it is not in the header; it is the frame size that makes all the units
@@ -109,11 +111,11 @@ parse). The frames are not pitch periods, they simply follow each other.
|---|---|
| 1 | the gain *A*: a 4-bit exponent and 4-bit mantissa, gain = (16 + (*A* & 15)) × 2^(*A* >> 4) / 256. Its top bit is clear. |
| 1 | the lag *B* |
| *N* / 4 | codebook indices |
| *N* / 4 (high quality *N* / 2) | codebook indices |
Each sample is the sample one pitch period back, *N* + *B* − 1 samples
earlier in the same unit, plus the gain times its sample of the codebook
vector (one vector for each 4 samples). The first frame has nothing before
vector (one vector for each 4 samples, or 2). The first frame has nothing before
it (low nibble 0 in *A*, and *B* = 1). In voiced sound *N* + *B* − 1 is the
pitch period: it matches the recorded period lengths of sections 6 and 7
to within a sample or two. Lags of 50 and more turn up in noisy and
@@ -121,7 +123,7 @@ changing frames; taking them as plain lags works.
The last frame is shorter: its first byte has the top bit set and its low
7 bits are its number of indices, then come the lag, the indices, the
frame's gain byte, and padding to the next 4-byte boundary.
frame's gain byte, and padding to the next unit.
A voiced unit's samples add up to the sum of its period lengths in section
6 or 7 (give or take 3), so those lengths are its pitch marks. Consonant
@@ -136,13 +138,12 @@ the phoneme before it and the first half of the diphone into the phoneme
after it. That sound is changed to the length and pitch wanted with
TD-PSOLA: each recorded period, in a window two periods wide, is placed at
the spacing the pitch wants, and periods are repeated or dropped for the
length. A low-pass filter at 6 kHz takes off the hiss of the 2-bit coding.
length. A low-pass filter at 6 kHz takes off the hiss of the coding (2
bits a sample, 4 in high quality).
For these voices the phrase ends slow down and fall less than for the
MacInTalk 3 voices. The rest of the voice, Apple's rules for the timing and
the pitch, is not used.
## Not done
- The "high quality" voices code 2 samples per codebook vector (a 1024-byte
codebook) and their last frames are not marked the same way.
- The unit's first byte, header word 4 and section 11.
+3 -2
View File
@@ -5,7 +5,8 @@ classic Mac OS: Fred, Ralph, Kathy, Junior, Princess, Zarvox, Trinoids,
Whisper, the singing voices (Cellos, Pipe Organ, Good News, Bad News) and
the novelty ones (Bells, Boing, Bubbles, Albert, Bahh, Deranged,
Hysterical). It also speaks with the PlainTalk voices Agnes, Bruce and
Victoria, by joining their recorded diphones.
Victoria (and their high quality versions), by joining their recorded
diphones.
It is a clean-room program. It has no Apple code and doesn't run, emulate or
load any. It reads only the voices' data, which `tools/fetch-macintalk.py`
@@ -77,4 +78,4 @@ The PlainTalk voices (plaintalk.c) share steps 1 to 3. Then each phoneme is
the second half of a recorded diphone into it and the first half of one out
of it, decoded from the voice's codebook, and set to its length and pitch
by TD-PSOLA (the recorded periods, windowed, placed at the new spacing).
Their high quality versions aren't supported yet.
Their high quality versions are agnes-hq, bruce-hq and victoria-hq.
+2 -2
View File
@@ -1288,8 +1288,8 @@ int main(int argc, char **argv)
memcpy(id, e->d_name, l - 5);
id[l - 5] = 0;
if (!pt_load(&ptv, dir, id))
printf("%-12s %-12s %3d Hz %3d wpm PlainTalk%s\n", id, id,
FS / ptv.nom, PT_RATE, ptv.dim == 2 ? ", high quality" : "");
printf("%-12s %-12s %3d Hz %3d wpm PlainTalk%s (N=%d)\n", id, id,
FS / ptv.nom, PT_RATE, ptv.dim == 2 ? ", high quality" : "", ptv.N);
}
}
closedir(d);
+40 -9
View File
@@ -22,8 +22,9 @@ struct ptvoice {
unsigned char *d;
size_t n;
uint32_t sec[13];
int nom; /* the voice's own period, samples at 22050 Hz */
int dim; /* samples per codebook vector */
int nom; /* the speaker's usual period, samples at 22050 Hz */
int dim; /* samples per codebook vector: 4, or 2 in high quality */
int align; /* units start on multiples of this many bytes */
int N; /* samples in a coded period */
int16_t cb[256][4];
uint32_t tab[2][PT_NW * PT_NW][2];
@@ -47,7 +48,7 @@ static int u32cmp(const void *a, const void *b)
/* How many of the units parse cleanly as frames of N samples: whole
* frames, then a last frame whose first byte has the top bit set and holds
* its index count, then one byte and up to 3 bytes of padding. */
* its index count, then one byte and padding to the next unit. */
static int pt_fit(struct ptvoice *v, int N)
{
int s, i, ok = 0, F = 2 + N / v->dim;
@@ -58,7 +59,7 @@ static int pt_fit(struct ptvoice *v, int N)
p += F;
if (p < e) {
uint32_t end = p + 2 + (v->d[p] & 0x7f) + 1;
ok += end <= e && e <= end + 3;
ok += end <= e && e < end + v->align;
}
}
return ok;
@@ -98,8 +99,10 @@ static int pt_load(struct ptvoice *v, const char *dir, const char *id)
goto bad;
/* section 10: the codebook, 256 vectors */
v->dim = (int)(v->sec[11] - v->sec[10]) / 512;
if (v->dim != 4) /* the high quality voices code differently; not done yet */
if (v->dim != 4 && v->dim != 2)
goto bad;
/* the tables count in units of 4 bytes, or 8 in the high quality voices */
v->align = 16 / v->dim;
for (i = 0; i < 256 * v->dim; i++)
v->cb[i / v->dim][i % v->dim] = (int16_t)be16(v->d + v->sec[10] + 2 * i);
/* sections 0 and 1: where the two halves of each diphone are */
@@ -120,6 +123,26 @@ static int pt_load(struct ptvoice *v, const char *dir, const char *id)
v->per[t][i] = (uint16_t)be16(p + 2 * i);
v->nper[t] = n;
}
/* the speaker's usual period: the median of the recorded ones (the
* header's value is off for some voices) */
{
static int hist[401];
int total = 0, acc = 0;
memset(hist, 0, sizeof(hist));
for (t = 0; t < 2; t++)
for (i = 0; i < v->nper[t]; i++)
if (v->per[t][i] >= 20 && v->per[t][i] <= 400) {
hist[v->per[t][i]]++;
total++;
}
for (i = 20; i <= 400 && total; i++) {
acc += hist[i];
if (2 * acc >= total) {
v->nom = i;
break;
}
}
}
/* The units of each stream in order. Streams 2 and 4 hold the first
* halves (table 0), 3 and 5 the second halves (table 1); 4 and 5 the
* halves that are consonants, wave-phoneme 31 and up. */
@@ -129,10 +152,10 @@ static int pt_load(struct ptvoice *v, const char *dir, const char *id)
for (i = 0; i < PT_NW * PT_NW; i++) {
int ph = side ? i % PT_NW : i / PT_NW;
uint32_t a = v->tab[side][i][0];
if (a >= 0xffff || (ph >= 31) != cons)
if (a == 0xffff || a == 0xffffffff || (ph >= 31) != cons)
continue;
if (v->sec[2 + s] + 4 * a < v->sec[3 + s])
o[n++] = a * 4;
if (v->sec[2 + s] + (uint32_t)v->align * a < v->sec[3 + s])
o[n++] = a * v->align;
}
qsort(o, n, sizeof(*o), u32cmp);
v->unit[s] = malloc(sizeof(struct ptunit) * (n + 1));
@@ -159,6 +182,14 @@ static int pt_load(struct ptvoice *v, const char *dir, const char *id)
}
}
}
if (getenv("MACINTALK_DEBUG"))
for (s = 0; s < 2; s++) {
int lists = 0;
for (i = 0; i < v->nper[s]; i++)
lists += v->per[s][i] == 0xffff;
fprintf(stderr, "%s: stream %d: %d units, %d period lists\n", id, 2 + s,
v->nunit[s], lists);
}
/* the coded period length isn't in the header: find the one that fits */
for (i = 8; i <= PT_MAXN; i += 4) {
int fit = pt_fit(v, i);
@@ -203,7 +234,7 @@ static int pt_entry(struct ptvoice *v, int side, int l, int r, uint32_t *off)
if (a == 0xffffffff)
return -1;
if (a != 0xffff) {
*off = a * 4;
*off = a * v->align;
return 0;
}
l = b >> 16;
+4 -3
View File
@@ -13,7 +13,8 @@ writes the voices' data resources as plain files:
docs/macintalk-format.md)
OUT/<voice>.ttvw the voice's sampled sound, for the voices that
have one (Bells, Boing, Cellos ...)
from Mac OS 8.6, the PlainTalk voices (Agnes, Bruce, Victoria):
from Mac OS 8.6, the PlainTalk voices (Agnes, Bruce, Victoria, and
their high quality versions agnes-hq, bruce-hq, victoria-hq):
OUT/<voice>.gtss the recorded diphones (see docs/plaintalk-format.md)
Only data is read. Nothing from the disks is run, and Apple's code (the
@@ -148,6 +149,8 @@ def resources(fork):
def voice_id(name):
"""'Pipe Organ' -> pipe-organ, 'Agnes, high quality' -> agnes-hq"""
name = name.replace(", high quality", " hq")
return name.lower().replace(" ", "-")
@@ -165,8 +168,6 @@ def extract(hda, out):
if creator == b"mtk3": # MacinTalk 3
want = {"ttvd": "ttvd", "ttvw": "ttvw"}
elif creator == b"gala": # MacinTalk Pro (PlainTalk)
if "high quality" in name:
continue # coded differently; synth/macintalk can't read them yet
# 'gtss' 3 is the voice's recorded sound; 'gtss' 4 is code: left out
res = {k: v for k, v in res.items() if k == ("gtss", 3)}
want = {"gtss": "gtss"}
+6 -3
View File
@@ -34,9 +34,9 @@ Engines (a VOICE is engine:name, see --list):
by our own synthesiser, synth/macintalk, from Apple's voice data
(tools/fetch-macintalk.py gets it). $MACINTALK is its program,
$MACINTALK_VOICES the voice folder. Works with --live.
plaintalk The PlainTalk voices (Agnes, Bruce, Victoria), Apple's recorded
diphones joined by the same program, synth/macintalk. Works
with --live.
plaintalk The PlainTalk voices (Agnes, Bruce, Victoria, and their high
quality versions agnes-hq ...), Apple's recorded diphones
joined by the same program, synth/macintalk. Works with --live.
Needs ffmpeg and sox.
"""
@@ -173,6 +173,9 @@ PLAINTALK = {
"agnes": ("Agnes", "female"),
"bruce": ("Bruce", "male"),
"victoria": ("Victoria", "female"),
"agnes-hq": ("Agnes (high quality)", "female"),
"bruce-hq": ("Bruce (high quality)", "male"),
"victoria-hq": ("Victoria (high quality)", "female"),
}
last_request = [0.0]
+3
View File
@@ -75,8 +75,11 @@ Written by tools/voice_index.py. Every recording belongs to its original owner (
| `live-mssam-mike-tel` | Microsoft Mike for Telephone, live | tts | mssam synthesiser |
| `live-mssam-sam` | Microsoft Sam, live | tts | mssam synthesiser |
| `live-plaintalk-agnes` | PlainTalk Agnes, live | tts | plaintalk synthesiser |
| `live-plaintalk-agnes-hq` | PlainTalk Agnes (high quality), live | tts | plaintalk synthesiser |
| `live-plaintalk-bruce` | PlainTalk Bruce, live | tts | plaintalk synthesiser |
| `live-plaintalk-bruce-hq` | PlainTalk Bruce (high quality), live | tts | plaintalk synthesiser |
| `live-plaintalk-victoria` | PlainTalk Victoria, live | tts | plaintalk synthesiser |
| `live-plaintalk-victoria-hq` | PlainTalk Victoria (high quality), live | tts | plaintalk synthesiser |
| `live-sam-elf` | SAM Elf, live | tts | sam synthesiser |
| `live-sam-extra-terrestrial` | SAM Extra-Terrestrial, live | tts | sam synthesiser |
| `live-sam-little-old-lady` | SAM Little Old Lady, live | tts | sam synthesiser |
+21
View File
@@ -0,0 +1,21 @@
; Live voice for app_speakingclock (docs/voice-format.md), made by
; tools/synth_voices.py --live plaintalk:agnes-hq. Each sentence is spoken when
; it is needed, by synth/macintalk, run here (tts_program_macintalk).
; The synthesiser is ours; the voice data it reads is Apple's and is
; not in this repository (tools/fetch-macintalk.py downloads it); see NOTICE.md.
[voice]
name=PlainTalk Agnes (high quality), live
description=PlainTalk (MacinTalk Pro) voice, female, spoken live
mode=tts
sequence=speech+pips
period=10
[tts]
command={program:macintalk} -v agnes-hq -o {out} "{text}"
text=At the third stroke, it will be {hour} {minute} {seconds}.
[source]
engine=plaintalk
voice=agnes-hq
synthesiser=synth/macintalk (this repository, clean-room) joining Apple's recorded PlainTalk diphones (Mac OS 8.6), fetched by tools/fetch-macintalk.py
+21
View File
@@ -0,0 +1,21 @@
; Live voice for app_speakingclock (docs/voice-format.md), made by
; tools/synth_voices.py --live plaintalk:bruce-hq. Each sentence is spoken when
; it is needed, by synth/macintalk, run here (tts_program_macintalk).
; The synthesiser is ours; the voice data it reads is Apple's and is
; not in this repository (tools/fetch-macintalk.py downloads it); see NOTICE.md.
[voice]
name=PlainTalk Bruce (high quality), live
description=PlainTalk (MacinTalk Pro) voice, male, spoken live
mode=tts
sequence=speech+pips
period=10
[tts]
command={program:macintalk} -v bruce-hq -o {out} "{text}"
text=At the third stroke, it will be {hour} {minute} {seconds}.
[source]
engine=plaintalk
voice=bruce-hq
synthesiser=synth/macintalk (this repository, clean-room) joining Apple's recorded PlainTalk diphones (Mac OS 8.6), fetched by tools/fetch-macintalk.py
@@ -0,0 +1,21 @@
; Live voice for app_speakingclock (docs/voice-format.md), made by
; tools/synth_voices.py --live plaintalk:victoria-hq. Each sentence is spoken when
; it is needed, by synth/macintalk, run here (tts_program_macintalk).
; The synthesiser is ours; the voice data it reads is Apple's and is
; not in this repository (tools/fetch-macintalk.py downloads it); see NOTICE.md.
[voice]
name=PlainTalk Victoria (high quality), live
description=PlainTalk (MacinTalk Pro) voice, female, spoken live
mode=tts
sequence=speech+pips
period=10
[tts]
command={program:macintalk} -v victoria-hq -o {out} "{text}"
text=At the third stroke, it will be {hour} {minute} {seconds}.
[source]
engine=plaintalk
voice=victoria-hq
synthesiser=synth/macintalk (this repository, clean-room) joining Apple's recorded PlainTalk diphones (Mac OS 8.6), fetched by tools/fetch-macintalk.py