Silicon Chip – July 2019

(Frankie) #1

siliconchip.com.au Australia’s electronics magazine July 2019 45


Enter the Raspberry Pi Zero


These days, the Raspberry Pi 3B+
can be bought for around $60 plus
postage from several resellers. But the
Pi 3B+ is overkill for what we need.
So we’ve turned to a smaller
relative, the Raspberry Pi Zero.
Remarkably, the Raspberry Pi Zero can
be had for under $10 from Core Elec-
tronics (https://core-electronics.com.
au/raspberry-pi-zero.html).
It is actually a small form-factor vari-
ant of the earlier Raspberry Pi Model B.
Of course, there is a catch, and the
Raspberry Pi Foundation has limited
sales of the Raspberry Pi Zero to one
per customer.
The Raspberry Pi Zero also lacks
features such as WiFi or even a head-
phone socket.
The Pi Zero W adds WiFi, but is
still subject to the one per customer
limit. We tried to buy a Pi Zero and a
Pi Zero W at the same time and were
not allowed.
There is also the Pi Zero WH, which
adds WiFi and soldered headers to the
mix. There are no limits on the sale of
these, fortunately, although it does re-
tail for around $20, or twice the cost of
the basic Pi Zero. However, all of these
choices are excellent value for money.
To turn our Pi Zero (of whatever


flavour) into a Speech Synthesiser,
we need to get audio out and amplify
it, and for this, we’ve created a small
DAC and amplifier board to provide
direct stereo speaker drive.
Our DAC/amplifier board is the
same shape as a Raspberry Pi Zero and
sits directly above it. You’ll also need
some speakers and a microSD card to
create a finished, working Speech Syn-
thesiser, as well as some means of sup-
plying serial commands to the com-
pleted unit, so it knows what to say.
Advanced users could even pro-
gram the Raspberry Pi directly in a lan-
guage such as Python, but you would
need to be reasonably confident us-
ing a Linux command line. We have
also provided some code to allow an
Arduino board to control the Speech
Synthesiser.

Why try Pi?
The Raspberry Pi series of single-
board computers are astonishingly
cheap for what they are, and this pro-
ject would work with any current vari-
ant of the Raspberry Pi.
The larger models will result in a less
compact finished product, but would
provide a great way to experiment with
speech synthesis before committing to
buying another, smaller Pi.

The speech synthesis software we’re
using is an open-source project called
“espeak-ng” (see https://github.com/
espeak-ng/espeak-ng). It includes
many different languages and voices,
so it is perfect if you need speech in
English or just about any other lan-
guage.
You can download variants of es-
peak-ng for different operating sys-
tems, such as Windows, if you would
like to hear what it sounds like first.
You can find these downloads at: htt-
ps://github.com/espeak-ng/espeak-ng/
releases
Since the Pi Zero is capable of run-
ning a wide range of advanced soft-
ware, we’ve included some extra fea-
tures in our Speech Synthesiser.
We’ve also included another open-
source program, “madplay” (https://
sourceforge.net/projects/mad/files/
madplay/). It can decode and play
MP3 files, so if you also want to use
your Speech Synthesiser as a simple
sound effects module, you can do that.
If you have one of the WiFi-enabled
Pi variants, the Speech Synthesiser can
also become a very simple internet ra-
dio. Instead of playing a file, madplay
can decode and play an internet radio
station using a single command.
We developed the software for this

Fig.1: the circuit of the Raspberry Pi hat which adds the ability to drive two speakers. It can be used for speech synthesis
or general audio playback. Audio data comes from the Pi via header socket CON1 in I^2 S digital format and is fed to
DAC IC3. The analog audios signals are then coupled to amplifiers IC1 & IC2 and on to headers CON3 and CON4, which
connect to the speaker(s). The resistor shown in red is left off for 3.3V signal levels on CON2.

1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38

(^3940)
1
1
1
1
2
2
2
2
3
3
4
ÓSC 20 1 9
IC1
LM386N
IC1
LM386N
1
2
3
4
5
6
7
8
IC2
LM386N
IC2
LM386N
1
2
3
4
5
6
7
8
TO
LEFT
SPEAKER
TO
RIGHT
SPEAKER
100 mF
100 mF
100nF 100nF
WeSl
DATA
GND
Vdd
AoutR
AoutL
VrefO
BitCLK
IC3
TDA1 543
IC3
TDA1 543
1
2
3
4
5
6
7
8
10 mF
10 mF
CON5
CON3
CON4
LEFT
LINE OUT
RIGHT
LINE OUT
GND
1kW
1kW
1kW
10nF
10nF
+5V +5V
+5V
CON2
CON1
+5V
+5V
470 W
470 W
TXD
RXD
BitCLK
DATA
WS
TO/FROM
RASPBERRY PI
GND
GND
GND
(GND)
GND
GND
GND
(+3.3V)
(+3.3V)
(GP02)
(GP03)
(GP04)
(GP17)
(GP10)
(GP09)
(GP11)
(GP12)
(GP16)
(GP20)GP 21
(GP00)
(GP06)
(GP05)
(GP13)
(GP27)
(GP22) (GP23)
(GP24)
(GP25)
(GP08)
(GP07)
(GP01)
SPEECH SYNTHESISER/AUDIO PLAYBACK HAT FOR RASPBERRY PI
SERIAL

Free download pdf