Text to Speech (TTS)

Hello All,

I am doing one project using TTS library. I download one code from the internet

     #include "Talkie.h"
#include "Vocab_US_Large.h"
//THE SCREWDRIVER
Talkie voice;

void setup() {
    voice.say(sp2_DANGER);
    voice.say(sp2_DANGER);
    voice.say(sp2_RED);
    voice.say(sp2_ALERT);
    voice.say(sp2_MOTOR);
    voice.say(sp2_IS);
    voice.say(sp2_ON);
    voice.say(sp2_FIRE);
    // SUBSCRIBE TO THE SCREWDRIVER https://www.youtube.com/channel/UCk9UflimfCIAv7kdAWBxyuA
}
void loop() {
}

Above code work properly. but i am doing some modification on this code shown below

#include <Wire.h>
#include "Talkie.h"
#include "Vocab_US_Large.h"
//THE SCREWDRIVER
Talkie voice;
char charValue[4];

void setup()
{
  Wire.begin();
  Serial.begin(9600);
}

void loop()
{
  // This is using address 0x6 which can be changed in the device settings.
  Wire.requestFrom(0x66, 2);
  
  if (Wire.available() >= 2)
  {
    int byteH = Wire.read();
    int byteL = Wire.read();
    float distanceInCM = byteH * 256 + byteL;
    float distanceInMeter = (distanceInCM/100);
    dtostrf(distanceInMeter,4,1,charValue);
    voice.say(sp2_DISTANCE);
    voice.say(sp2_IS);
    voice.say(sp2_charValue);
    voice.say(sp2_METER);
  
  }
  
  delay(100);
}

In modified code have some issues I am not able to resolve these issues. In this code, I have accruing sensor data and converted it into character and try to listen "DISTANCE IS 4 METER". But not get success.

So please help me with what can I change in the above code.

Well I can't get this to compile because I have no "Talkie.h" file but I suspect that is an error on your part and you actually mean talkie.h, the same goes for your

#include "Vocab_US_Large.h"

There is no such file, if you want this file it must be added to you program as a tab.
So saying that the first code worked was not telling the truth was it? Because it contains the same mistakes.

Having said that then:-

voice.say(sp2_charValue);

is where you are going wrong.

I don't think this library works like this. Each word it says is pre programmed as an LPC sequence of bytes, and sp2_charValue isn't defined as anything.
You have to select the correct number to say. In the Vocab_UK_Acorn.ino file there are words for all the numbers, so you have to use the number you want to say to trigger each word of the number. Forget about the dtostrf function just work with the number.

It is an interesting exerciser to make a function that will say any number you pass to it, because it involves recursion. Make a function that says a number between zero and ninety nine, and if your number is above this then divide by one hundred, say hundred and pass this new number to the same function you are in.
You can extend this to a thousand and beyond.
Note the number words may be in other vocabularies as well.

Look at the _2_Voltmeter code in the examples that come with the Talkie library for an example of how this is done. Note that now the compiler insists on things being put in program memory are of type const so change that intro to:-

const uint8_t spZERO[]     PROGMEM = {0x69, 0xFB, 0x59, 0xDD, 0x51, 0xD5, 0xD7, 0xB5, 0x6F, 0x0A, 0x78, 0xC0, 0x52, 0x01, 0x0F, 0x50, 0xAC, 0xF6, 0xA8, 0x16, 0x15, 0xF2, 0x7B, 0xEA, 0x19, 0x47, 0xD0, 0x64, 0xEB, 0xAD, 0x76, 0xB5, 0xEB, 0xD1, 0x96, 0x24, 0x6E, 0x62, 0x6D, 0x5B, 0x1F, 0x0A, 0xA7, 0xB9, 0xC5, 0xAB, 0xFD, 0x1A, 0x62, 0xF0, 0xF0, 0xE2, 0x6C, 0x73, 0x1C, 0x73, 0x52, 0x1D, 0x19, 0x94, 0x6F, 0xCE, 0x7D, 0xED, 0x6B, 0xD9, 0x82, 0xDC, 0x48, 0xC7, 0x2E, 0x71, 0x8B, 0xBB, 0xDF, 0xFF, 0x1F};
const uint8_t spONE[]      PROGMEM = {0x66, 0x4E, 0xA8, 0x7A, 0x8D, 0xED, 0xC4, 0xB5, 0xCD, 0x89, 0xD4, 0xBC, 0xA2, 0xDB, 0xD1, 0x27, 0xBE, 0x33, 0x4C, 0xD9, 0x4F, 0x9B, 0x4D, 0x57, 0x8A, 0x76, 0xBE, 0xF5, 0xA9, 0xAA, 0x2E, 0x4F, 0xD5, 0xCD, 0xB7, 0xD9, 0x43, 0x5B, 0x87, 0x13, 0x4C, 0x0D, 0xA7, 0x75, 0xAB, 0x7B, 0x3E, 0xE3, 0x19, 0x6F, 0x7F, 0xA7, 0xA7, 0xF9, 0xD0, 0x30, 0x5B, 0x1D, 0x9E, 0x9A, 0x34, 0x44, 0xBC, 0xB6, 0x7D, 0xFE, 0x1F};

