Is it possible to make Arduino talk without shield

Well - not exactly tiny, but it still leave 20K or so available, so it isn't too shabby, either, for what it does, I suppose...

:slight_smile:

Ro-Bot-X.... shame on me :-[
I was too hurry that I didn't read all your post.

For now, I got it working. I connected Arduino to my computer speakers and everything works fine. Interesting is that when using VoiceBox Shield... you have to have SpeakJet Chip + TTS256 Text to Speech Chip... but you have both in one....

I have one more question - is it somehow possible to use the chip from children toy mobile phone? That usually say something like "I LOVE YOU... etc"

Possibly, if you have a datasheet for the chip in question.

Hi again,
I am trying to make the Arduino to say the current temperature.
I have connected temperature sensor LM35 to analog pin 0.

There is something wrong with the red part.

/*
The Text To Speech library uses Timer1 to generate the PWM
output on digital pin 10. The output signal needs to be fed
to an RC filter then through an amplifier to the speaker.
*/

#include <TTS.h>

// Media pins
#define ledPin 13 // digital pin 13
const int pin = 0; // analog pin 0

int tempc = 0;
int tempb = 0;

// Variables
char text [50];
boolean state=0;

TTS text2speech; // speech output is digital pin 10

void setup() {}

void loop()
{

// Takes 8 samples and sums up
for(int i = 0; i < 8; i++)
{
tempc += analogRead(pin);
}

// Makes some calculations
tempc = (5.0 * tempc * 100.0) / (8.0 * 1024.0);
int tempb = tempc + 0.5;

state = !state;
Test_Speech();
}

void Test_Speech()
{
text2speech.setPitch(6); //lower values = higher voice pitch
strcpy(text, tempb);
text2speech.say(text);
delay(500);
}

int tempb = tempc + 0.5; gives the temperature numbers, like 23 degrees.

strcpy(text, tempb);
text2speech.say(text); should say the value.

This works fine:
strcpy(text, "Hello there 1 2 3 4 5");
text2speech.say(text);

But i want it to say the int tempb value
I think there is a problem with text and integer..

The strcpy is bad. You are trying to copy an int to a string. There are int to string conversion functions to use instead.

I did some changes

void loop()
{

// Takes 8 samples and sums up
for(int i = 0; i < 8; i++)
{
tempc += analogRead(pin);
}

// Makes some calculations
tempc = (5.0 * tempc * 100.0) / (8.0 * 1024.0);
int tempb = tempc + 0.5;

state = !state;
Test_Speech();
}

void Test_Speech()
{
text2speech.setPitch(6); //lower values = higher voice pitch
itoa (tempb, tempx, 10); // integer to string
strcpy(text, tempx);
text2speech.say(text);
Serial.println(text);
delay(500);
}

Serial.println(text); - gives always ZERO. Wonder why?

Also i was thinking, because the speech isnt very understandable, to let it say numbers in my language.

For example,

INTEGER 1 = "ÜKS"
INTEGER 2 = "KAKS"
INTEGER 3 = "KOLM"
INTEGER 4 = "NELI"
INTEGER 5 = "VIIS"
etc.

tempb = (5.0 * tempc * 100.0) / (8.0 * 1024.0);
digit1 = tempb / 10; // get the ten's digit
digit2 = tempb % 10; // get the one's digit

IF digit1 = 1
THEN digit1 = ÜKS
IF digit1 = 2
THEN digit1 = KAKS
IF digit1 = 3
THEN digit1 = KOLM

and then the script says "KAKS KOLM" instead of "TWO THREE" (by default the speech script pronounces numbers in english one-two-three-etc)

How to do this? Any suggestions for displacing numbers ?

int tempb = tempc + 0.5;

This statement, in loop, creates a local variable, named tempb, and assigns it a value.

itoa (tempb, tempx, 10); // integer to string

This statement, in Test_Speech, references a global variable named tempb. This is NOT the same variable that was valued in loop.

No idea what to do..

The IDE told you which line caused the error.

I'm guessing it was this one:

itoa (tempb, tempx, 10); // integer to string

The 1st argument is the integer to be converted to a string. The 2nd argument is the string (array of characters) where the output is to be stored. The 3rd argument is the base (typically 10) to be used in the conversion.

I don't see a declaration for tempx, and I doubt that the compiler does, either. Therefore, it assumes that you will declare it as an integer, and is telling you that that is the wrong type.

Stupid ass assumption, in my opinion, but I didn't write the compiler.

I had mistakes in previous code. Here is the current script i'm working on:

/*
The Text To Speech library uses Timer1 to generate the PWM
output on digital pin 10. The output signal needs to be fed
to an RC filter then through an amplifier to the speaker.
*/

#include <TTS.h>

// Media pins
#define ledPin 13       // digital pin 13                          
const int pin = 0; // analog pin 0

int tempc = 0;
int tempb = 0;
char tempx [50];

// Variables
char text [50];
boolean state=0;

TTS text2speech;  // speech output is digital pin 10

void setup() {}

void loop()
{  

// Takes 8 samples and sums up
for(int i = 0; i < 8; i++)
{
tempc += analogRead(pin);
}

// Makes some calculations
tempc = (5.0 * tempc * 100.0) / (8.0 * 1024.0);
int tempb = tempc + 0.5;

state = !state;
Test_Speech();
}

void Test_Speech()
{
text2speech.setPitch(6); //lower values = higher voice pitch
itoa (tempb, tempx, 10); // convert integer to string
strcpy(text, tempx);
text2speech.say(text);
delay(500);
}

Well, it compiles now!

Well, it compiles now!

Does it work?

I didn't have a chance to try it before but now, when i uploaded and connected earphones + LM35 temp sensor, it is saying ERROR-ERROR-ERROR... in a voice :stuck_out_tongue:

void Test_Speech()
{
text2speech.setPitch(6); //lower values = higher voice pitch
itoa (tempb, tempx, 10); // convert integer to string
strcpy(text, tempx);
text2speech.say(text);
delay(500);
}

If i write:

itoa (tempb, tempx, 10); // convert integer to string
Serial.print(tempx);
strcpy(text, tempx);
text2speech.say(text);

Then it gives none in Serial Monitor

What does Serial.print(tempb); show?

tempc = (5.0 * tempc * 100.0) / (8.0 * 1024.0);

tempc is an int. What do you end up with in tempc?

int tempb = tempc + 0.5;

tempb is a local variable with the same name as a global variable. Adding 0.5 to an int does nothing.

The global tempb is never modified, Test_Speech() should be converting 0 to a string.

strcpy(text, tempx);

Why copy one array to another array of the same size?

It's actually working. It just has really bad sound quality that i didn't understand it. Numbers 0 - 9 are quite understandable, but 10 - .. are awful. Therefore i would like to know, if it is possible to make 23 to 2 3 (with space between)?

#include <TTS.h>
const int pin = 0; // analog pin 0
int tempc = 0;
char tempx [50];
boolean state=0;
TTS text2speech; // speech output is digital pin 10

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

void loop()
{
for(int i = 0; i < 8; i++)
{tempc += analogRead(pin);}
tempc = ((5.0 * tempc * 100.0) / (8.0 * 1024.0)) + 0.5;
state = !state;
Test_Speech();
}

void Test_Speech()
{
text2speech.setPitch(6); //lower values = higher voice pitch
itoa (tempc, tempx, 10); // convert integer to string
Serial.print(tempx);
text2speech.say(tempx);
delay(500);
}

Here is the The Final Code (fully working)

#include <TTS.h>                          
const int pin = 0; // analog pin 0
int digit1 = 0;
int digit2 = 0;
int tempc = 0;
char temp1 [1];
char temp2 [1];
boolean state=0;
TTS text2speech;  // speech output is digital pin 10

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

void loop()
{ 
for(int i = 0; i < 8; i++)
{tempc += analogRead(pin);}
tempc = (5.0 * tempc * 100.0) / (8.0 * 1024.0);
digit1 = tempc / 10; // get the ten's digit
digit2 = tempc % 10; // get the one's digit
state = !state;
Test_Speech();
}

void Test_Speech()
{
text2speech.setPitch(6); //lower values = higher voice pitch
itoa (digit1, temp1, 10); // convert integer to string
text2speech.say(temp1);
delay(500);
itoa (digit2, temp2, 10); // convert integer to string
text2speech.say(temp2);
delay(500);
text2speech.say("degrees");
delay(1000);
}

PC Speaker sound for 24'C: TWO FOUR DEGREES

Thanks again, PaulS !!!

Before you get real happy with that code, I'm going to suggest some changes. The itoa function adds a NULL to the end of the string. So, if the value passed to it is a one digit number, two characters will be written to the array, in which you provide room for one of them. Something else is getting overwritten.

If you looked at the values in the array, you would see that 1 is converted to '1', 2 is converted to '2', etc.

You can do this much more efficiently:

char temp1[2];
char temp2[2];
temp1[0] = digit1 + '0';
temp1[1] = '\0'; // Add the NULL terminator
temp2[0] = digit2 + '0';
temp2[1] = '\0';

Try this in place of the calls to itoa, and see how much smaller your compiled code gets.

Thank you :slight_smile:
Code smaller and still working.

Ro-Bot-X -
Thank you so much! Worked the first time! Exactly what I was looking for!

I used my pc speakers to output since they had an amplifier.

By the way is there any way to increase the quality? By using Phonics perhaps to sound out the word I want to hear?

Any updated releases?

Thanks again :sunglasses:

Here is the list of phonemes, you can try to use them instead of text. You can also play with the intonation in the phonemes.

Quoting original text by Webbot (Clive Webster):
If you are programatically calling the speak method, or your text starts with a '*' character then
 the following text is made up of phonemes with optional pitch numbers. 
If you are just 'playing' then it is very likely that you may get an error message - because you have
 used a phoneme that is not in the following list.
 
The valid phonemes are:-
AY as in 'pale'
AE as in 'black'
AA as in 'car'
AI as in 'fair'
EE as in 'meet'
EH as in 'get'
ER as in 'perk'
IY as in 'site'
IX as in 'sit'
IH as in 'sit!!'
OW as in 'coat'
O as in 'cot'
UX as in 'coot'
OY as in 'voice'
AW as in 'now'
AO as in 'door'
OH as in 'won'
UW as in 'you'
/U as in 'put'
UH as in 'wood'
AH as in 'up'
B as in 'bat'
D as in 'dab'
F as in 'fat'
G as in 'gap'
/H as in 'hat'
J as in 'jab'
K as in 'cat'
L as in 'lag'
M as in 'mat'
N as in 'nap'
P as in 'pat'
R as in 'rat'
S as in 'sat'
T as in 'tap'
V as in 'vat'
W as in 'wag'
Y as in 'yap'
Z as in 'zap'
CH as in 'chair'
DH as in 'this'
SH as in 'share'
TH as in 'thick'
ZH as in 'azure'
CT as in 'fact'
DR as in 'dragon'
DUX as in 'duke'
NX as in 'sing'
TR as in 'track'
 
When using phonemes you can optionally append a number from 1 to 8 to change the pitch of the phoneme.
So to say 'Welcome everyone' using phonemes we could use 'WEH4LKAHM EH3VREEWON'

Since I have no idea how this stuff works, I just converted it into a library, I can't improve it further. If anyone can do a better job, please do and post the code for others to use, as I did, with the permission of the original developer. Also, he said he did his best at it and can't be convinced to spend more time in this matter. He included his code to his WebbotLib library for building robots with AVR controllers.