# Is simple voice synthesis (just digits 0-9) possible with Cortex-M0+ with 4kB flash?

I'm working on a little side project with the LPC810 (Cortex M0+ 32 bit ARM MCU, 8 pin DIP package, 4kB flash, 1kB SRAM). I need a UI to convey to the user a temperature setting. I only have about 2 pins spare to implement the UI.... so using LEDs is going to a challenge.

I had an idea of using just one pin to drive a speaker or peizzo buzzer and convey the temperature in speech. Just the digits 0 - 9 in english is all I need. Storing 0-9 in PCM is out of the question with so little flash. So I was wondering is anyone aware of open source code that would allow for very high compression of a small dictionary of words what would be light enough on CPU/RAM to work with a Cortex M0 class MCU? (I have a strong hunch this is plain out of reach of low end Cortex M0 MCUs without external memory).

• Not a direct answer to your question, but with 2 pins, you can drive many LEDs. Ether use shift registers or I2C to GPIO chips. Jul 28 '13 at 17:25
• What I'm doing here is more a challenge to see what can be done with little or no extra hardware... I'm not necessarily going for the most pragmatic solution :-) You're absolutely right: there are loads of serial devices I could attach for UI. Jul 29 '13 at 0:36
• FYI, I just posted a variant of your question as a challenge on codegolf.SE. Perhaps some of the (hopefully forthcoming) solutions there may be of interest to you as well. Aug 2 '13 at 13:55

While this may not be a complete, independent and ready-to-use answer, but I think you can get some neat ideas, implement (or port) it on Cortex-M0. Here I assume that from a computation power and resource standpoint, a Cortex-M0 has more to offer, than the popular Atmel 8-bit AVR (ATmega328P) running on an Arduino.

Here are 2 projects, that manage to use the PWM pin of Arduino and an RC-filter circuit to play out synthesized speech. Of course, we are not looking at hi-fidelity audio, but something that is recognizable. Also do note, that apart from the need for a PWM capable pin, your micro-controller might be very busy during the synthesis, so much so that, it might spend most of it's cycles doing it. Software PWM would put further strain.

Now for the 2 projects:

PS> Personally, I've not implemented them, but looked at them for a project.

I need a UI to convey to the user a temperature setting. I only have about 2 pins spare to implement the UI.... so using LEDs is going to a challenge.

Use the two pins as I²C Bus, and connect a GPIO expansion chip like MAX6956, which has 20 output pins in a 28-pin DIP package. That is enough for a few 7-segment displays, and you can connect more than one expansion chip to the bus.

• Thanks for the suggestion... this is a challenge make a sous vide cooker from nothing other than a hacked power timer, DS18B20, LPC810 (8 pin DIP) + passives. So what you're suggesting makes perfect sense normally, I'm actually deliberately going for weird and minimal. Jul 29 '13 at 0:44

It may be possible to write code that would fit in 4K that would produce vaguely-recognizable speech for the digits 0-9, but it would probably be easier to define beep patterns for them. A small amount of training might be required to recognize the beep patterns (among other things, if you're using a positional notation, knowing how a zero would be conveyed) but if all temperatures are positive it may not be too hard to define beep sequences for values 90-10 and 9-1.

+90: XXXXX--XX--XX---
+80: XXXXX---X-X-X---
+70: XXXXX-X-X---
+60: XXXXX-X-
+50: XXXXX---
+40: XX--XX--
+30: X-X-X---
+20: X-X-
+10: X---


Each "X" represents 50ms on and 50ms off, while each "-" represents 100ms off. For values 9-1, use the same cadences as 90-10 but a different pitch. The cadence patterns above could easily be stored in an array of 16-bit integers. The sequences above are chosen not just to allow counting, but also to be recognizable as patterns. Counting straight non-rhythmic pulses up to nine can be a bit difficult, but arranging the things to be counted into rhytmic grouping can help a lot.

• Yes, this is a good idea. My original plan was to blink a LED using a similar code (the project is a sous vide cooker controller... and the temperature range is actually very narrow... about 55C - 65C). Thinking that maybe I could double up functions: both LED and buzzer on the same GPIO line. Instead of solid on for the LED, I send a 50% duty cycle audio tone... indistinguishable to the eye. Jul 29 '13 at 0:48
• I think hearing tones could be easier than observing blinks. I would also think, though, that you might want to be able to have the LED on while the device was silent. Depending upon VDD and power-draw requirements, you may be able to arrange things so driving a pin one polarity hits the LED, and driving it the other way hits the piezo (float the pin to activate neither the light nor the piezo). Jul 29 '13 at 16:44

If board space is not a limitation, A port expansion + few counters (74HC161 or similar), external sample ROM and a DAC can implement this without requiring much code space.