Turn your micro:bit into the Robot Wars announcer
Three... Two... One... Activate!
Fans of Robot Wars both new and old recognise that deep booming voice of the arena announcer.
Whether its introducing a team of roboteers, starting the match or calling "Cease!", the voice is a key part of Robot Wars. Things wouldn't feel the same without it!
In this activity, we're going to show you how to turn your BBC micro:bit into the arena announcer, thanks to a fun new addition to the Python Editor: A speech synthesiser!
Step 1: The Mu Editor
This activity uses Python, but not our regular Python Editor. The Speech Synthesiser is a special function of the Mu Editor, which you can download from our Software Tools page.
If you're not familiar with using Python on your micro:bit, take a look at the MicroPython micro:bit guide.
To make your micro:bit speak, we're going to need speakers to attach to your micro:bit. A pair of headphones and some crocodile clips will do the trick! You can find out how to connect headphones to your micro:bit here.
Step 2: micro:bit's First Words
Open the Mu Editor.
To do most cool micro:bit things, you'll need to import the correct modules. Call the 'microbit' module and 'speech' module:
from microbit import*
There are two ways to make your micro:bit talk:
- speech.say() - Your micro:bit will say the string inside the brackets. The synthesiser has been designed to use English pronunciations, but it's not quite perfect.
- speech.pronounce() - Similar to speech.say, your micro:bit will read the string inside the brackets, but instead of looking for specific voice sounds or 'Phonemes'. There's a full list of phonemes that the micro:bit can understand on the Python Guide.
Give it a try! You can make your micro:bit say the announcer intro like this:
speech.say("Three, two, one. Activate.")
Step 3: Making it sound perfect
If you run the script you've written so far, it doesn't sound quite right. We can give commands that change the 'voice' of the micro:bit speech. A live of speech with voice controls looks like this:
speech.say("Hello", speed=30, pitch=150, throat=70, mouth=200)
Those four settings can be given a number between 0 and 255 and will do the following effects:
- Speed: How fast or how slow the speech is.
- Pitch: How high and squeaky or low and croaky the voice is.
- Throat: How relaxed or tense the voice sounds.
- Mouth: Whether the voice is mumbling or pronouncing everything clearly
Also, you can tell the micro:bit to pronounce words exactly as you'd like, using 'speech.pronounce' and this pronunciation guide. It's fiddly, but the end result will sound much clearer. Try this out:
speech.pronounce("THRIYIY. TUX. WAHN. AEKTIHVEYT.", speed=100, pitch=90, throat=110, mouth=105)
Step 4: Putting it all together
Once you've got your speech the way you like it, why not map the speech to the A and B buttons, so you can play them on command?
You can download our version of the Robot Wars Announcer .hex file here. You can flash the file straight to your micro:bit, or open the .hex file in the Mu editor to edit the contents.
Once you've experimented a bit and got the hang of things, why not try these:
- Change up the voice style to something totally different! Can you make the announcer sound younger and more excited?
- Can you put in a countdown on the LEDs to match the spoken countdown? Tou may need to split up the speech into smaller chunks and hange the LEDs after each part.