docs: rewrite the voice and mssam format pages in Simplified Technical English

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRRR4BV2CBsQMqfrT6
Signed-off-by: Claude <noreply@anthropic.com>
This commit is contained in:
Claude committed 2026-11-14 10:34:48 +00:00
1 parent 89b81ec1de
commit 5ea936c3f3
2 files changed
+130 -100

No files matched your search

+64 -44
View File
@@ -1,14 +1,20 @@
# Microsoft Sam, Mike and Mary voice data
What synth/mssam reads, as we decoded it from the data alone. The voices
come in Microsoft's Speech API 4 TTS package `msttsl.exe` (SHA-1
d988cbb3e99bc9dd850defda939c06b81d9d4544), a cabinet holding `sam.vce`,
`male.vce` (Mike) and `female.vce` (Mary), and `male8.vce` and `female8.vce`, Mike and Mary for
telephone (`mike-tel`, `mary-tel`). Each `.vce` is an OLE compound
file with these streams: `Inventory`, `TreeImage`, `PhoneFile`, `Senone`,
`Cdb`, `VcHeader` (and `AltUnits` in Sam's). `tools/fetch-mssam.py`
writes `Inventory` as `<voice>.inv`, `Cdb` as `<voice>.tones`, and
`TreeImage` rewritten as `<voice>.tree`.
This page describes the data that synth/mssam reads. We decoded the
format from the data only. The voices come in the Speech API 4 TTS
package of Microsoft, `msttsl.exe` (SHA-1
d988cbb3e99bc9dd850defda939c06b81d9d4544). This package is a cabinet
that contains these files:
- `sam.vce`, `male.vce` (Mike) and `female.vce` (Mary).
- `male8.vce` and `female8.vce`, Mike and Mary for telephone
(`mike-tel`, `mary-tel`).
Each `.vce` is an OLE compound file with these streams: `Inventory`,
`TreeImage`, `PhoneFile`, `Senone`, `Cdb`, `VcHeader` (and `AltUnits` in
the file of Sam). `tools/fetch-mssam.py` writes `Inventory` as
`<voice>.inv` and `Cdb` as `<voice>.tones`. It converts `TreeImage` and
writes it as `<voice>.tree`.
## Inventory (`.inv`, little-endian)
@@ -18,18 +24,20 @@ writes `Inventory` as `<voice>.inv`, `Cdb` as `<voice>.tones`, and
u32 nunits, u32 size, (nunits+1) u32 offsets, then the units
The 6 line-spectrum codebooks have 256 entries of 3, 3, 3, 3, 4 and 4
values: one entry from each makes the 20 line spectral frequencies of a
frame (in cycles per sample). The excitation codebooks have 128 entries;
family A's 11 dims and family B's 13 dims each add up to 510, the points
of one pitch period scaled to a fixed length.
values. One entry from each codebook gives the 20 line spectral
frequencies of a frame (in cycles per sample). The excitation codebooks
have 128 entries. The 11 dims of family A add up to 510. The 13 dims of
family B also add up to 510. 510 is the number of points in one pitch
period, scaled to a fixed length.
The telephone voices are the same at 8000 Hz with order 12: 4 line-spectrum
codebooks of 3 values, and 10 excitation codebooks in each family (dims 12,
12, 16, 16, 16, 18, 24, 38, 46, 56, adding up to 254). Their unvoiced frame bytes
(147-238) do not fit as lengths at 8 kHz; mssam plays those frames as 5 ms,
which matches the units' recorded lengths (Senone) best.
The telephone voices are the same, at 8000 Hz with order 12. They have 4
line-spectrum codebooks of 3 values, and 10 excitation codebooks in each
family. The dims are 12, 12, 16, 16, 16, 18, 24, 38, 46 and 56, and they
add up to 254. Their unvoiced frame bytes (147-238) are not correct as
lengths at 8 kHz. Thus mssam plays those frames as 5 ms. This value
agrees best with the recorded lengths of the units (Senone).
A unit:
This is the layout of a unit:
u32 n frames
n frame headers voiced: 0x7f bytes (127 each) then a
@@ -44,37 +52,47 @@ A unit:
each later one: 13 family B indices,
the change from the previous period
Unvoiced frames are noise. Unit 0 is empty; unit k+1 is senone k.
Unvoiced frames are noise. Unit 0 is empty. Unit k+1 is senone k.
## TreeImage (big-endian)
A header with the path of the question file, then the questions (u32
count, then name\0 and a 64-bit mask each), then `\\...\TREE2\0`,
`tree\0`, u32 number of sounds n, n bytes (1: one state per sound), u32 n,
n u32 (where each sound's senones end, counted from n), u32 the number of
senones, then u32 total, 0, 18, 0xffffffff, the number of composite
questions q, then q pairs of 64-bit masks, 8 more bytes, and one tree per
sound.
The stream has these parts, in this sequence:
A mask holds sound i at bit (i + 36) mod 64, and the four word positions at
bits 32-35: begins a word, ends one, is a whole word, is inside one. A
composite question (left, right) is true when the sound before is in
`left`, this sound's word position is in `left`, and the sound after is in
`right`.
1. A header with the path of the question file.
2. The questions: a u32 count, then a name\0 and a 64-bit mask for each
question.
3. `\\...\TREE2\0` and `tree\0`.
4. A u32 number of sounds n, then n bytes (1: one state for each sound).
5. A u32 n, then n u32 values (the end of the senones of each sound,
counted from n).
6. A u32 number of senones.
7. A u32 total, 0, 18, 0xffffffff, and the number of composite
questions q.
8. q pairs of 64-bit masks, then 8 more bytes.
9. One tree for each sound.
A tree is u16 nodes, u16 leaves (nodes = 2*leaves - 1), then the nodes in
order, node 0 first:
A mask holds sound i at bit (i + 36) mod 64. It holds the four word
positions at bits 32-35: starts a word, ends a word, is a full word, is
inside a word. A composite question (left, right) is true when these
three conditions are true:
- The sound before is in `left`.
- The word position of this sound is in `left`.
- The sound after is in `right`.
A tree is u16 nodes and u16 leaves (nodes = 2*leaves - 1). Then the
nodes follow in sequence, node 0 first:
inner node u16 yes, u16 no, 0xffff, u16 question..., 0xffff
leaf 0xffff, u16 k, u16 k
An inner node goes to `yes` when any of its questions is true. Leaf k of
sound s is senone (the senones of the sounds before s) + k.
An inner node goes to `yes` when one or more of its questions is true.
Leaf k of sound s is senone (the senones of the sounds before s) + k.
PhoneFile lists the sounds in order, one per line (Sam: 52, Mike and
Mary: 58, with SILb and SILe for silence before and after).
PhoneFile lists the sounds in sequence, one on each line (Sam: 52, Mike
and Mary: 58). SILb and SILe are for the silence before and after.
`<voice>.tree` is the same in our own little-endian layout:
`<voice>.tree` has the same data in our own little-endian layout:
"MSSAMTR1", u32 sounds, u32 questions, u32 senones, u32 1
questions x (u64 left, u64 right) sound i at bit i, positions at 60-63
@@ -85,12 +103,14 @@ Mary: 58, with SILb and SILe for silence before and after).
## Senone
u32 count, then 28-byte records: the sound's name (4 bytes), u32 0, u32
the leaf number + 1, and four float32: the unit's mean length in ms, its
A u32 count, then 28-byte records. Each record has the name of the
sound (4 bytes), u32 0, u32 the leaf number + 1, and four float32
values. The four values are the mean length of the unit in ms, its
spread, and two energies.
## Cdb (`.tones`)
Text: pitch per tone, as `H (179) on: m=129= sd=34=; off: m=141= ...`, the
mean pitch in Hz where a vowel starts and ends. mssam uses `H` (accented),
`_` (plain), `h]` and `_]` (the last vowel of a phrase).
Text: the pitch for each tone, as
`H (179) on: m=129= sd=34=; off: m=141= ...`. The values are the mean
pitch in Hz at the start and at the end of a vowel. mssam uses `H`
(accented), `_` (plain), `h]` and `_]` (the last vowel of a phrase).
+66 -56
View File
@@ -1,16 +1,18 @@
# Voice format
A voice is a folder under `voicedir` (default
`<astdatadir>/sounds/speaking-clock` on Asterisk, `<sounds_dir>/speaking-clock`
on FreeSWITCH). The folder's name is the voice's id, the name you pass to
`SpeakingClock()` (or FreeSWITCH's `speakingclock`). app_speakingclock and
mod_speakingclock read the same voices. It holds a `voice.conf` and its clips.
A voice is a folder under `voicedir`. The default is
`<astdatadir>/sounds/speaking-clock` on Asterisk, and
`<sounds_dir>/speaking-clock` on FreeSWITCH. The name of the folder is
the id of the voice. You give this name to `SpeakingClock()` (or to
`speakingclock` on FreeSWITCH). app_speakingclock and mod_speakingclock
read the same voices. The folder contains a `voice.conf` and the clips
of the voice.
## Clips
Each clip is an 8 kHz, 16-bit, mono PCM `.wav` file. app_speakingclock skips
anything else, so `tools/build_voices.py` converts every clip to that format.
A clip's file name says what it holds:
Each clip is an 8 kHz, 16-bit, mono PCM `.wav` file. app_speakingclock
skips all other files. Thus `tools/build_voices.py` converts all clips to
that format. The file name of a clip tells what the clip contains:
| Clip | Says | Used by |
|---|---|---|
@@ -18,11 +20,11 @@ A clip's file name says what it holds:
| `its` | "It's" / "The time is" | `its` |
| `phrase` | "At the third stroke (it will be)" | `phrase` |
| `greet_morning`, `greet_afternoon`, `greet_evening` | "Good morning" ... | `greeting` |
| `n0` .. `n59` | a number said whole | `hour`, `minute` |
| `h1` .. `h12` | the hour, when it is said differently from the number (TIM: "it will be three") | `hour` |
| `n0` .. `n59` | a full number in one clip | `hour`, `minute` |
| `h1` .. `h12` | the hour, if the voice says it differently from the number (TIM: "it will be three") | `hour` |
| `hoc1` .. `hoc12` | "*n* o'clock" in one clip | `hour` on the hour |
| `noon`, `midnight` | | `hour` at 12:00 and 0:00 |
| `m1` .. `m59` | the minute, when it is said differently from the number (TIM) | `minute` |
| `m1` .. `m59` | the minute, if the voice says it differently from the number (TIM) | `minute` |
| `oh` | "oh", for minutes 1 to 9 ("four oh five") | `minute` |
| `oclock` | "o'clock", for minute 0 | `minute` |
| `f_twen`, `f_thir`, `f_for`, `f_fif`, `f_six`, `f_seven`, `f_eight`, `f_nine` | the first half of 13 to 19 and the tens | numbers that have no `n` clip |
@@ -35,13 +37,17 @@ A clip's file name says what it holds:
| `chime` | one strike of the hour | `strikes` |
| `hr1` .. `hr12` | a sound for each hour | `hourly` |
| `hourchime1`, `hourchime2` | top-of-hour chimes | `hourchime` |
| `x_*` | anything else the voice came with (alarms, dings, messages) | by name |
| `x_*` | all other sounds that came with the voice (alarms, dings, messages) | by name |
Numbers are built the way Steve's Talking Clock voices build them. A
number's `n` clip is used if there is one. Otherwise 13 to 19 are built from
a fragment plus `f_teen` ("thir" + "teen"). Twenty and above are built from
`f_twen` plus `f_ty3` ("twen" + "ty-three") when the voice has `f_ty`, and
from `n20` plus `n3` when it doesn't.
The module builds numbers in the same way as the voices of Steve's
Talking Clock:
1. If the number has an `n` clip, the module uses it.
2. If not, the module builds 13 to 19 from a fragment and `f_teen`
("thir" + "teen").
3. The module builds twenty and above from `f_twen` and `f_ty3`
("twen" + "ty-three") if the voice has `f_ty`. If the voice does not
have `f_ty`, it uses `n20` and `n3`.
## voice.conf
@@ -60,29 +66,30 @@ hours=12 ; or 24
```
- **mode** sets the defaults for `sequence` and `period`:
- `talking`: `intro+its+hour+minute+ampm`, every 10 s
- `tim`: `phrase+hour+minute+seconds+pips`, every 10 s
- `chime`: `quarter+strikes`, every 30 s
- `hourly`: `hourly`, every 10 s
- `tts`: `speech+pips`, every 10 s (see Live voices, below)
- **sequence** lists what to say, joined by `+`. It can use the words in the
table above (`intro`, `its`, `greeting`, `phrase`, `hour`, `minute`,
`seconds`, `ampm`, `pips`, `quarter`, `strikes`, `hourly`, `hourchime`) or
any clip by name (`x_exactly`). A missing clip is skipped. `pips` with no
`pips.wav` plays made-up pips: three 0.1 s, 1 kHz tones a second apart.
- `talking`: `intro+its+hour+minute+ampm`, each 10 s
- `tim`: `phrase+hour+minute+seconds+pips`, each 10 s
- `chime`: `quarter+strikes`, each 30 s
- `hourly`: `hourly`, each 10 s
- `tts`: `speech+pips`, each 10 s (refer to Live voices, below)
- **sequence** lists the items to say, joined by `+`. It can use the
words in the table above (`intro`, `its`, `greeting`, `phrase`, `hour`,
`minute`, `seconds`, `ampm`, `pips`, `quarter`, `strikes`, `hourly`,
`hourchime`) or a clip by name (`x_exactly`). The module skips a
missing clip. If there is no `pips.wav`, `pips` plays synthetic pips:
three 0.1 s, 1 kHz tones, one second apart.
- **period**: announcement *j* gives the time *j* × period.
- **marker**: where the time mark falls in `pips.wav`. With a marker, each
announcement is placed so that the mark lands on the exact second it
announces, as on the real machines. Without one, each announcement starts
on its second. For made-up pips the mark is the third pip.
`tools/build_voices.py` measures this from the clip (the onset of the last
pip).
- **marker**: the position of the time mark in `pips.wav`. With a marker,
the module aligns each announcement so that the mark comes on the exact
second that it announces, as on the real machines. Without a marker,
each announcement starts on its second. For synthetic pips, the mark is
the third pip. `tools/build_voices.py` measures this value from the clip
(the start of the last pip).
## Live voices (mode=tts)
A live voice has no number clips. Each announcement's sentence is spoken
whole, when it is needed, by a synthesiser program on the Asterisk or FreeSWITCH machine
(DECtalk, SAM).
A live voice has no number clips. A synthesiser program on the Asterisk
or FreeSWITCH machine (DECtalk, SAM) speaks the full sentence of each
announcement when the module must have it.
```
[voice]
@@ -96,27 +103,30 @@ command={program:dectalk} -fo {out} -a "[:np] {text}"
text=At the third stroke, it will be {hour} {minute} {seconds}.
```
- **command**: the program to run, split into words like a shell would
(with `"..."` and `'...'`), but run without one, so the text is always a
single argument. `{program:name}` becomes `tts_program_name` from
speakingclock.conf or speakingclock.conf.xml (else `name`, found on the PATH), `{text}` the text,
and an argument `{out}` a file for it to write the WAV to. Without `{out}`
the WAV is read from its standard output.
- **text**: what each announcement says. In words: `{hour}`, `{minute}`
("oh five", "o'clock" on the hour, "hundred" on a 24-hour clock),
`{seconds}` ("and twenty seconds", "precisely" on the minute), `{ampm}`
("A.M.", "P.M."), `{greeting}` ("Good morning"). In digits: `{H}`,
`{HH}`, `{M}`, `{MM}`, `{S}`, `{SS}`.
- **sequence**: `speech` is the sentence. Clips in the voice's folder can be
used as well (a `pips.wav`, an `intro.wav`).
- **command**: the program to run. The module divides it into words as
a shell does (with `"..."` and `'...'`), but it does not use a shell.
Thus the text is always one argument. `{program:name}` becomes
`tts_program_name` from speakingclock.conf or speakingclock.conf.xml.
If that setting is not there, it becomes `name`, found on the PATH.
`{text}` becomes the text. An argument `{out}` becomes a file, and the
program writes the WAV to that file. Without `{out}`, the module reads
the WAV from the standard output of the program.
- **text**: the words of each announcement. In words: `{hour}`,
`{minute}` ("oh five", "o'clock" on the hour, "hundred" on a 24-hour
clock), `{seconds}` ("and twenty seconds", "precisely" on the minute),
`{ampm}` ("A.M.", "P.M."), `{greeting}` ("Good morning"). In digits:
`{H}`, `{HH}`, `{M}`, `{MM}`, `{S}`, `{SS}`.
- **sequence**: `speech` is the sentence. You can also use clips in the
folder of the voice (a `pips.wav`, an `intro.wav`).
The program's WAV can be any PCM: 8 or 16 bits, mono or stereo, any rate.
The module converts it to 8 kHz, trims the silence around it and evens its
level, and keeps the last 128 sentences. A worker thread runs the program,
about 20 seconds before each sentence is due, so a call never waits on it.
An announcement whose sentence isn't ready in time plays the pips alone,
and a program that fails is tried again after 30 seconds. `tts_timeout`
(default 15 s) stops a program that hangs.
The WAV of the program can be any PCM: 8 or 16 bits, mono or stereo, at
any rate. The module converts it to 8 kHz, removes the silence before
and after it, and makes its level even. The module keeps the last 128
sentences. A worker thread runs the program about 20 seconds before the
module must have each sentence. Thus a call never waits for the program.
If a sentence is not ready in time, the announcement plays only the
pips. If a program fails, the module tries again after 30 seconds.
`tts_timeout` (default 15 s) stops a program that hangs.
`tools/synth_voices.py --live voices dectalk:<voice>` (or `sam:`) writes
these voices (`live-dectalk-*`, `live-sam-*`).