TTS (Text-to-Speech) Library Port?

Jerware

Well-known member
I enjoyed playing with the Talkie Library that was ported to Teensy awhile back but it has the limitation of a limited vocabulary (recorded phrases). There is another library that provides an unlimited vocabulary, albeit using a much more robotic voice and the requirement of an RC (resistor/capacitor) filter for the audio.

https://github.com/jscrane/TTS

It makes heavy use of Timer1 on Arduino, which is foreign to me. I wonder if anyone has time and interest to take a stab at porting it to Teensy/IntervalTimer/DAC? Further, I wonder if the Audio Library could be used to replace the RC filter?
 
Nope! But that looks like a voice recognition product, right? TTS is the opposite -- text to spoken speech. I'd also prefer to do everything on the microcontroller if possible for cost and space efficiency. Otherwise, there is a nice TTS module called emic 2.
 
I have a emic2 and works rather nicely. You can send commands and test to it from the Teensy.
 
I hacked up a version that works on Teensy 3.2 (may work with other teensies with DAC). I used the DAC rather than PWM, so you don't need a PWM filter to get analog to your audio amp. I tested on T3.2 with propshield and speaker. Louder than tests with UNO or LEONARDO. my changes are at
https://github.com/manitou48/TTS

TTS.h has a DACPIN definition that enables teensy DAC/delays in TTS.cpp

the github repository includes some mods where i added pin 5 for leonardo (littlebits)
 
repository updates:
I conditionalized the DACPIN selection and confirmed the text-to-speech worked on T3.2,3.5,3.6,LC and DUE.

I hacked another version to support ARM DAC pins on various mbed critters.
https://developer.mbed.org/users/manitou/code/tts/

For your viewing pleasure here is a trace of saying "a a a " on leonardo (littlebits) with the PWM smoothed by a 3-pole Sallen-Key filter. (3 spaces after 2nd a, one space after final a, and the AVR PWM runs at 13.333 KHz)
ttsaaa.png
and for comparison, a trace from the T3.2 DAC output for the same text string.
ttsaaa.png

phoneme codes: zSUTzSUTzzzSUTzzz
z is 46 ms pause

Another T3.2/DAC example below is saying "Hello." at two different pitches. CHN2 (blue) is the LED pin toggling for each phoneme.
ttshellopho.png
Phonemes are "h" "eh" "l" "oh" "w"

Depending on your audio amp, you might want a simple RC filter for your DAC output, see
https://forum.pjrc.com/threads/40241-Teensy-3-6-DAC-performance?p=130817&viewfull=1#post130817
For my tests, I didn't need/use any RC filter on the DAC output.
 
Last edited:
What are your thoughts on running the output through the audio library. Is that possible or would it require a substantial reworking?
 
i'm not familiar with all the audio adaptor options, but i think you could jumper the teensy DAC output to line-in of the adaptor. As noted, i tested with the propshield and speaker, and also with this audio amp breakout plus speaker
https://www.sparkfun.com/products/11044

Edit: OK, i tested TTS with DAC jumpered to adaptor line-in Left, listened with ear buds, and the following sketch
Code:
// TTS with audio adaptor
//  teensy DAC to adaptor line-in L


///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=123,346
AudioOutputI2S           i2s2;           //xy=344,386
AudioConnection          patchCord1(i2s1, 0, i2s2, 0);
AudioConnection          patchCord2(i2s1, 0, i2s2, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=316,695
// GUItool: end automatically generated code

#include <TTS.h>
TTS text2speech;

void setup() {
  Serial.begin(9600);
  AudioMemory(8);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);
  sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
  sgtl5000_1.lineInLevel(3);
  delay(1000);
}

void loop() {
  text2speech.setPitch(6);
  text2speech.sayText("Hello  master! How are you doin?");
  delay(500);

  text2speech.setPitch(1);
  text2speech.sayText("I am fine, thankyou.");
  delay(500);
}
 
