Issue
110, September 1999
Talking
Back: Adding Speech to Embedded Applications
by
Rodger Richey
Training
embedded apps to process speech may be as easy as
finding the right 8-bit micro. Don't let what Rodger
has to say about using an ADPCM algorithm and PWM
output to generate speech to go in one ear and out
the other.
WHAT
IS ADPCM?
ADPCM
is a waveform coding technique that attempts to code
signals without any knowledge about how the signal was
created. This implies that a waveform coder can be applied
to other forms of data besides speech (e.g., video).
In general, these coders are simple, with bit rates
above 16 kbps. Anything lower degrades the reconstructed
speech.
ADPCM
is based on two principles of speech. Because there
is a high correlation between consecutive speech samples,
a relatively simple algorithm could be used to predict
what the next sample might be, based on previous samples.
When
the predicted sample was compared to the real sample,
it was found that the resulting error signal had a lower
variance than the original speech samples and could
therefore be quantized with fewer bits. It was also
found that no side information about the predictor would
have to be sent if the prediction was based on the quantized
samples rather than on the incoming speech signal.
The
result was differential pulse code modulation, formerly
named ITU-T G.721. Further studies showed that if the
predictor and quantizer were made to be adaptive (i.e.,
that smaller samples are quantized using smaller steps
and larger samples with larger steps), then the reconstructed
speech more closely matched the original speech.
This
adaptation helps the speech processor handle changes
in the incoming speech signal more effectively. Thus
the creation of ADPCM standardized to be ITU-T G.726
and G.727. Figure 2 shows a block diagram of the encoder
and decoder portions of ADPCM. Notice that both the
encoder and decoder share the same quantizer and predictor.
Figure 2Because the decoder block
is embedded in the encoder, the ADPCM algoritm
does not need to send or store any additional
side information with the compressed data.
|
Most
DSP manufacturers can show some type of speech algorithm
that has been implemented for their architecture. Very
few 8-bit microcontroller manufacturers can say the
same due to the horsepower required to implement the
speech coding algorithms.
The
ADPCM algorithm discussed in this article was developed
by the now defunct Interactive Multimedia Association
(IMA) based on an Intel DVI variation of the standard
G.726. Normally, this algorithm is quite rigorous in
the computation category, but the IMA version reduces
the floating-point math and complex mathematical functions
to simple arithmetic and table lookups.
A
16-bit 2s complement speech sample is converted
into a 4-bit ADPCM code. The algorithm uses approximately
600 words of program memory and 13 bytes of data memory.
Almost any 8-bit microcontroller can implement this
algorithm thanks to the small amount of resources required.
The
source code gives the complete ADPCM encode and decode
routines written for use in Microchips assembler
(MPASM). The missing piece to the source code is that
for each message recorded or played, all the registers
(PrevSampleL, PrevSampleH, and PrevIndex) must be cleared.