-->
Page 1 of 2

Speech synthesis library (self-contained) for ESP8266

PostPosted: Sat Sep 30, 2017 6:40 pm
by earlephilhower
Hi folks,

I've ported a low-memory, completely self-contained speech synthesizer available to the ESP8266. No Internet connection or services are used, so you can use this is applications where a web service just isn't possible or desirable.

https://github.com/earlephilhower/ESP8266SAM
(note you will also need https://github.com/earlephilhower/ESP8266Audio to handle the I2S or delta-sigma sound output)

Software Automatic Mouth (SAM) was an amazing speech synthesizer available on 8-bit CPUs in the early 80s. There were versions for the Atari 400, Commodore 64, and others. A fan converted it from 6502 assembly to C code and put it online ( https://github.com/s-macke/SAM ). I took his code, reworked the output so it sent bytes directly to the audio device instead of buffering, and moved what tables I could into PROGMEM.

The quality is not stellar, but still amazing given the small memory footprint. All samples and waveform generation are only 4-bit(!!)) and even with CPU limits of the late 70s/early 80s is spoke in real time. While the ESP8266 has 100x the CPU horsepower of a 1-MHz 6502, it has less free memory than a C64 did, so this low memory usage is critical.

If you have need for a fixed vocabulary for your project, I'd still use the MP3 ESP8266Audio class for much higher quality, but if you don't know what you'll need your ESP8266 to say beforehand this is definitely usable.

Using the code is very simple:
Code: Select all#include <Arduino.h>
#include <ESP8266SAM.h>
#include <AudioOutputI2SDAC.h>

AudioOutputI2SDAC *out = NULL;

void setup()
{
  out = new AudioOutputI2SDAC();
  out->begin();
}

void loop()
{
  ESP8266SAM *sam = new ESP8266SAM;
  sam->Say(out, "Can you hear me now?");
  delay(500);
  sam->Say(out, "I can't hear you!");
  delete sam;
}

Re: Speech synthesis library (self-contained) for ESP8266

PostPosted: Sun Oct 01, 2017 1:53 pm
by mrburnette
Very nicely done, thank you.
Ray

Re: Speech synthesis library (self-contained) for ESP8266

PostPosted: Fri Oct 06, 2017 3:03 am
by earlephilhower
I've just pushed a new version that's reworked to generate full 8-bit, continuous audio output instead of the 4-bit the original code was doing. If you were playing with it, try pulling the new repo.

It's still not the greatest, but there is significantly less buzzing and noise on my test speakers now. There were some sign handling differences between the PC and the ESP8266 that were also fixed, so if you're getting weird artefacts this should clear them up as well.

Re: Speech synthesis library (self-contained) for ESP8266

PostPosted: Sat Oct 07, 2017 1:34 pm
by torntrousers
Great stuff! Thanks for sharing the code.