Silicon Chip – July 2019

(Frankie) #1

50 Silicon chip Australia’s electronics magazine siliconchip.com.au


a serial UART interface. We used an Arduino Leonardo mi-
crocontroller board, as it has two serial ports; one is a vir-
tual serial port connected to the USB interface while the
other is a hardware-based serial port which is connected
to a pair of accessible I/O pins.
Initially, we’ll just use the Leonardo as an interface be-
tween your PC and the Raspberry Pi for testing purposes.
Later, you can program the Leonardo to trigger speech and
sounds by itself.
Start by programming the Leonardo with our “USB-Seri-
al_for_Leonardo” sketch (also available for download from
the SILICON CHIP website).
This makes the Leonardo equivalent to a simple USB/
serial converter. It won’t work on Uno boards, as they only
have one hardware serial port.
If you don’t have a Leonardo, any other Arduino board
based on the ATmega32U4 microcontroller should work.
For example, you could use a small “Beetle” board, like
the one we used for PC Remote Control Interface in the
August 2018 issue (see siliconchip.com.au/Article/11196).
Connect the Leonardo as shown in Fig.4. This allows it
to supply 5V to the Raspberry Pi board. While there will
inevitably be a voltage drop across the jumper wires sup-
plying current to the Pi, we did not find this to cause any
problems.
If you do find you have power problems on the Pi, or
noise in the audio, you may be able to solve this by pow-
ering the Pi directly using its own micro USB socket and
an external USB plugpack.
In this case, don’t connect the 5V supply wire. The Ar-
duino board can still get its power from the computer.
Another option for the test procedure is to use a CP2102
USB/serial converter.
To do that, simply wire up the converter to CON2 on the
hat, but note that you will need to leave out or remove the
1k resistor at upper right as these devices operate with
3.3V signalling levels.


Terminal software


While it’s possible to use the Arduino serial monitor to
communicate with the Pi via the Arduino, other terminal
programs such as PuTTY or TeraTerm have better terminal


emulation support which suits the Raspberry Pi interface.
In particular, if you wish to do any file editing on the
Pi (which may be necessary to enable specific settings), a
proper terminal program is mandatory.
Regardless of which terminal software you use, you will
need to connect to the Pi at 115,200 baud with eight bits
and no parity (8-N-1).

Generating speech
If you have chosen the step-by-step setup, you will have
already tested out the Speech Synthesiser. If you have in-
stalled the pre-configured card image, then you will want
to see what the Speech Synthesiser is capable of before
setting up your controller.
After the Pi has booted, you need to log in using the user-
name “pi” and password “raspberry”. Later, if you set up
an Arduino (or another device) to control the Pi directly,
you will need to program it to wait for the login prompt
and then send these strings, followed by newline charac-
ters, so that it can log in automatically. Our sample soft-
ware demonstrates how to do this
The espeak-ng program we’re using for speech synthe-
sis has a multitude of options, and a full list of command
parameters can be listed by typing the command:
espeak-ng - - help

For example, using the voice parameter, we can apply a
different accent. The parameters start with a dash and are
usually listed before the text to be spoken.
For example, type:
espeak-ng -ven-us “testing”

You should then hear the word “testing” in an Ameri-
can accent. Or try:
espeak-ng -s 125 -v en+f5 “testing”

This will also say “testing” but in a female-sounding
voice. Of course, you can modify the text inside the quotes
to make it say different words and phrases.
There are currently no Australian or New Zealand ac-
cents available, but a clever choice of spelling can be used
to emulate regional pronunciation.

Fig.4: connect the Leonardo board to the Speech Synthesiser as shown, for testing or to develop your own Arduino code
to drive the Synthesiser. Note that the Pi will draw a few hundred milliamps from the 5V supply, so ensure that it can get
the power it needs or you may have glitches.
Free download pdf