Giter Club home page Giter Club logo

esp8266sam's Introduction

ESP8266SAM

Speech synthesis for ESP8266 and ESP-32 using ported SAM code

This is a port, wrapper, and update of the reverse-engineered speech synthesizer Software Automatic Mouth (SAM). Utilize it with the ESP8266Audio library to have your ESP speak via a DAC or a direct-drive speaker. No web services are required, everything from text parsing to speech generation is done directly on the ESP.

Original sources

This version has been reworked to generate full 8-bit speech formants as well as proper time-series waveforms.

Usage

You will need:

  1. The ESP8266Audio library installed in your Arduino/libraries folder ( git clone https://github.com/earlephilhower/ESP8266Audio )
  2. An audio output device compatible with ESP8266Audio. There are two described in its readme, and either the DAC or 1-transistor amplifier will work fine.

Then in your code instantiate an AudioOutput object, ->begin() it, and then simply create the SAM object and call Say().

About SAM

SAM is a very basic speech synthesizer originally developed in 1979 and ported to the Commodore 64. It was designed to run on very low memory 8-bit processors, and as such is a great for the ESP8266 with it's limited RAM.

The quality of speech isn't phenomenal. To paraphrase Samuel Johnson, "It is not done well; but you are surprised to find it done at all." The same could be said of the decompiled, disassembled, C-translated source code.

Output is fixed at 22050Hz due to some hardcoded delays to help match C64 internal timing parameters.

The voice is formant generated and can be modified by setting things such as speed, pitch, mouth and throat configuration, and even sending in phonetic codes instead of English text. See @s-macke's repository for more information.

Cool uses of SAM

Jan Derogee has used ESP8266SAM to build a complete VIC-20 compatible speech synthesis cartridge that works with BASIC applications. It also has a great background on early speech synthesis and a neat construction and demo video. Check it out at https://janderogee.com/projects/SerialSpeechSynthesisSAM/SerialSpeechSynthesisSAM.htm

License

While the ESP8266 wrapper is my own, the SAM software is a reverse-engineered version of a software published more than 34 years ago by "Don't ask Software".

The company no longer exists. Any attempt to contact the original authors failed. Hence S.A.M. can be best described as Abandonware (http://en.wikipedia.org/wiki/Abandonware)

As long this is the case I cannot put my code under any specific open source software license. However the software might be used under the "Fair Use" act (https://en.wikipedia.org/wiki/FAIR_USE_Act) in the USA.

esp8266sam's People

Contributors

earlephilhower avatar liebman avatar maditnerd avatar maxgerhardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp8266sam's Issues

Unable to get any output from SAM

I have a PCM5102 connected to ESP8266 and all examples from ESP8266Audio work as expected. This means the wiring is right.

I can't get SAM's Say() to output anything. Any help appreciated.

Output is muffled

I tried this on M5Stack Atom Echo Smart Speaker. The sound is very muffled. Is there anyway to tune the output?

Can't seem to get an output nodac on ESP32

Could someone guide me on using the code on an esp32? I was using an Esp8266 with the nodac code. Using a single wire from rx to an input pin on my amp it works fine but once I switch to an Esp32 it doesn't seem to output anything on any Rx pins.
Oh and if anyone could teach me how to switch the voice presets in the code, that would be much appreciated as well. Best regards, H.

SAM only, no DAC

Hi.

I have a very specific use case. I hope to implement SAM, and put the output into the mic input of a walkie talkie. As such, I don't believe I need a DAC: I think the digital output and a capacitor will do the job. I'm not entirely sure which pin to use. The optical example in ESP8266Audio just says "GPIO pin" but I'm not sure ow to select this (if it can be selected).

The other thing is: I don't see how to use the SAM library. The instructions say I need https://github.com/earlephilhower/ESP8266Audio. Do I require to install ESP8266SAM as a library as well as ESP8266Audio?

Hope you can help, then (as requested) I believe I have a VERY interesting application for your wrapper!

Thanks.

ESP32 PCM5102a Noise

When running the Code example ESP8266SAM->Examples->Speak theres noise in the background (more foreground):
Id attached a recorded example of it.

When using ESP8266 Audio and i play sth the noise does not appear.

noise.wav.zip

Do i have to configure sth to eliminate the noise in the foreground?

Speak example never stopping on ESP32

Similar to : earlephilhower/ESP8266Audio#473

On ESP32, after playing a SAM voice it never stop to say the last sound.
To find out this you have to modify a little the default example by replacing the delay(); with something not blocking.

Here the example to verify this little bug on ESP32 (and a quick/dirty solution in comments) :

#include <Arduino.h>
#include <ESP8266SAM.h>
#include <AudioOutputI2S.h>

unsigned long previousMillis = 0;        // will store last time sam voice was played
const long interval = 5000;              // inerval between the repeats

AudioOutputI2S *out = NULL;

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

void loop()
{

  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    ESP8266SAM *sam = new ESP8266SAM;
    sam->Say(out, "Bonjour");
    delete sam;
    // quick fix to avoird infinite repeat on ESP32 :
    //out->stop();  

  }
}

I hesitated to create this issue in ESP8266audio library but I think that the out->stop(); could be added at line 87 of ESP8266SAM.cpp.
Need expert opinion to confirm ๐Ÿ˜‰

debug.h file creates conflict with core and other libraries

As per community topic

The debug.h header defines

#define debug 0

With ESP8266 core also contains the debug.h header

https://github.com/esp8266/Arduino/blob/master/cores/esp8266/debug.h

In PlatformIO this causes a conflict due to probably a different order of include flags. An example of this is the WiFiManager library that has these functions

    void          setDebugOutput(boolean debug);
    void          setDebugOutput(boolean debug, String prefix); // log line prefix, default "*wm:"

with a previous #include <Arduino.h>, which at some points includes debug.h which then goes into this library's debug.h instead of the core's debug.h library, the #define debug 0 takes effect and the expanded version of the function declaration is

void          setDebugOutput(boolean 0);

which is invalid code.

In file included from C:\Users\Miguel\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Stream.h:25,
                 from C:\Users\Miguel\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/HardwareSerial.h:32,
                 from C:\Users\Miguel\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Arduino.h:288,
                 from C:\Users\Miguel\AppData\Local\Temp\tmpvxy3fvbw:1:
.pio\libdeps\d1_mini\ESP8266SAM\src/debug.h:17:15: error: expected ',' or '...' before numeric constant
   17 | #define debug 0
      |               ^
.pio\libdeps\d1_mini\WiFiManager/WiFiManager.h:99:42: note: in expansion of macro 'debug'
   99 |     void          setDebugOutput(boolean debug);

I'd suggest to rename the debug.h file to esp8266sam_debug.h to avoid a conflict with Arduino-ESP8266 and also rename the debug to something more unique.

Interested in adding Spanish support.

Hi, first of all, great work porting this library and on your other library ESP8266Audio as well ๐Ÿ˜ƒ

I'm from Argentina, and I'm thinking it would be great to add Spanish support to ESP8266SAM. I think the existing phonemes should work, and the only thing to change would be the mathching from strings to phonemes, so it would implement Spanish pronounciation by selecting different phonemes than the ones for English. From playing with other libraries and frameworks I know this would not render optimal results, probably will sound a little funny, but maybe it could be a good starting point.

Would you provide any guidelines or ideas on how to achieve this? Thanks!

SAM for SAMD21 (Arduino Zero)

Hi Phil
The SamD21 used in the Arduino Zero has an onboard dac (A0)
Any chance to have SAM running also on it?
Many thanks
Cheers,
Jean-Luc

Share audio examples

Hi,
I think it would be good if you'd share a couple of audio examples of SAM saying a couple of sentences. Personally, it would help me in comparing my results with yours, because I'm not sure if the quality I'm getting is the best it could be.

thanks!

Other code hanging in the loop()

Hi there, and kudos for the excellent porting (and esp8266audio creation too).

I'm using the NoDAC + SAM successfully but now that the program is getting bigger, I noticed that code seems to not be able to loop anymore.
The only solution I've found so far, is to call SAM once per loop and just make him say nothing.
If I do this the other functions start working magically, like the server.handle() (for the incoming http connections to the webserver) and some simple timers;.

Is there something I am missing?
Any suggestion would be really appreciated.
Thank you ! :)

foreground buzzing noise

I am using the esp8266 (12) with NoDAC and get a foreground noise that renders the output (almost) unusable ... If I didn't know what it was saying ... I wouldn't ... I noticed that the piano sample in the esp8266audio library sounded the same way until I normalized, and amplified the mp3 ... any chance of making tweaks to the esp8266sam's output? I plan to test it with an i2c hardware decoder and amp to see if it's just the quality or the NoDAC setup ...

Phonetic mode not working. (Fix suggestion)

Hello Earle,

When trying out the Phonetic possibilities I noticed that SetPhonetic is not really implemented although mentioned.

I added the following lines to the file sam.c and then it appeared to work for real :

Line 17:
int phonetic = 0;

Line 61:
void SetPhonetic(int x) {phonetic = x;};

Phonetic Words as mentioned in the original Manual of 'Don't Ask Computer Software' do work now:
https://janderogee.com/projects/SerialSpeechSynthesisSAM/files/dict_eng.txt
e.g.
Q
quality=KWAA4LIXTIY
quantity=KWAA4NTIXTIY
quart=KWOH4RT
quarts=KWOH4RTS
quebec=KUHBEH4K
question=KWEH4SCHUN
quick=KWIH4K
quiet=KWAY4IXT
quit=KWIH4T
quiz=KWIH4Z
quote=KWOW4T
quotient=KWOW4SHUNT

void SAM_Phonetic_Test() {
char my_tts_text[150];
ESP8266SAM *sam = new ESP8266SAM;
sam->SetPhonetic(true); \\ Puts SAM in the Phonetic Mode

strncpy_P(my_tts_text, PSTR("KWAA4LIXTIY KWAA4NTIXTIY KWOH4RT KWOH4RTS KUHBEH4K KWEH4SCHUN KWIH4K KWAY4IXT KWIH4T KWIH4Z KWOW4T KWOW4SHUNT", sizeof(my_tts_text)));

sam->Say(audio_output_I2S, my_tts_text);
sam->SetPhonetic(false); \\ Puts SAM in the Normal Mode

sam->Say(audio_output_I2S, "Can you hear me now?");
delay(500);
sam->Say(audio_output_I2S, "I can't hear you!");

delete sam;

}

PS: Thanks for the work with great library, brings back sweet memories of my early experiences on my Apple-][ Clone

not issue but question: can esp8266sam be used async ?

Hi. i could not test for now. still waiting for the correct hardware...

But can you tell me if it's possible to use esp8266sam without locking the main program loop ?

Does the main loop hang when the say method is called ?

Goal is to animate something on a screen while tts is running. could this be achieved ?

Thanks by advance for you answer.
DrZoid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.