cardiac-speech
CARDIAC learns to talk.
GitHub
Join us on Discord
Abstract
The standard methods of rule-based text-to-speech synthesis assume hardware multiplication and, typically, floating-point arithmetic. We demonstrate that they can be carried out on CARDIAC, a teaching computer whose only arithmetic is decimal addition and subtraction. The system borrows from the research behind the speech synthesizers of the 1980s, including DECtalk and the CallText 5010 that gave Stephen Hawking his voice, both based on Dennis Klatt’s MITalk [Garcia 2018]. We use the Naval Research Laboratory’s letter-to-sound rules [Elovitz 1976], Klatt’s segmental duration rules [Klatt 1979] and formant targets [Klatt 1980], and a linear-predictive lattice synthesizer [Markel and Gray 1976], followed by polyphase interpolation to 48 kHz [Crochiere and Rabiner 1983] and a band of frication above 4 kHz after the parallel branch of Klatt’s synthesizer [Klatt 1980]. Each method is recast in decimal integer arithmetic, with free constants chosen as powers of ten, which CARDIAC handles efficiently. Listening to the first 48 kHz version led to revisions that silence the pauses, sharpen the interpolation filter, add the high band, slow the speaking rate and clarify the consonants, with each matter of judgement decided by blind comparison. The system converts arbitrary English text to 48 kHz speech faster than real time, in less than a fifth of the time the speech lasts. We also compare a hand-built CARDIAC implementation with one compiled from Rust; both produce identical output, but the Rust implementation exposes weaknesses in the compiler that point toward further research.
1. Introduction
CARDIAC was designed to teach how a computer works, not to do work. Earlier projects in this collection have asked how far it can be pushed: a decoder that plays CD-quality audio (lubdub), and a ray tracer and a voxel renderer written in Rust and compiled for it. Speech synthesis is a harder test, because it joins symbolic processing, the matching of spelling rules against text, to sustained signal processing, a recursive filter that must produce thousands of samples a second.
The author has fond memories of playing with Texas Instruments’ Speak & Spell as a child, which led to an interest in this topic. The Speak & Spell spoke words recorded from a human speaker and stored in coded form [Edwards 2008]; the synthesizer described here uses no recordings.
We demonstrate a complete rule-based text-to-speech pipeline on CARDIAC, with no recorded speech (Figure 1). The contributions are a set of decimal adaptations of the published methods it follows; a resampler, also on CARDIAC, that raises the output to 48 kHz; the revisions that listening to that output called for, among them a band of frication above 4 kHz; and measurements of accuracy, spectral quality and cost, including a comparison of hand-written and compiled implementations. The samples below are the system’s final output. Section 2 reviews the methods the system draws on, Sections 3 to 5 describe the design as first built, at 8 kHz and then at 48 kHz, Section 6 the revisions, Section 7 the implementation, Section 8 the evaluation, and Section 9 its limitations.
Figure 1. The system as four stages of CARDIAC programs, with the counts for the README sentence. Each program reads one deck of cards and punches one stream of cards; the host (shaded) only moves cards, dealing, copying, collating and merging them in fixed orders and fetching table records by number (dashed), and does no arithmetic on the speech. Text becomes 101 phoneme cards in 25 programs, the phonemes become 380 frames of 13 cards in 43 programs, 11 programs turn the frames into 76,000 samples at 8 kHz (each two cards, thousands and units), and 7 programs resample them to 456,000 samples at 48 kHz. Counts from talk -v, --phonemes and --frames (both versions, heartburn); docs/pipeline.svg shows every program.
Samples
Each recording below was produced by the complete system from the text printed beneath it, with no recorded speech at any stage. The output is 16-bit audio at 48 kHz, resampled on CARDIAC from the voice box’s 8 kHz (Section 5.4), with a band of frication above 4 kHz added on CARDIAC (Section 6.3). The 8 kHz recordings of the same texts are given in Section 5.3, and the 48 kHz version as first built in Section 5.4, for comparison. The first is the opening passage of the CARDIAC manual, 41 seconds of continuous prose; the others are shorter quotations. Each text is printed exactly as it was given to the system; the full stops inside the two song quotations mark pauses, which the system makes at every full stop. The words “belong” and “survive” required entries in the exception list (Section 9).
CARDIAC reads its own manual
The opening of the CARDIAC manual, by David Hagelbarger and Saul Fingerman (Bell Labs, 1968)
Cardiac is an acronym for CARDboard Illustrative Aid to Computation. The key word here is “illustrative.” It means that Cardiac illustrates the operation of a computer without actually being a computer. In fact, it is not even a practical aid to computing. On the other hand, it is a very practical aid to understanding computers and computer programming. You’ll need this kind of understanding to keep up with the Computer Age you are about to enter. These are fast-moving times, and those who make no effort to understand computers may very well get left behind.
For millions of years
Stephen Hawking’s words in Pink Floyd’s Keep Talking (1994)
for millions of years, mankind lived just like the animals. Then something happened, which unleashed the power of our imagination. and we learned. to talk.
Keep talking
Pink Floyd, Keep Talking
It doesn’t have to be like this. All we need to do is make sure. we keep. talking.
All your base
Zero Wing (Sega Mega Drive, 1991)
All your base are belong to us. You have no chance to survive. Make your time.
2. Background
Speech synthesis by rule produces speech from text alone, with no recorded examples. The Naval Research Laboratory published letter-to-sound rules for English in 1976 [Elovitz 1976], and Dennis Klatt published rules for the duration of speech sounds [Klatt 1979] and formant targets for a synthesizer [Klatt 1980]. Klatt’s work at MIT became MITalk, and from it came DECtalk [Hallahan 1995] and the CallText 5010 that gave Stephen Hawking his voice [Garcia 2018]. Klatt reviewed the field as it stood in 1987 [Klatt 1987].
Linear predictive coding (LPC) models speech as an all-pole filter driven by a periodic source for voiced sounds and a noise source for unvoiced ones, with a new set of filter coefficients many times a second. Its lattice form, in which the filter is specified by reflection coefficients, is stable whenever every coefficient lies between −1 and 1 [Markel and Gray 1976]. This system takes its front end from synthesis by rule and its back end from LPC (Figure 2).
Figure 2. The published methods this system draws on (green, joined to it) and the synthesizers that came from Klatt’s work (grey). Klatt’s work at MIT, which includes his duration rules (1979) and formant targets (1980), became MITalk, and from it came DECtalk and the CallText 5010 that gave Stephen Hawking his voice (Garcia 2018; Hallahan 1995). This system takes the NRL letter-to-sound rules (Elovitz et al. 1976) and Klatt’s rules for its front end, and an LPC lattice (Markel and Gray 1976) and polyphase interpolation (Crochiere and Rabiner 1983) for its back end. It also uses Sacia and Beck’s powers of speech sounds (1926), Bresenham’s running remainder (1965) for the fall of the pitch and Kaiser’s window (1974) for the second resampling filter. Years are those of the paper’s references, and DECtalk’s is the Computer History Museum’s dating.
3. The machine
Each published method used here assumes a machine with multiplication, division and floating point. CARDIAC has none of them. It has a single conditional jump, on a negative accumulator, and 96 cells for a program and its data, each holding a signed three-digit decimal number. A ten-stage lattice filter performs twenty multiplications per output sample, the pitch period is a division, the duration rules multiply percentages, and an audio sample needs sixteen bits of range where a cell offers fewer than eleven.
CARDIAC has strengths of its own, and the design is built around them. It is a decimal machine, and SFT multiplies or divides by any power of ten in one instruction, exactly. STO keeps the last three digits of the four-digit accumulator, so it reduces a value mod 1000 and splits a number at a decimal digit for free. A program can execute the cards it reads, so a table of numbers can arrive as instructions. And the work can be spread over many machines, each running a small program, as a room of CARDIACs would. Each section below names the method it follows and the trade it makes, in the manner of lubdub, whose decoder established several of these techniques.
3.1 Designing in tens
lubdub’s step sizes are a single digit times a power of ten, the decimal counterpart of the power-of-two steps of binary ADPCM, because a power of ten costs CARDIAC one shift. The same choice recurs throughout this system, wherever a published method leaves a constant free. Synthesizers interpolate their parameters between frames, and the number of steps per frame is free. Here each 25 ms frame is ten steps of 20 samples, so the step from one frame’s value to the next, (next − this) / 10, is a single SFT (Figure 3). Glides between sounds are blended in tenths, duration factors are in hundredths, and reflection coefficients are stored in thousandths and cut to two significant digits, so that each digit is one jump into a row of ADDs. The excitation’s low-pass uses 0.5, five tenths, the de-emphasis 0.9, nine tenths, and the resonator of the high band 1.5 and 0.9. The noise generator works mod 1000, and the resampling filters’ coefficients are in thousandths. Where a binary design would choose a power of two, this one chooses a power of ten.
Figure 3. One reflection coefficient, K1, across two 25 ms frames of the README sentence, frames 108 and 109, in the AA of "was" (the pair of frames within a vowel with the largest change of K1 that is not a multiple of ten). Circles are the values on the frame cards the front end punched, and the green staircase is the value the voice box uses for each sample, as the ksteps program punched it. Each frame is ten steps of 20 samples. The first step holds the frame’s own value and each later step adds (next - this) / 10, formed by one SFT 01, which truncates toward zero. From 362 to 830 the step is 46 where the exact step is 46.8. The tenth step holds 776, and the next frame starts from its own card, 830. The dashed line is exact linear interpolation between the cards, for comparison. Data from talk --frames (heartburn) and from interp and ksteps run on ref/cardiac.py.
4. From text to frames
4.1 Text to phonemes
The letter-to-sound rules are the Naval Research Laboratory’s [Elovitz 1976]. Each rule names a group of letters, a left context and a right context, and the rules for a letter are tried in order until one matches. The contexts are written with symbols for classes of letters: a vowel, a consonant, a front vowel, a voiced consonant, a sibilant, and so on. The report assumes string matching. CARDIAC has no strings and no room for a rule interpreter of any generality.
The adaptation is in the encoding. Letters are given codes from 1 to 26 in an order chosen so that every class the rules name is a contiguous range of codes (Figure 4): A O U E I Y are 1 to 6, with the front vowels E I Y at 4 to 6, and the consonants follow so that the voiced consonants and the sibilants are ranges too. Every element of a context then reduces to a count and a range, and testing a letter against it is two subtractions and two conditional jumps. The rules are laid out as a table of one record per letter, which the host fetches by the letter’s code. Two programs test every rule’s left and right contexts (Figure 5), scanning outward from the letter in each direction; a third selects the first rule both accept; a fourth emits its phonemes. In all, 25 programs convert text to phonemes, including the expansion of numbers into words, with years from 1100 to 1999 read in pairs, and the lookup of function words and exceptions.
Figure 4. The letter codes of the text programs and the classes of the NRL rules. Letters are numbered 1 to 26 in the order A O U E I Y F H K P Q T S C X G J Z D L N R B M V W, so that each class a rule names is a range of codes; 27 is the apostrophe and 28 the edge of a word. The symbol above each column is the one the rules use (Elovitz et al. 1976), and the label under it its meaning; the blank matches the edge of a word or an apostrophe. The rules’ & and @ also match the pairs CH and SH (and @ also TH), which are written as separate rules. A rule’s ":" and "#" are counts on the same ranges (none or more consonants, one or more vowels). Testing a letter against a class is two subtractions and two conditional jumps. Ranges from ref/text_tables.py, which writes the rule decks.
Figure 5. A worked match of one NRL rule on the A of NAME in the README sentence. Above, the word as the text programs hold it, with an edge (28) on each side, and the rule that matched, ␣:[A]^+␣ = /EY/, its elements tested in turn. The left context is read leftwards from the letter before the bracket, and the right context rightwards from the bracket’s first letter. Each element is a count and a range of codes, and each test is the two comparisons shown. Below, the verdicts the left and right programs punched for each of the 34 rules of A at this letter (filled: the context matches); first chose rule 14, the first with both, outlined in red, and pick punched its phoneme EY. Data from the taps of talk on the README sentence (heartburn) and text/rules.cards.
4.2 Durations
Durations follow Klatt’s rules [Klatt 1979]. Each sound has an inherent duration Dinh and a minimum Dmin, and a percentage P, initially 100, is multiplied by a factor for each rule that applies: 140 before a pause, 85 for a vowel outside its word’s final syllable, and so on. The duration is (Dinh − Dmin) P / 100 + Dmin (Figure 6).
Klatt states the factors as percentages, which is the decimal machine’s native form. Each rule contributes a factor in hundredths, and a rule that does not apply contributes 100, so every sound produces the same number of cards and the deck’s layout never depends on the text. Multiplying by a factor is Horner’s rule over its three digits, each digit’s product formed by a jump into a row of ADDs and each step closed by SFT 01, which divides by ten exactly. The truncation at each step is part of the definition, and the reference implementation reproduces it. A factor for the speaking rate, added later, is described in Section 6.4.
Figure 6. The inherent duration in the phoneme table of each of the 78 sounds of the README sentence (open circles; Klatt 1979), against the duration the mul program computed for it, (D_inh - D_min) P / 100 + D_min, after the rules’ factors (filled). Sounds are listed in order down the left column and then the right, under the words they belong to; ˈ marks primary and ˌ secondary stress. Of the sounds, 11 are lengthened (green line) and 67 shortened (grey line). The longest, OW at the end of "Hello" before the comma, takes the factors 140, 80 and 120, and lasts 311 ms against its inherent 220 ms. Pauses are omitted. Data from what the feat, rules2, rules5, rules9 and mul programs punched (talk on the README sentence under heartburn) and front/features.cards.
4.3 Formants and the filter
Klatt’s synthesizer is a cascade of second-order resonators, one per formant [Klatt 1980]. Its coefficients are 2r cos(2πFT) and r2, with r = exp(−πBT), and a formant that glides needs them recomputed every update. CARDIAC cannot evaluate a cosine or an exponential at any useful rate. The synthesizer here therefore takes Klatt’s formant targets but not his resonators. Each target is converted once, offline, to the ten reflection coefficients of an LPC lattice [Markel and Gray 1976] and stored as a table of 41 phonemes’ filters. The computation does not depend on the text, so it belongs with the tables.
The lattice suits CARDIAC for a second reason. A lattice is stable whenever every reflection coefficient lies between −1 and 1, so a glide between two sounds can be made by blending their coefficients linearly, in tenths, with no risk of an unstable filter. A blended filter speaks more quietly than either of its ends, by as much as 13 dB, so a precomputed table of gain corrections, indexed by the two filters and the blend, restores its power (Figure 7). The relative power of each sound comes from Sacia and Beck’s measurements at Bell Laboratories [Sacia and Beck 1926]. Forty-three programs turn phonemes into frames of 25 ms, each frame thirteen cards: voicing, pitch period, amplitude and ten reflection coefficients.
Figure 7. Spectral envelopes of filters from the phoneme table. Each curve is computed here in floating point as one pulse passes through the excitation’s low-pass (voiced filters only), the ten-stage lattice with the table’s reflection coefficients and the de-emphasis 0.9, times the filter’s gain. (a) The start targets of IY, AA and UW and the noise filter of S, each with its own gain. (b) The glide in the README sentence with the largest level factor, at frame 74 (1.850 s). The frame’s own filter (R start) is moved towards halfway to its neighbour’s (AA end) with weight 5 tenths, by blending the reflection coefficients as the glideb program punched them. With the own filter’s gain the blend is 9.9 dB quieter than the own filter (dashed red); the glide table’s factor 311, fetched by gnorm, restores it (green). Data from front/filters.cards and front/glides.cards and the taps of glides, glideb and gnorm (talk under heartburn).
4.4 Pitch
The fundamental frequency falls from 130 Hz to 100 Hz, the fall Klatt gives for an isolated vowel [Klatt 1980], here stretched across a sentence. It rises by 15 or 7 percent at a stressed vowel, and moves toward 85 Hz for a statement or 160 Hz for a question. A declination of 30 Hz over a sentence of L frames is a division per frame. It is computed instead by Bresenham’s method [Bresenham 1965], which draws a line with a running remainder: 30 is added each frame, and L is subtracted as often as it fits (Figure 8). The pitch period, 8000 / f0 samples, is found by repeated subtraction, with 8000 held as thousands and units because it exceeds a cell.
Figure 8. The fundamental frequency of the README sentence, 8000 / P for each of its 338 voiced frames, from the pitch period P on the frame cards the front end punched (green; points 25 ms apart, at the frames’ centres). Shading marks the frames of vowels with primary stress (darker) and secondary stress (lighter), with each word named once above, where the rise program raises the pitch by 15 or 7 percent. The dashed line is the declination the decl program punched, 130 Hz falling towards 100 Hz across each sentence by Bresenham’s method; the second sentence starts again at 130 Hz. Each sentence ends with the fall towards 85 Hz. Data from talk --frames and the taps of feat, nframes and decl (heartburn).
5. From frames to sound
5.1 Excitation
A voiced frame is a single pulse every P samples through the one-pole low-pass e = pulse + 0.5 e, which softens the buzz of a bare pulse (Figure 9). The factor 0.5 is chosen because it is 5/10 in decimal: five ADDs and SFT 01. Unvoiced frames take a sign from the linear congruential generator x = 21x + 7 mod 1000. On a binary machine the modulus would be a power of two. On CARDIAC it is 1000 because STO performs the reduction, and 21x is 10x + 10x + x, a shift and two additions.
Figure 9. The excitation as the excite program punched it, one value a sample, for 20 ms in the middle of two sounds of the README sentence, the longest vowel and the longest voiceless fricative. (a) Voiced: a pulse of height A every P samples through the one-pole low-pass e = pulse + 0.5 e (formed as five ADDs and SFT 01, truncated toward zero), which leaves each pulse with a tail of halving values. (b) Unvoiced: +A or -A by the sign of x - 500, where x follows the generator x = 21 x + 7 mod 1000. P and A are those of the frame card; within a frame they move by tenths of the change to the next. Data from interp, steps and excite run on ref/cardiac.py on the frame cards of talk --frames; the values equal ref/voice_ref.py’s and the programs’ instruction counts equal heartburn’s.
5.2 The lattice
Each stage of the ten-stage lattice computes f = f − k b and b′ = b + k f. The multiplications follow lubdub’s decoder, which multiplies by a step of one digit times a power of ten by jumping into a row of nine ADD instructions and shifting. Here each coefficient is reduced to two significant decimal digits and a sign, and a program upstream emits it as five cards that are themselves instructions: an ADD or SUB that sets the sign, a jump into the row of ADDs for each digit, a final shift, and a rounding constant. The lattice programs read these cards into their own multiply routines (Figure 11). The routine is rewritten every 20 samples, and a multiplication costs one instruction per addition and no tests. The ten stages are divided over five programs of two stages each, with f passed down and b passed back up (Figure 10).
Figure 10. The ten-stage lattice as five CARDIAC programs of two stages each (dashed). The forward value f passes down the left rail and the backward value b up the right; stage i computes f(i-1) = f(i) - k(i) b(i-1) and b(i) = b(i-1) + k(i) f(i-1), where b(i-1) is from the sample before (z⁻¹). Stage 10’s b is never used, so L1 does not compute it. Between programs each sample crosses as two cards (marked in red at the first boundary): f down to the program below, and b back up to the program above for the next sample. Each program also reads ten coefficient cards every 20 samples, five for each of its stages. Wiring from src/voice.rs and voice/lattice_top.cq, lattice.cq and lattice_bottom.cq.
Figure 11. The cells of one lattice program, voice/lattice.cq (L2, L3 and L4 run it), which fills 93 of the 97 cells a program has. The row of nine ADDs is cells 90 to 98, and it runs on into cell 99, where the JMP into it leaves the way back. The ten coefficient cards of each 20-sample step are read straight into the two multiply routines (orange, cells 47, 50, 52, 55, 63, 66, 68, 71, 75, 76). For each stage they are the sign word (±, ADD t or SUB t), the two jumps into the row for the coefficient’s digits (d2, d1), the final shift (SFT) and the rounding half (½), so the routines are rewritten every step. Cells and roles read from the listing; drawn by runcardiac’s memmap.py.
5.3 Output at 8 kHz
The voice box runs at 8 kHz, the telephone band for which a ten-coefficient LPC model is designed. These are the same four texts as above, as the voice box produces them:
CARDIAC reads its own manual
One defect is audible. Played in a browser, 8 kHz audio is resampled to the device’s rate, and the resampling leaves images of the spectrum above 4 kHz, heard as tones over the voice (Figure 12).
Figure 12. Spectrogram of the README sentence as the voice box produces it at 8 kHz, played at 48 kHz by repeating each sample six times, the simplest way a player can raise the rate. Repetition leaves images of the speech band reflected about every multiple of 8 kHz, so everything above 4 kHz (red line) is an artefact heard as tones and hiss over the voice. Hann windows of 1,024 samples (21 ms) every 240 samples (5 ms); levels relative to the loudest point of this figure and the next spectrogram. Data from talk (heartburn).
5.4 Resampling on CARDIAC
Raising the rate is a standard problem of multirate signal processing: insert zeros between samples and remove the images with a low-pass filter, computing only the outputs that are not zero, which is the polyphase form [Crochiere and Rabiner 1983]. A factor of six is cheaper in two stages than in one, because only the first stage needs a sharp transition. Resampling on the host would be arithmetic on the speech, so seven more CARDIAC programs perform it.
The first stage doubles the rate with a least-squares low-pass. As first built it had 39 taps, within 0.4 dB of flat to 3 kHz, 1.3 dB down at 3.3 kHz, 37.7 dB down at 4 kHz and at least 52.7 dB down from 4.5 kHz. The second stage triples the rate with a 19-tap sinc under a Kaiser window [Kaiser 1974], at least 41.9 dB down from 12 to 24 kHz. A sinc cut at a third of the band is zero at every third tap from its centre, so one of its three phases is the input sample itself and costs nothing to compute. The coefficients are designed offline and supplied in thousandths. Three decimal digits make each multiplication Horner’s rule over three rows of ADDs, as in the lattice, with each tap’s five instruction cards prepared once by two programs before the speech begins. The running sum exceeds a cell and is kept as thousands and units. Every 48 kHz sample matches a reference implementation of the same integer arithmetic.
These are the four texts as this first 48 kHz version spoke them, before the revisions of Section 6:
CARDIAC reads its own manual
The images are gone, and other defects become audible. Some pauses are not quite silent. The consonants are dull, and the S sounds are weak enough that “for millions of years” can be heard as “for millions of year”. At Klatt’s rate the short syllables of long words, as in “Illustrative Aid to Computation”, run together, and some consonants are misheard. The P of “computation” sounds like a B, and “cardboard” like “cod bod”.
6. Revisions after listening
Each defect of Section 5.4 was traced to a cause and corrected in the CARDIAC programs, in the Rust programs where they exist, and in the reference implementations alike. Where a correction left a choice to be made by ear, renderings with and without it, or at several settings, were compared blind, the listener not knowing which was which. The revisions lengthen the speech and raise its cost; the samples at the top of the page include all of them, and Sections 8 and 9 give the measurements for the system as it now stands.
6.1 Limit cycles in pauses
Fixed-point recursive filters are prone to zero-input limit cycles, and the lattice had them. A pause keeps the filter of the sound before it, and with rounding, values of 1 to 3 circulated through the stages as a steady tone, in 207 of 210 silent frames of one long passage. Truncating toward zero in silent steps, and rounding elsewhere, stopped most of them but not all. In the first 48 kHz version, some pauses in the opening passage of the CARDIAC manual still held steady tones between 1,333 and 2,667 Hz.
The remedy uses CARDIAC’s shift directly. In any step whose amplitude is 0, a pause or a stop’s closure, the reduce program now sends the lattice the cards of k = 0 for every coefficient. Its four instruction cards are SFT 00, a shift by 100 that changes nothing, and its rounding half is 0, so that every product is exactly 0. The lattice then passes its input straight through, and the output is exactly zero within at most 31 samples, whatever filter came before. SFT 00 is one instruction where a jump into the row of ADDs for a digit of 0 is two, and reduce skips its own work in silence, so the change also removes 3.2 million instructions, 7 percent of the 8 kHz pipeline’s, from the sentence of Section 8.3 as it was then spoken.
6.2 A sharper first stage
Part of the dullness of the consonants came from the first resampling stage. The 39-tap filter was 1.3 dB down at 3.3 kHz and 6 dB down at 3.53 kHz, so it removed much of the band from 3.3 to 4 kHz, where the bursts of stops and the fricatives carry energy, and the 48 kHz speech had 1.2 dB less power than the 8 kHz speech it was made from. The first stage is now a 159-tap least-squares low-pass [Crochiere and Rabiner 1983], within 0.3 dB of flat to 3.8 kHz, 40.0 dB down at 4 kHz and at least 48.2 dB down from 4.5 kHz (Figure 13). Its stopband begins at 4 kHz itself, because the image of a component at f lands at 8 kHz − f, and the narrow transition from 3.82 to 4 kHz is what costs the taps. The filter now removes 0.2 dB of the speech’s power.
Rounding the coefficients to thousandths raises a second problem. In a polyphase interpolator each phase computes every other output sample, and if the two phases’ coefficients sum to different values, a constant input comes out alternating, an image at 8 kHz of the lowest frequencies. The 39-tap filter’s phases summed to 0.986 and 0.982. In the new design the least-squares solution is constrained, by Lagrange multipliers, to give each phase the same sum, and after rounding the taps are adjusted by single thousandths, at the centre or in symmetric pairs, until each phase sums to exactly 1000. The second stage’s three phases sum to exactly 1000 as well. Because the coefficients are thousandths, unit gain is an integer, and the rounding can be made to meet it exactly.
The longer filter costs most of the system’s time. The first stage’s work rose from about 1,100 to 4,019 instructions per 8 kHz sample, and the real-time factor of the 48 kHz version from 0.073 to 0.175. Figure 14 gives the resulting spectrogram.
Figure 13. The frequency responses of the two resampling filters, computed from the coefficients in thousandths that the CARDIAC programs read (upsample/tables/fir1.cards and fir2.cards, which equal ref/up_table.py’s design), each divided by its gain. (a) Stage 1, the 159-tap least-squares low-pass at 16 kHz, is within 0.3 dB of flat to 3.8 kHz, 40.0 dB down at 4 kHz and at least 48.2 dB down from 4.5 kHz. (b) Stage 2, the 19-tap Kaiser-windowed sinc at 48 kHz, is at least 41.9 dB down from 12 to 24 kHz. (c) The two together, stage 1’s response repeating every 16 kHz at the 48 kHz rate. The dashed line marks 4 kHz, the top of the 8 kHz speech band.
Figure 14. Spectrogram of the README sentence as the 48 kHz version produces it, resampled by the seven CARDIAC programs, for comparison with the previous spectrogram, with the same analysis and the same reference level. For this sentence the energy from 4 to 24 kHz (above the red line) is -44.6 dB relative to 0 to 4 kHz, against -7.0 dB for the previous spectrogram (measured as in Figure 16), and most of what remains is the noise of the arithmetic’s rounding and truncation rather than images. Data from upsample/target/release/talk --no-hiband and talk --8k (heartburn).
6.3 A high band for the fricatives
Speech computed at 8 kHz has nothing above 4 kHz, where much of a fricative’s energy lies. The voice box’s noise filters are fitted to Klatt’s spectra below 4 kHz, so the hiss of an S is pushed against the edge of the band, and even the sharper first stage leaves a word-final S or Z with little. Klatt’s synthesizer gives its fricatives their high frequencies through its parallel branch [Klatt 1980], in which a frication source drives the formant resonators F2 to F6 side by side, each at its own amplitude, together with a bypass that passes the source on flat. S and Z excite only F6, a resonance at 4,900 Hz, 1,000 Hz wide.
Three more CARDIAC programs add a band of frication to the 48 kHz output, worked out from the text. For each frame the host fetches a level by the number of the filter the frame speaks through, from a table that is 0 for every filter but the fricatives’ noise filters, so vowels, sonorants and pauses receive no high band at all. The hnoise program ramps the level across the frame in ten steps, as the voice box ramps its amplitude, and emits +L or −L by the sign of the same decimal generator, x = 21x + 7 mod 1000. At 48 kHz its 1,000 values would repeat every 21 ms, a 48 Hz buzz in the hiss, so at the start of each step the generator is moved on by a second value that runs through the same generator once a step. The hfilt program shapes the noise with three zeros at 0 Hz and two at 24 kHz, eight additions and subtractions, and two poles, y = e + 1.5y1 − 0.9y2, a resonance at 5.0 kHz, 0.8 kHz wide, close to Klatt’s F6. Klatt specifies a resonator by its frequency and bandwidth, which give coefficients that CARDIAC would have to multiply digit by digit. Here both coefficients are tenths, so that 1.5y1 is y1 + 5y1 / 10 and 0.9y2 is 9y2 / 10, rows of ADDs each closed by one SFT 01, and the resonance they give falls close to Klatt’s. The hmix program adds the band to each 48 kHz sample, and the host deals 245 blank cards ahead of it so that the band lines up with the frames it was made for, behind the delay of the two resampling stages.
The levels were first set from Klatt’s Table III. For each voiceless fricative and each burst, his frication spectrum gives the ratio of its energy from 4 to 8 kHz to its energy below 4 kHz, and the level was set so that the high band’s energy bears that ratio to the speech’s own energy below 4 kHz, measured over twelve texts. A voiced fricative took its voiceless cognate’s level 10 dB down, after Klatt’s weaker frication source for voiced sounds. At those levels the high band sounded like static. In a blind comparison of the fricatives’ band at full, half and a quarter of these levels, with none on the stops’ bursts, a quarter was clearest, and the table keeps a quarter of each fricative’s level and gives the bursts none. The table is computed offline, since Klatt’s spectra need exponentials and none of it depends on the text. With it, the energy above 4 kHz is −26.7, −29.0 and −29.0 dB relative to 0 to 4 kHz for the three texts of Section 8.2, where the resampler alone leaves −45.4, −43.9 and −43.5 dB. In vowels and pauses hnoise and hfilt pass zeros for 6 and 15 instructions a sample, and the band costs 4 percent of the system’s instructions.
6.4 Speaking rate
At the durations Klatt’s rules give, the short syllables of long words were hard to follow. A speaking-rate factor in hundredths, a single card, now multiplies every segment’s duration after Klatt’s formula, pauses included, so that the duration is ((Dinh − Dmin) P / 100 + Dmin) R / 100. Of the rates 100, 110 and 115, 115 was clearest by ear. The factor scales the whole duration rather than joining the rule factors in P, because in P it would stretch only the part above the minimum, and the sounds that are hard to follow are those the rules have already pushed toward their minimum, the unstressed syllables in the middle of a long word. In “illustrative” the R stays at 18 ms with the factor in P, and becomes 20 ms when it scales the whole duration. A percentage is again the machine’s native form, and the multiplication is the same three-digit Horner multiply that mul already performs, about 40 instructions a segment. The rate lengthens the speech by 14 percent, and a full stop’s pause of 600 ms becomes 690 ms, as a speaker who slows down also pauses longer.
6.5 Consonants
The changes to the consonants were chosen by blind comparison of renderings with and without them. Klatt’s duration for a stop is its closure, and the burst had taken the closure’s last frame, so that a stop of two frames was closed for only 25 ms and “computation” was hard to follow. Each stop’s burst now has a frame of its own after the closure, and the nframes program moves the time on by that frame, so that the sounds after the stop keep their frames. The bursts’ filter gains were also doubled, a rise of 6 dB.
P, T and K breathe out over the first frame of the sound after them. A sonorant of a single frame after them, such as the Y of “computation” or the R of “illustrative”, had gone straight to voicing, and the P of “computation” sounded like a B. Such a sonorant now speaks its one frame voiceless, as English devoices the R of “tree”.
The first and last frames of a sound glide halfway toward its neighbours. A sound of two frames now glides only its first frame, and its second holds its own target. When both frames glided, a short R never reached its low third formant, the frames staying near 1,680 Hz against R’s 1,360 Hz, and “cardboard” sounded like “cod bod”.
Two pronunciations were corrected in the exception list. CARDIAC is now K AA1 R D IY2 AE2 K. The secondary stress on its IY keeps that vowel’s full minimum duration, long enough to hold a syllable of its own, CAR-dee-ack rather than car-dyak. The rules read the COOP of “cooperate” as one syllable, so “cooperate” and five of its forms are now exceptions.
The burst frames lengthen the speech further, by 2 to 7 percent on the four sample texts and 6 percent on the sentence of Section 8.3. With the slower rate, the opening passage of the manual grew from 33.7 to 41.2 seconds.
One trait of the voice was kept on purpose. It has the slightly nasal character of LPC speech.
7. Implementation
7.1 The host
The host performs five operations, all of them bookkeeping on cards (Figure 15): it deals a pile to several machines in turn, copies a pile to several machines, collates fixed columns of records, merges piles in a fixed order, and fetches a table record named by a card, as a librarian fetches a book by its call number. No operation depends on a card’s value except the fetch, which uses it only as a record number. The precomputed material is limited to the phoneme filter table, a table of gain corrections for gliding between filters, the two resampling filters and the high band’s levels. The rule and word decks are transcriptions, not computations.
Figure 15. The five operations of the host, each with one of its uses in this system. (a) It deals cards a fixed number at a time to several decks in turn. (b) It copies every card put on a pile onto several decks. (c) It collates whole records from fixed columns of several piles. (d) It merges several piles, taking a fixed number of cards from each in a fixed order, each pile waiting its turn. (e) It fetches the record of a table deck that a card names and puts that record in a deck, as a librarian fetches a book by its call number; record 48 is the first that gnorm asked for in the README sentence. None of the operations depends on what a card says, except the fetch, which uses it only as a record number. Uses from src/net.rs, src/front.rs, src/voice.rs and upsample/src/lib.rs.
8. Evaluation
8.1 Exactness
Each stage has a reference implementation in Python that performs the same integer arithmetic. The text programs agree with the reference on all 937 test texts, the frame programs on all 23 test sentences, frame for frame and sample for sample, and the voice box on four test passages. The 48 kHz output agrees with its reference on seven texts, with and without the high band, and so do the 8 kHz samples beneath it; it also agrees on four longer passages, 3,322,800 samples at 48 kHz. The hand-written and Rust implementations of the 8 kHz pipeline produce identical samples.
8.2 Images above 4 kHz
| Text | Energy above 4 kHz, CARDIAC resampler | Each sample repeated six times |
| All your base | −45.4 dB | −7.1 dB |
| Keep talking | −43.9 dB | −6.8 dB |
| For millions of years | −43.5 dB | −6.8 dB |
Energy from 4 to 24 kHz is given relative to 0 to 4 kHz, for the resampler alone, without the high band, which puts energy there on purpose (Figure 16). Most of what remains above 4 kHz is the noise of the arithmetic rather than images. Each 16 kHz sample is rounded to a whole unit so that it passes between the two stages on one card, and each product is truncated to tenths by its shifts; for “All your base”, the figure would be −47.8 dB with the 16 kHz samples unrounded, and −53.4 dB with the products exact as well, which is what the filters themselves leave with their coefficients in thousandths. With the 39-tap first stage the figures were −46.6, −45.0 and −44.7 dB: the sharper filter leaves slightly more noise, from its four times as many truncated products, and passes 1.0 dB more of the speech.
Figure 16. Images above 4 kHz. (a) The power spectrum of "All your base" averaged over the whole utterance (Hann windows of 4,096 samples, half overlapping), for the 48 kHz output of the CARDIAC resampler and for the same 8 kHz samples each repeated six times; shading marks 4 to 24 kHz, where the 8 kHz speech has nothing. (b) The energy from 4 to 24 kHz relative to 0 to 4 kHz for the paper’s three sample texts, as in the table of Section 8.2, which is -45.4, -43.9, -43.5 dB for the resampler (green) against -7.1, -6.8, -6.8 dB for repetition (grey). Measured by ref/up_measure.py on the output of upsample/target/release/talk --no-hiband and talk --8k (heartburn).
8.3 Cost
Instruction counts for the sentence “Hello, my name is cardiac and I was born in 1968 to D W Hagelbarger. And now I can talk.”, 9.50 seconds of speech (Figure 17):
| Stage | Programs | Instructions | Per second of speech |
| Text to phonemes | 25 | 877,616 | 0.09 million |
| Phonemes to frames | 43 | 2,665,333 | 0.28 million |
| Voice box, 8 kHz | 11 | 48,788,796 | 5.14 million |
| Resampling to 48 kHz | 7 | 375,023,790 | 39.5 million |
| High band | 3 | 18,505,649 | 1.95 million |
| Total | 89 | 445,861,184 | 46.9 million |
The lattice alone accounts for 79 percent of the 8 kHz pipeline, the resampler for 84 percent of the whole, and the first resampling stage for 81 percent of the resampler. On heartburn, running all 89 programs in turn on one core of an Apple M5 Ultra, the sentence takes 1.73 seconds, a real-time factor of 0.18. Without the high band it takes 1.67 seconds, and the 8 kHz pipeline alone takes 0.091 seconds, a real-time factor of 0.010.
Figure 17. CARDIAC instructions per second of speech for each stage, for the README sentence (9.50 s of speech; 427,355,535 instructions in all, loading included). The darker part of each bar is the programs that multiply by jumping into a row of ADDs. In the voice box they are the five lattice programs, 85 percent of its instructions and 79 percent of the whole 8 kHz pipeline’s, and in the resampler the two filter programs. Counts from talk -v --no-hiband of the 48 kHz version under heartburn.
8.4 Hand-written and compiled programs
The 8 kHz pipeline exists in two implementations that produce identical samples. The first is written by hand in CARDIAC assembly. In the second, 83 of 89 programs are written in Rust and compiled with rust-cardiac; the lattice and output stage remain hand-written. A Rust lattice that multiplies by table lookup runs 1,004 instructions per sample against 551 for the hand-written one, because Rust cannot express a program that executes the instructions it reads. The port exposed seven inefficiencies in the compiler, since fixed on its main branch, and one construct it refuses. In one program the compiler outperformed the hand-written code: for the pitch period it biases a loop counter by one, so that its test is a single conditional jump, and takes 11 instructions per iteration where the hand-written loop takes 12. The Rust implementation’s README gives the measurements.
9. Discussion and limitations
Four tables are computed offline in floating point. They hold the 41 phonemes’ reflection coefficients, the gain corrections for gliding between filters, the resampling filters’ coefficients and the high band’s levels. None depends on the text. Everything that does is computed on CARDIAC.
The front end inherits the weaknesses of letter-to-sound rules. Words the rules mispronounce need entries in the exception list, which grows as new texts expose them; “belong” and “survive” were added for the samples above, and “cooperate” and its forms after the rules split them wrongly. A word written in capitals is spelled out, which is right for MTV and wrong for CARDIAC, so the manual passage above is given to the system with “Cardiac” in place of “CARDIAC”. Words are cut at 13 letters.
The voice is that of a ten-coefficient LPC model at 8 kHz, with a 4 kHz band, and resampling cannot add to it. Above 4 kHz the only content is the high band, noise shaped by one fixed resonance, present only in the fricatives; the stops’ bursts and the voiced sounds have nothing there. The resampler requires the de-emphasised signal to stay within a cell, a limit the output stage itself does not have; the test passages peak at 621 against a limit of 999.
The revisions of Section 6 that were matters of judgement, the high band’s level, the speaking rate and the changes to the consonants, were judged by a single listener. The comparisons were blind, but a panel of listeners and an intelligibility test would be needed to establish that each change helps listeners in general.
The cost is dominated by multiplication. The lattice takes 79 percent of the 8 kHz pipeline and the resampler more than five times everything else. Both rely on the row-of-ADDs technique, and neither can be expressed in Rust as it stands, because a compiled program cannot execute the instructions it reads.
10. Conclusion
A machine without multiplication, division or floating point can synthesize intelligible speech from arbitrary text, by rule, faster than real time even at 48 kHz, provided each method is recast in decimal terms. The recasting follows one principle throughout: where a published method leaves a constant free, choose a power of ten, and where it multiplies, let the multiplier arrive as instructions. The same principle produced the audio decoder this work builds on, and it is likely to serve any further signal processing on CARDIAC.
References
- B. Edwards, “VC&G Interview: 30 Years Later, Richard Wiggins Talks Speak & Spell Development”, Vintage Computing and Gaming, 2008. vintagecomputing.com
- H. S. Elovitz, R. W. Johnson, A. McHugh and J. E. Shore, “Automatic Translation of English Text to Phonetics by Means of Letter-to-Sound Rules”, NRL Report 7948, Naval Research Laboratory, 1976. archive.org
- D. H. Klatt, “Review of text-to-speech conversion for English”, Journal of the Acoustical Society of America 82(3), 737–793, 1987. doi:10.1121/1.395275
- D. H. Klatt, “Synthesis by rule of segmental durations in English sentences”, Proceedings of the 9th International Congress of Phonetic Sciences, Copenhagen, 1979, pp. 290–297. coli.uni-saarland.de
- D. H. Klatt, “Software for a cascade/parallel formant synthesizer”, Journal of the Acoustical Society of America 67(3), 971–995, 1980. fon.hum.uva.nl
- C. Garcia, “Bringing A New Voice to Genius—MITalk, the CallText 5010, and Stephen Hawking’s Wheelchair”, Computer History Museum, 26 March 2018. computerhistory.org
- W. I. Hallahan, “DECtalk Software: Text-to-Speech Technology and Implementation”, Digital Technical Journal 7(4), 1995. zx.net.nz
- J. E. Bresenham, “Algorithm for computer control of a digital plotter”, IBM Systems Journal 4(1), 25–30, 1965. computerhistory.org
- R. E. Crochiere and L. R. Rabiner, Multirate Digital Signal Processing, Prentice-Hall, 1983.
- J. F. Kaiser, “Nonrecursive digital filter design using the I0-sinh window function”, Proceedings of the IEEE International Symposium on Circuits and Systems, 1974, pp. 20–23.
- J. D. Markel and A. H. Gray, Jr., Linear Prediction of Speech, Springer-Verlag, 1976.
- C. F. Sacia and C. J. Beck, “The Power of Fundamental Speech Sounds”, Bell System Technical Journal 5(3), 393–403, 1926. archive.org