Help With A Sound Detection Sensor

Thank you for getting back to me.

So i tried what you said and adjusted the 512. I did both 400 and 600 with it still doing the same thing. im kinda new to this so im not sure how far i should be adjusting it?

Below is the code with the stuff suggested.

const int buttonPinStatic = 7;   // Static 

// variables will change:
int buttonState = HIGH;         // variable for reading the pushbutton status

#define CALIBRATION 512 // try and change until it works

void setup() {
 
   // initialize the button pin as a input:
pinMode(buttonPinStatic, INPUT);

// initialize serial communication:
   Serial.begin(9600);
   
int volume;
do {
  int val1 = analogRead(A0);
  delay(100);
  int val2 = analogRead(A0);
  volume = (val1 + val2) / 2;
} while (volume>CALIBRATION); // wait until average volume drops (i.e. you stop speaking)

   
   Serial.write(0x7E); 
   Serial.write(0x03); 
   Serial.write(0xA7);
   Serial.write(0x1F); //  volume max
   Serial.write(0x7E);
   
   // start sound
   Serial.write(0x7E); 
   Serial.write(0x04); 
   Serial.write(0xA0); // A0 for SD card
   Serial.write((byte)0x00);
   Serial.write(0x02); // track number
   Serial.write(0x7E);
   delay(3000);
    
   }
   
   void loop() 
{
 
   Serial.write(0x7E);
   Serial.write(0x02); //STOP Sound
   Serial.write(0xA4); 
   Serial.write(0x7E);                     
   
 buttonState = digitalRead(buttonPinStatic);
if (buttonState == HIGH) { 

   Serial.write(0x7E); 
   Serial.write(0x04); 
   Serial.write(0xA0); // A0 for SD card
   Serial.write((byte)0x00);
   Serial.write(0x01); // track number
   Serial.write(0x7E);
delay(1000);
}

  
         }