Last edited:
Interesting. I was referring to the audio library, which functions independent of (or with) the audio adapter to filter audio. I was hoping this could be used to simulate the RC filter suggested on the original GitHub page. I hadn't considered using the inputs on the audio board to accomplish this. Good idea though I'd still be curious to know from Paul or someone whether the this TTS library can tap into the audio library directly.
 
Hi Manitou. I just downloaded you library and just started playing around with it. I am using T3.5 with a prop shield. Since I never used audio before it took a little while to notice that DAC0 needed to be attached to audio-in. It also took me a little while to figure out that this needed to be added to your examples to make it work with a prop-shield:
Code:
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH);  // turn on the amplifier
  delay(10);  // allow time to wake up

You may want to added it your examples, commented out with a note.

Also, I noticed with just a simple speaker (.25w 8Ohm) it was really hard to understand the words. Was wondering if it was my speaker or not. What's the quality of the speech that you have heard.

Thanks
Mike
 
Also, I noticed with just a simple speaker (.25w 8Ohm) it was really hard to understand the words. Was wondering if it was my speaker or not. What's the quality of the speech that you have heard.

The voice synthesis in this library is pretty crude, and the voice is very robotic. I think the leonardo/PWM+filter is a little better quality than the teensy DAC implementation. The DAC implementation runs at a slightly higher pitch and is a bit tinny. I tried adding a simple RC filter to the DAC output, but that only seemed to reduce the volume. One might fiddle with the pause() values. I've used different audio amps with an 8ohm 0.5 watt speaker, and volume is good enough to annoy my wife. :)
 
In regards to your last comment :) :)

Anyway. Just wanted to make sure it just wasn't me doing something wrong. The talkie library isn't too bad with the prop shield. Have an emic2 laying around have to start playing with that again.

Thanks for all your help.
Mike
 
For what it's worth, a few more comments on various text-to-speech pograms.

I'm not sure of the provenance of the TTS program described in this thread.

The Talkie lib plays pre-encoded words based on Texas Instruments speech synthesis architecture from the 80s

There is also the SAM speech synthesizer from the 1982 commodore 64. I've built that program on linux, and it will drive the audio board or it can write a WAV file (22khz mono). That library is also the basis of the UK's microbit speech. Also see http://www.multiwingspan.co.uk/micro.php?page=speech

It shouldn't be too hard to port to teensy.

Also mentioned in this thread is the Emic 2 breakout board.
 
SAM was cool. I'll create a teensy-port.

Do you have the original C64 PRG ???
I want to test it with my emulator.
 
Was beginning to take a look at that myself. If you want a guinea pig for testing I will volunteer. :)
 
Not a problem. I'm willing to give it a try. I may have some challenges with the audio since I only have a prop-shield to work with and pretty new to audio :) Will post back here if I run into any issues I can't figure out.
 
Everyone is a comedian. Have a emic2 and works great with the teensy. Opportunity to learn something new. Can I do it? Who knows. But I am going to try. :eek:
 
My apologizes. Really thought you were joking. Didn't know you could that. Ok. So now that you brought that up you can to share how to do that. Whats the performance improvement?
 
its hardware uart from sandboxelectronic, has 64byte fifo and rts/cts support, although 2 libraries exist, the one i wrote uses stream class so i can name it how i want like Serial7, or whatever, and has the read/write/available/peek functions, my library also enables rts/cts automatically and supports recovery (hotpluggable), both which dont exist in the other libs

like i said i tested esp8266 @ 921600baud with rts/cts, a uart display @ 115200 baud, adafruit gps @ 115200 baud, tested on Wire1 on teensy 3.5 at 100 and 400 khz bus

there are no comments or info files for the library as its just code, but if someone wants to release it and draw up some kind of header or readme or something then i can pass it on i guess, the uart device is capable of 16 addresses on the i2c bus, so a teensy 3.5 could have, theoretically, 6 internal uarts, and 48 i2c uarts (3x i2c busses x 16 uarts) for a total of 54 hardware uarts.

last test i did was BT and adafruit huzzah on Wire1 bus, both working great
 
Last edited:
Back
Top