SP0256A-AL2 Speech Synthesis
I had one of those moments recently when reading an article online sent me into a bit of a major tangent. The article in question was talking about the SP0256-AL2 speech synthesizer chip. And if you heard a computer talking in the 1980s, then chances are it was probably this chip doing all the hard work.
These aren’t very easy to come by these days, but you might get lucky with the usual places and find a legit, used, working one, but apparently an awful lot of those that can be found online are likely to be fake (see: https://www.smbaker.com/counterfeitfakejustplainbad-sp0256a-al2-chips).
But a number of peripherals for home computers in the 1980s included it and as luck would have it, the wonderful “MR GELÉE’S TECH” has a PCB, supplied with the chip included, for the RC2014 here: https://www.tindie.com/products/mrgelee/mg005-speech-synthesiser-designed-for-rc2014/
Update: I’ve also spotted that there is SP0256-AL2 emulation in the RC2040 project too.
So whilst on particularly a musical project (at least, not at the moment), this details how I got it up and running.
For my series of projects driving this from an Arduino, see Arduino and SP0256A-AL2.
https://makertube.net/w/gmqV2pM5UMqTPt31ThwseY
Warning! I strongly recommend using old or second hand equipment for your experiments. I am not responsible for any damage to expensive instruments!
If you are new to microcontollers, see the Getting Started pages.
The SP0256A-AL2
This is a pretty amazing device. It was present in the Currah uSpeech peripheral (that unfortunately I never had myself) back “in the day” and a whole load of other cheap(ish) add-ons for 1980s computers.
It works by having a set of samples encoded in ROM for the basic phonetic sounds of the English language (called “allophones”). Then it is told which to sound by a controlling CPU, or these days MCU probably.
Of course, text to speech has come on enormously since then, and there are all sorts of nuance now possible. It will be interesting to see if the recent rounds of AI use become a pinnacle of text to speech or a curse, but we shall see.
But there is something pretty nostalgic about hearing an allophone-based, lo-fi (by today’s standards) chip in action. And this style of voice is iconic for the sounds of computer voices used in films such as War Games, 2001, and The Forbin Project, among many others.
There is a complete run-down of the family of these devices here: https://en.wikipedia.org/wiki/General_Instrument_SP0256
“The SP0256-AL2 is perhaps the most commonly encountered variant. It contains 59 allophones primarily intended for use with English language phrases and five pauses in its internal 16 Kb (2 KB) ROM.”
There are full technical details in a datasheet and application manual available online, for example, from here: https://www.cpcwiki.eu/index.php/SP0256
Here is the full allophone table from the datasheet:
The datasheet also includes some words that show how the allophones can be used, for example:
I sort of imagined that somewhere there might be a library that has the data structures that represent the details provided in the datasheet, but I’ve not found it yet if it exists.
But thankfully there are means of getting allophones from English Text, which I’ll get to shortly.
The Basic Code
The code to drive the chip from BASIC is pretty straight forward. This is my code based on the example provided in the manual:
10 DATA 18,12,55,12,43,18,51,35,5,55,0
15 DATA 24,35,46,52,45,21,41,51,11,13,14,53,45,0
20 LET LE=11+14
30 DIM XX(LE)
40 FOR Y = 1 TO LE
50 READ XX (Y)
60 NEXT Y
70 FOR Z=1 TO LE
80 IF (INP(31) AND 2) = 2 THEN GOTO 100
90 GOTO 80
100 OUT 31,XX(Z)
105 NEXT Z
There is a list of the phonemes required and they are sent to the chip in turn.
As already mentioned of course, the real trick is how to get that list of allophones. Whilst it is possible to walk through the datasheet for the SP0256A-AL2 and pick out the correct ones in turn, that is a lot more difficult that it might initially seem, as it perhaps highlighted above.
Text to Allophone Data Workflow
As with may of these things we are fortunately that there are tools out there that can do all this for us. In this case, two tools are required:
I used espeak-ng which has a MSI installer for Windows, and lexconverter which is a python script.
Install steps:
- Install espeak-ng as required. This is a command line utility for Linux or Windows and instructions for installation can be found in “Documentation” -> “User Guide”.
- Grab the lexconvert.py script.
I had to ensure that the location of espeak-ng was present in my system PATH, but also had to edit lexconvert.py to change several instances of espeak to espeak-ng. There were three places that looked like they would need changing, all associated with “os.system”, “os.popen” or “subprocess.Popen” calls or similar.
I suspect copying the original executable to a more handy location and renaming it to “espeak” would probably work too.
To get allophones suitable for use with the SP0256A-AL2 requires the “cheetah” option to lexconvert, as detailed below:
cheetah : Allophone codes for the 1983 "Cheetah Sweet Talker" SP0256-based hardware add-on for ZX Spectrum and BBC Micro home computers. The conversion from phonemes to allophones might need tweaking. Set the CHEETAH_SYM environment variable to see the mnemonic symbols from the instruction sheet (not actually used by the system).
The command I used was as follows, which then waits for keyboard input and creates a data structure of allophones which can be used almost directly in the BASIC program.
C:\Users\Kevin\Stuff>python lexconvert.py --phones cheetah
Enter text (EOF when done)
Hello World
DATA 27,51,45,53,46,52,45,21,0
Greetings Professor Falcon
DATA 36,14,19,13,12,44,43,9,14,51,40,7,55,52,40,26,45,41,51,11,0
Would you like to play a game?
DATA 46,30,21,25,22,45,6,41,13,51,9,45,20,51,36,20,16,0
This is the Voice of World Control
DATA 18,12,55,12,43,18,51,35,5,55,24,35,46,52,45,21,41,51,11,13,14,53,45,0
C:\Users\Kevin\Stuff>
One issue I had in using these DATA statements directly is that they get capped when pasted into the RC2014 terminal, hence using two DATA statements in my final code.
But in general terms, this works surprisingly well.
RC2040 Support
After getting this far, I happened to spot that there is also SP0256-AL2 support in the RC2040 emulator too – more here: https://github.com/ExtremeElectronics/RC2040
In particular there is a script that will create the entire BASIC code for you here: https://extkits.co.uk/sp0256-al2/
Full details of the emulation can be found here: https://github.com/ExtremeElectronics/SP0256-AL2-Pico-Emulation-Detail
This is a really easy way to start messing around with it.
A Note on Chips
As mentioned at the start, getting hold of a true SP0256A-AL2 might be a bit of a lottery, so it maybe that playing with the Pico emulation is good enough.
But a good source, if you are already an RC2014 user, is the MG005 as previously mentioned. It is a great addition to your RC2014 system.
In my case I have managed to end up with three devices, one from the MG005 and two off ebay. They weren’t particularly cheap but look like they come from sellers who have a range of vintage devices for sale (one in the UK and one from Netherlands).
All three devices do seem to work and seem to be actual SP0256A-AL2 devices rather than a re-badged simpler device in the range. Here are some photos of the tops and bottoms of my three devices.
The bottom one is the trusted source from MG005 (hence the coloured in GI logo), the others are the two ebay purchases.
They all have similar markings. The text appears pretty distinct in all three devices, and although it’s quite hard to see in the photo, all three have a faint “C 236 20” type marking, viewable in the right light, that is just visible on the centre device in the photo.
All three also have a very distinct, recessed, spot marking pin 1 and none of them seemed to have overly shiny pins that would imply they’ve been “re-dipped” in solder to make them look new.
So far, I think I have three good chips I can use for experimenting.
Closing Thoughts
I now feel like I should build up DATA statements of allophones for well-known quotes from computers in films.
I also now want to work out how to drive the SP0256A-AL2 directly from a microcontroller myself, so that will probably be next.
Then I would like to tie this up to MIDI somehow, but my initial thought, of linking allophones to MIDI notes, seems to have been done already: https://rarewaves.net/products/midi-narrator/
But I still might have to overdub it saying “Concerto for a Rainy Day”. Getting it in time with the music might be an interesting challenge, but maybe there might be a computer-voice-vocoder-like thing possible now.
And of course, this now presents all sorts of interesting possibilities for some more Philip Glass…
Kevin
#rc2014 #sp0256aAl2 #speechSynthesis