And so on.

One more point about your video.
Your circuit is wrong, you are using a TIP 122 transistor, but you use a FET in your Fritzing layout diagram. This is not a schematic so stop calling it one.

The TIP122 transistor needs a resistor in the base to limit the current. As you have it you are damaging the Arduino's output pin trying to drive this.

Thank You sir for reply!

Grumpy_Mike:
So saying that the first code worked was not telling the truth was it?

Sir my copy TTS code works properly. But audio voice volume

Grumpy_Mike:
You have to select the correct number to say. In the Vocab_UK_Acorn.ino file there are words for all the numbers, so you have to use the number you want to say to trigger each word of the number. Forget about the dtostrf function just work with the number.

Sir my laser sensor maximum limit of 100 meters. So I just try converting each number into character.

Sir, I just want my distance sensor output in the audio form that's why I am using the Talkie library.

Sir my copy TTS code works properly.

The code you posted first can not work correctly because it contains the mistakes I pointed out.

Sir my laser sensor maximum limit of 100 meters. So I just try converting each number into character.

And I told you it will not work that way.
If you disagree then fine, find a way to do it yourself, don’t ask for help and then dismiss it.

Sir, I just want my distance sensor output in the audio form that's why I am using the Talkie library.

I am aware of what you want to do and I have offered a solution. You are entitled to ignore me but that means I will be wasting my time if I attempt any further communication with you.

Best of luck with your project and fix that error on your web site.

my copy TTS code works properly.

Please state where you obtained the Talkie library.

The original Github Talkie library from Peter Knight will not work with your code.

There is a version (superset evolution) of the Talkie library you can load from the library manager through the Arduino IDE. Same name.

Grumpy_Mike was spot on with his response - the Votmeter example does exactly what the OP is trying to do and contains most of the code required to implement his solution.

Grumpy_Mike:
If you disagree then fine, find a way to do it yourself, don’t ask for help and then dismiss it.
I am aware of what you want to do and I have offered a solution. You are entitled to ignore me but that means I will be wasting my time if I attempt any further communication with you.

Hello Sir,
Sir, I agree with you. I have changed my code and I again download the new Talkie library. My new code running properly but audio voice quality is not good.

When I run my code on Arduino Uno I can listen to the audio voice on the headphone (headphone connected Pin 3 and ground).
But when I run the same code on Adafruit feather m0 board audio voice not coming to headphone(headphone connected Pin 10 and ground).

So sir, what can I do for the same code also run my Adafruit feather m0 board and how can I increase the audio quality of the audio signal.

Thank You.

jremington:
Please state where you obtained the Talkie library.

The original Github Talkie library from Peter Knight will not work with your code.

Sir, I am download Talkie library from GitHub - ArminJo/Talkie: Refurbished Arduino version of the Talkie library from Peter Knight.

Hello All,

Thank You for your support.

Now I am able to get an audio voice in headphones through Adafruit feather m0 board. But large noise is present in the audio signal means voice is not clear. But, when I run the same code on Arduino voice, is clear.

In feather board, I have connected speaker on A0 pin but in case of Arduino Uno on Pin 3

So sir please guide me on how can I get a clear voice by using the Adafruit feather m0 board?

Thank You.

The library documentation says that the M0 version has not been tested.

ARM0 (but not tested) as found on the SAMD, Teensy and Particle boards.

Post the issue on Github.

This statement, also from that library documentation, is incredibly bad advice. If you follow it, you will eventually destroy your Arduino.

I use the speakers from old earphones or headphones, which have approximately 16 to 32 Ohm, directly without a series resistor.