(SOLVED) Expected Primary-expression error

I am new with arduino and need help with one of my scripts. I go the 'Expected primary-expression before '.' token' error and need help. This is the code showing the error.

if (voice(Talkie.h)).say("introduce yourself")) do (voice(Talkie.h)).say("I am Alex, a simple Artificial Intellegence Program coded and built by Mirza Rameez Ahmed Baig.")

I'm not sure what language that is.

Please post all your code and the error message, in code tags.

if (voice(Talkie.h)).say("introduce yourself"))
  {
     do
      (voice(Talkie.h)).say("I am Alex, a simple Artificial Intellegence Program coded and built by Mirza Rameez Ahmed Baig.")

There is no clue what the voice() function is, or what arguments it takes. There is no clue what class Talkie is an object of, so there is no proof that the object even has an h field.

Post ALL of your code, and links to any non-standard libraries.

Artificial Intellegence

Oh! The irony! :smiley:

Basically, I cannot find the fix for a few errors in my script so i want some super smart guy to thoroughly fix my script. I am sorry if this causes in-convenience.

  • Please put the Talkie.h file in your C:\Users\Documents\Arduino\Libraries folder

  • The Alex.ino file is the program I am trying to make (It is suppose to be a program that answers certain things it hears (Parts: Microphone Module, Speaker Module, Arduino Uno and possibly 200 OHM Resistor))

  • TY in advance

Talkie.h (413 Bytes)

Well, i spent a couple of hours assembling the circuit from your list of parts. I also thoroughly checked the script you have provided. Everything is fine, you are good to go.

Steve

  1. Show us the code
  2. Tell us what the errors are

The error is the function definition not allowed before the '{' token.
Code:

#include "Talkie.h"

Talkie voice;

const uint8_t spDANGER[] PROGMEM = {0x2D, 0xBF, 0x21, 0x92, 0x59, 0xB4, 0x9F, 0xA2, 0x87, 0x10, 0x8E, 0xDC, 0x72, 0xAB, 0x5B, 0x9D, 0x62, 0xA6, 0x42, 0x9E, 0x9C, 0xB8, 0xB3, 0x95, 0x0D, 0xAF, 0x14, 0x15, 0xA5, 0x47, 0xDE, 0x1D, 0x7A, 0x78, 0x3A, 0x49, 0x65, 0x55, 0xD0, 0x5E, 0xAE, 0x3A, 0xB5, 0x53, 0x93, 0x88, 0x65, 0xE2, 0x00, 0xEC, 0x9A, 0xEA, 0x80, 0x65, 0x82, 0xC7, 0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 0x0F, 0x6E, 0x94, 0x22, 0x8F, 0xF3, 0x92, 0xF6, 0x05, 0x43, 0xCC, 0x74, 0x77, 0x3E, 0xC3, 0xF5, 0x95, 0x98, 0xA9, 0xBA, 0x8B, 0x8F, 0x00, 0x7E, 0x73, 0xE5, 0x00, 0x05, 0x28, 0xF0, 0xFF};
const uint8_t spALERT[] PROGMEM = {0xA5, 0xCF, 0xC6, 0xAB, 0x55, 0x5B, 0xAF, 0x39, 0xDA, 0xC9, 0x54, 0xDD, 0xBC, 0xC6, 0xC2, 0x3C, 0x27, 0x20, 0xCF, 0x1C, 0xD7, 0x30, 0xB0, 0x45, 0x16, 0x69, 0x1D, 0xC3, 0x11, 0xE4, 0x59, 0x8A, 0x7C, 0xB5, 0x9B, 0x8B, 0xD9, 0x30, 0xB7, 0xD3, 0x76, 0x19, 0x9A, 0x25, 0x59, 0x57, 0x59, 0xEC, 0x11, 0xAF, 0xE8, 0xD9, 0xF9, 0x2A, 0x8A, 0x1D, 0xF0, 0x75, 0x3F, 0x73, 0xAC, 0x87, 0x3B, 0xA2, 0x0B, 0xAA, 0x2B, 0xCF, 0xE4, 0x10, 0xA1, 0xDC, 0x45, 0x64, 0x03, 0x00, 0x80, 0x01, 0x66, 0x36, 0x33, 0xC0, 0xAB, 0xD5, 0x0A, 0x68, 0x25, 0x85, 0x02, 0xFF, 0x0F};

int micPin = 3;
int fsrAnalogPin = A0; // FSR is connected to analog 0
int speakerPin = 8; // connect Red LED to pin 8 (PWM pin)
int fsrReading; // the analog reading from the FSR resistor divider
int speakerMap;

void setup() {

voice.say(spDANGER);
voice.say(spDANGER);
voice.say(spRED);
voice.say(spALERT);
voice.say(spMOTOR);
voice.say(spIS);
voice.say(spON);
voice.say(spFIRE);

{
Serial.begin(9600); // We'll send debugging information via the Serial monitor

{ Serial.begin (9600);

pinMode(micPin, INPUT);
}
}

void loop(){

fsrReading = analogRead(fsrAnalogPin);
int num=fsrReading/5;
Serial.print("Analog reading = ");
Serial.println(fsrReading);
speakerMap = map(fsrReading, 0, 1000, 120, 1500);
tone(speakerPin, speakerMap,10);

delay(100);

{
if (digitalRead(micpin) == HIGH)
{

if (voice(Talkie.h)).say("introduce yourself")) do (voice(Talkie.h)).say("I am Alex, a simple Artificial Intellegence Program coded and built by Mirza Rameez Ahmed Baig.")
else if (voice(Talkie.h)).say("hello" or "hi") do (voice(Talkie.h)).say("Hello" or "Hi")
else if (voice(Talkie.h)).say("bad") do (voice(Talkie.h)).say("Oh No!")
else if (voice(Talkie.h)).say("good") do (voice(Talkie.h)).say("I'm Happy!")
else if (voice(Talkie.h)).say("I'm going" or "I am going") do (voice(Talkie.h)).say("Bye")
else if (voice(Talkie.h)).say("why") do (voice(Talkie.h)).say("Cause I can")
else if (voice(Talkie.h)).say("run diagnostics") do (voice(Talkie.h)).say("All systems working optimally.")
else if (voice(Talkie.h)).say("How are you") do (voice(Talkie.h)).say("All my systems are working optimally" or "I'm Okay")
else if (voice(Talkie.h)).say("Fortnite") do (voice(Talkie.h)).say("Fortnite's Awesome!")
else if (voice(Talkie.h)).say("Rameez") do (voice(Talkie.h)).say("Rameez's Awesome")
else if (voice(Talkie.h)).say("alex") do (voice(Talkie.h)).say("Yes?")
else if (voice(Talkie.h)).say("no") do (voice(Talkie.h)).say("I understand!")
else if (voice(Talkie.h)).say("Yes") do (voice(Talkie.h)).say("I'm happy!")
else do (voice(Talkie.h)).say("Response Denied!")

}
}

Please do this:

  • When you encounter an error, you'll see a button on the right side of the orange bar "Copy error messages" in the Arduino IDE (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button..
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the error between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

If the text exceeds the forum's 9000 character limit, save it to a .txt file and podst it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

Please always do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

Please use code tags when you post code. To do this, click the </> button on the forum toolbar, then paste the text you want to be in the code tags. Finally, move the cursor out of the code tags before adding any additional text you don't want to be in the code tags. If your browser doesn't show the posting toolbar, then you can manually add the code tags like this:
[code]``[color=blue]// your code is here[/color]``[/code]

The reason for doing this is that, without code tags, the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier for us to read your code and to copy it to the IDE or editor.

Using code tags and other important information is explained in the "How to use this forum" post. Please read it.

/code //Created by: Mirza Rameez Ahmed Baig

#include "Talkie.h"

Talkie voice;

const uint8_t spDANGER[] PROGMEM = {0x2D, 0xBF, 0x21, 0x92, 0x59, 0xB4, 0x9F, 0xA2, 0x87, 0x10, 0x8E, 0xDC, 0x72, 0xAB, 0x5B, 0x9D, 0x62, 0xA6, 0x42, 0x9E, 0x9C, 0xB8, 0xB3, 0x95, 0x0D, 0xAF, 0x14, 0x15, 0xA5, 0x47, 0xDE, 0x1D, 0x7A, 0x78, 0x3A, 0x49, 0x65, 0x55, 0xD0, 0x5E, 0xAE, 0x3A, 0xB5, 0x53, 0x93, 0x88, 0x65, 0xE2, 0x00, 0xEC, 0x9A, 0xEA, 0x80, 0x65, 0x82, 0xC7, 0xD8, 0x63, 0x0A, 0x9A, 0x65, 0x5D, 0x53, 0xC9, 0x49, 0x5C, 0xE1, 0x7D, 0x2F, 0x73, 0x2F, 0x47, 0x59, 0xC2, 0xDE, 0x9A, 0x27, 0x5F, 0xF1, 0x8B, 0xDF, 0xFF, 0x03};
const uint8_t spMOTOR[] PROGMEM = {0x66, 0xAA, 0x8C, 0x69, 0x53, 0x92, 0xC4, 0x2D, 0x2F, 0x6B, 0x2A, 0x74, 0xDA, 0x9D, 0xB2, 0xDD, 0xF6, 0x36, 0xAB, 0xCE, 0x78, 0xDA, 0x9D, 0xB2, 0xD5, 0x9A, 0x01, 0xDB, 0x77,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, 0x1D, 0xC3, 0x11, 0xE4, 0x59, 0x8A, 0x7C, 0xB5, 0x9B, 0x8B, 0xD9, 0x30, 0xB7, 0xD3, 0x76, 0x19, 0x9A, 0x25, 0x59, 0x57, 0x59, 0xEC, 0x11, 0xAF, 0xE8, 0xD9, 0xF9, 0x2A, 0x8A, 0x1D, 0xF0, 0x75, 0x3F, 0x73, 0xAC, 0x87, 0x3B, 0xA2, 0x0B, 0xAA, 0x2B, 0xCF, 0xE4, 0x10, 0xA1, 0xDC, 0x45, 0x64, 0x03, 0x00, 0x80, 0x01, 0x66, 0x36, 0x33, 0xC0, 0xAB, 0xD5, 0x0A, 0x68, 0x25, 0x85, 0x02, 0xFF, 0x0F};

int micPin = 3;
int fsrAnalogPin = A0; // FSR is connected to analog 0
int speakerPin = 8; // connect Red LED to pin 8 (PWM pin)
int fsrReading; // the analog reading from the FSR resistor divider
int speakerMap;

void setup() {

voice.say(spDANGER);
voice.say(spDANGER);
voice.say(spRED);
voice.say(spALERT);
voice.say(spMOTOR);
voice.say(spIS);
voice.say(spON);
voice.say(spFIRE);

{
Serial.begin(9600); // We'll send debugging information via the Serial monitor

{ Serial.begin (9600);

pinMode(micPin, INPUT);
}
}

void loop(){

fsrReading = analogRead(fsrAnalogPin);
int num=fsrReading/5;
Serial.print("Analog reading = ");
Serial.println(fsrReading);
speakerMap = map(fsrReading, 0, 1000, 120, 1500);
tone(speakerPin, speakerMap,10);

delay(100);

{
if (digitalRead(micpin) == HIGH)
{

if (voice(Talkie.h)).say("introduce yourself")) do (voice(Talkie.h)).say("I am Alex, a simple Artificial Intellegence Program coded and built by Mirza Rameez Ahmed Baig.")
else if (voice(Talkie.h)).say("hello" or "hi") do (voice(Talkie.h)).say("Hello" or "Hi")
else if (voice(Talkie.h)).say("bad") do (voice(Talkie.h)).say("Oh No!")
else if (voice(Talkie.h)).say("good") do (voice(Talkie.h)).say("I'm Happy!")
else if (voice(Talkie.h)).say("I'm going" or "I am going") do (voice(Talkie.h)).say("Bye")
else if (voice(Talkie.h)).say("why") do (voice(Talkie.h)).say("Cause I can")
else if (voice(Talkie.h)).say("run diagnostics") do (voice(Talkie.h)).say("All systems working optimally.")
else if (voice(Talkie.h)).say("How are you") do (voice(Talkie.h)).say("All my systems are working optimally" or "I'm Okay")
else if (voice(Talkie.h)).say("Fortnite") do (voice(Talkie.h)).say("Fortnite's Awesome!")
else if (voice(Talkie.h)).say("Rameez") do (voice(Talkie.h)).say("Rameez's Awesome")
else if (voice(Talkie.h)).say("alex") do (voice(Talkie.h)).say("Yes?")
else if (voice(Talkie.h)).say("no") do (voice(Talkie.h)).say("I understand!")
else if (voice(Talkie.h)).say("Yes") do (voice(Talkie.h)).say("I'm happy!")
else do (voice(Talkie.h)).say("Response Denied!")

}
}

//Error is in void loop command

It is really important that you read the replies above, particularly those relating to code tags.

The error is not in the void loop command, the error is in the setup function.

And DO NOT start new topics on the same subject.

Duplicate deleted.

Edit: And another duplicate deleted.

//Created by: Mirza Rameez Ahmed Baig

#include "Talkie.h"

Talkie voice;

const uint8_t spDANGER[] PROGMEM = {0x2D, 0xBF, 0x21, 0x92, 0x59, 0xB4, 0x9F, 0xA2, 0x87, 0x10, 0x8E, 0xDC, 0x72, 0xAB, 0x5B, 0x9D, 0x62, 0xA6, 0x42, 0x9E, 0x9C, 0xB8, 0xB3, 0x95, 0x0D, 0xAF, 0x14, 0x15, 0xA5, 0x47, 0xDE, 0x1D, 0x7A, 0x78, 0x3A, 0x49, 0x65, 0x55, 0xD0, 0x5E, 0xAE, 0x3A, 0xB5, 0x53, 0x93, 0x88, 0x65, 0xE2, 0x00, 0xEC, 0x9A, 0xEA, 0x80, 0x65, 0x82, 0xC7, 0xD8, 0x63, 0x0A, 0x9A, 0x65, 0x5D, 0x53, 0xC9, 0x49, 0x5C, 0xE1, 0x7D, 0x2F, 0x73, 0x2F, 0x47, 0x59, 0xC2, 0xDE, 0x9A, 0x27, 0x5F, 0xF1, 0x8B, 0xDF, 0xFF, 0x03};
const uint8_t sp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, 0xF0, 0xFF};
const uint8_t spALERT[] PROGMEM = {0xA5, 0xCF, 0xC6, 0xAB, 0x55, 0x5B, 0xAF, 0x39, 0xDA, 0xC9, 0x54, 0xDD, 0xBC, 0xC6, 0xC2, 0x3C, 0x27, 0x20, 0xCF, 0x1C, 0xD7, 0x30, 0xB0, 0x45, 0x16, 0x69, 0x1D, 0xC3, 0x11, 0xE4, 0x59, 0x8A, 0x7C, 0xB5, 0x9B, 0x8B, 0xD9, 0x30, 0xB7, 0xD3, 0x76, 0x19, 0x9A, 0x25, 0x59, 0x57, 0x59, 0xEC, 0x11, 0xAF, 0xE8, 0xD9, 0xF9, 0x2A, 0x8A, 0x1D, 0xF0, 0x75, 0x3F, 0x73, 0xAC, 0x87, 0x3B, 0xA2, 0x0B, 0xAA, 0x2B, 0xCF, 0xE4, 0x10, 0xA1, 0xDC, 0x45, 0x64, 0x03, 0x00, 0x80, 0x01, 0x66, 0x36, 0x33, 0xC0, 0xAB, 0xD5, 0x0A, 0x68, 0x25, 0x85, 0x02, 0xFF, 0x0F};

int micPin = 3;
int fsrAnalogPin = A0; // FSR is connected to analog 0
int speakerPin = 8; // connect Red LED to pin 8 (PWM pin)
int fsrReading; // the analog reading from the FSR resistor divider
int speakerMap;

void setup() {

voice.say(spDANGER);
voice.say(spDANGER);
voice.say(spRED);
voice.say(spALERT);
voice.say(spMOTOR);
voice.say(spIS);
voice.say(spON);
voice.say(spFIRE);

{
Serial.begin(9600); // We'll send debugging information via the Serial monitor

{ Serial.begin (9600);

pinMode(micPin, INPUT);
}
}

void loop() {

fsrReading = analogRead(fsrAnalogPin);
int num=fsrReading/5;
Serial.print("Analog reading = ");
Serial.println(fsrReading);
speakerMap = map(fsrReading, 0, 1000, 120, 1500);
tone(speakerPin, speakerMap,10);

delay(100);

{
if (digitalRead(micpin) == HIGH)
{

if (voice(Talkie.h)).say("introduce yourself")) do (voice(Talkie.h)).say("I am Alex, a simple Artificial Intellegence Program coded and built by Mirza Rameez Ahmed Baig.")
else if (voice(Talkie.h)).say("hello" or "hi") do (voice(Talkie.h)).say("Hello" or "Hi")
else if (voice(Talkie.h)).say("bad") do (voice(Talkie.h)).say("Oh No!")
else if (voice(Talkie.h)).say("good") do (voice(Talkie.h)).say("I'm Happy!")
else if (voice(Talkie.h)).say("I'm going" or "I am going") do (voice(Talkie.h)).say("Bye")
else if (voice(Talkie.h)).say("why") do (voice(Talkie.h)).say("Cause I can")
else if (voice(Talkie.h)).say("run diagnostics") do (voice(Talkie.h)).say("All systems working optimally.")
else if (voice(Talkie.h)).say("How are you") do (voice(Talkie.h)).say("All my systems are working optimally" or "I'm Okay")
else if (voice(Talkie.h)).say("Fortnite") do (voice(Talkie.h)).say("Fortnite's Awesome!")
else if (voice(Talkie.h)).say("Rameez") do (voice(Talkie.h)).say("Rameez's Awesome")
else if (voice(Talkie.h)).say("alex") do (voice(Talkie.h)).say("Yes?")
else if (voice(Talkie.h)).say("no") do (voice(Talkie.h)).say("I understand!")
else if (voice(Talkie.h)).say("Yes") do (voice(Talkie.h)).say("I'm happy!")
else do (voice(Talkie.h)).say("Response Denied!")

}
}

See reply #10

Where do you think setup ends, and loop starts?

The compiler disagrees with you. Guess who wins?

//100% this is correct

//Created by: Mirza Rameez Ahmed Baig

#include "Talkie.h"

Talkie voice;

const uint8_t spDANGER[] PROGMEM = {0x2D, 0xBF, 0x21, 0x92, 0x59, 0xB4, 0x9F, 0xA2, 0x87, 0x10, 0x8E, 0xDC, 0x72, 0xAB, 0x5B, 0x9D, 0x62, 0xA6, 0x42, 0x9E, 0x9C, 0xB8, 0xB3, 0x95, 0x0D, 0xAF, 0x14, 0x15, 0xA5, 0x47, 0xDE, 0x1D, 0x7A, 0x78, 0x3A, 0x49, 0x65, 0x55, 0xD0, 0x5E, 0xAE, 0x3A, 0xB5, 0x53, 0x93, 0x88, 0x65, 0xE2, 0x00, 0xEC, 0x9A, 0xEA, 0x80, 0x65, 0x82, 0xC7, 0xD8, 0x63, 0x0A, 0x9A, 0x65, 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 0x8F, 0xF3, 0x92, 0xF6, 0x05, 0x43, 0xCC, 0x74, 0x77, 0x3E, 0xC3, 0xF5, 0x95, 0x98, 0xA9, 0xBA, 0x8B, 0x8F, 0x00, 0x7E, 0x73, 0xE5, 0x00, 0x05, 0x28, 0xF0, 0xFF};
const uint8_t spALERT[]  PROGMEM = {0xA5, 0xCF, 0xC6, 0xAB, 0x55, 0x5B, 0xAF, 0x39, 0xDA, 0xC9, 0x54, 0xDD, 0xBC, 0xC6, 0xC2, 0x3C, 0x27, 0x20, 0xCF, 0x1C, 0xD7, 0x30, 0xB0, 0x45, 0x16, 0x69, 0x1D, 0xC3, 0x11, 0xE4, 0x59, 0x8A, 0x7C, 0xB5, 0x9B, 0x8B, 0xD9, 0x30, 0xB7, 0xD3, 0x76, 0x19, 0x9A, 0x25, 0x59, 0x57, 0x59, 0xEC, 0x11, 0xAF, 0xE8, 0xD9, 0xF9, 0x2A, 0x8A, 0x1D, 0xF0, 0x75, 0x3F, 0x73, 0xAC, 0x87, 0x3B, 0xA2, 0x0B, 0xAA, 0x2B, 0xCF, 0xE4, 0x10, 0xA1, 0xDC, 0x45, 0x64, 0x03, 0x00, 0x80, 0x01, 0x66, 0x36, 0x33, 0xC0, 0xAB, 0xD5, 0x0A, 0x68, 0x25, 0x85, 0x02, 0xFF, 0x0F};


int micPin = 3;
int fsrAnalogPin = A0; // FSR is connected to analog 0
int speakerPin = 8;      // connect Red LED to pin 8 (PWM pin)
int fsrReading;      // the analog reading from the FSR resistor divider
int speakerMap;


void setup() {

  voice.say(spDANGER);
  voice.say(spDANGER);
  voice.say(spRED);
  voice.say(spALERT);
  voice.say(spMOTOR);
  voice.say(spIS);
  voice.say(spON);
  voice.say(spFIRE);

{
Serial.begin(9600);   // We'll send debugging information via the Serial monitor

{  Serial.begin (9600);
 
  pinMode(micPin, INPUT);
}
}

void loop() {

  fsrReading = analogRead(fsrAnalogPin);
  int num=fsrReading/5;
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
  speakerMap = map(fsrReading, 0, 1000, 120, 1500);
  tone(speakerPin, speakerMap,10);
 
  delay(100);
  
{
  if (digitalRead(micpin) == HIGH)
{
 
if (voice(Talkie.h)).say("introduce yourself")) do (voice(Talkie.h)).say("I am Alex, a simple Artificial Intellegence Program coded and built by Mirza Rameez Ahmed Baig.")
else if (voice(Talkie.h)).say("hello" or "hi") do (voice(Talkie.h)).say("Hello" or "Hi")
else if (voice(Talkie.h)).say("bad") do (voice(Talkie.h)).say("Oh No!")
else if (voice(Talkie.h)).say("good") do (voice(Talkie.h)).say("I'm Happy!")
else if (voice(Talkie.h)).say("I'm going" or "I am going") do (voice(Talkie.h)).say("Bye")
else if (voice(Talkie.h)).say("why") do (voice(Talkie.h)).say("Cause I can")
else if (voice(Talkie.h)).say("run diagnostics") do (voice(Talkie.h)).say("All systems working optimally.")
else if (voice(Talkie.h)).say("How are you") do (voice(Talkie.h)).say("All my systems are working optimally" or "I'm Okay")
else if (voice(Talkie.h)).say("Fortnite") do (voice(Talkie.h)).say("Fortnite's Awesome!")
else if (voice(Talkie.h)).say("Rameez") do (voice(Talkie.h)).say("Rameez's Awesome")
else if (voice(Talkie.h)).say("alex") do (voice(Talkie.h)).say("Yes?")
else if (voice(Talkie.h)).say("no") do (voice(Talkie.h)).say("I understand!")
else if (voice(Talkie.h)).say("Yes") do (voice(Talkie.h)).say("I'm happy!")
else do (voice(Talkie.h)).say("Response Denied!")

}
}

Talkie.h (413 Bytes)

Please do an auto format on your code, as I requested you to do already. After the auto format, check the indentation of your code to see whether it matches you intended program structure. That should make it obvious what the problem is with your code.

It says that the problem is that function definition is not allowed before '{' token and its occuring at the void loop code

AudiRameez:
It says that the problem is that function definition is not allowed before '{' token and its occuring at the void loop code

And it is absolutely correct.

Again: where does setup end, and loop begin?

setup ends at the pin-mode part and loop starts at the fsrreading part

void setup() {

  voice.say(spDANGER);
  voice.say(spDANGER);
  voice.say(spRED);
  voice.say(spALERT);
  voice.say(spMOTOR);
  voice.say(spIS);
  voice.say(spON);
  voice.say(spFIRE);

{
Serial.begin(9600);   // We'll send debugging information via the Serial monitor

{  Serial.begin (9600);
 
  pinMode(micPin, INPUT);
}
}

Does that look right to you?

(Hint: it doesn't to me. Or the compiler.)

AudiRameez:
setup ends at the pin-mode part and loop starts at the fsrreading part

After you do an auto-format, does the indentation match with that statement?

After auto format, functions should always start with no indentation and end with a } that is also not indented. If this is not the case, it indicates you are missing some braces.