Button press with count to activate wav

Im having some hickups, when I have a certain count from a button press I need the ardunio to activate a wav file from a SD card reader activated by the button. This code works with every button press it makes a count (example 1,2,3,4,5,6) in the serial monitor. The issue i'm facing is when it reaches a certain amount of counts I need the arduino to activate the wav from the SD card reader and ignore any inputs until the wav is done playing than go back to the same process again, activating the sound if the button was pressed again. So on and so forth without any interruptions as the sound is playing.

// Including header files here -----------------------
#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"
// ----------------------------------------------------

TMRpcm tmrpcm;

// this constant won't change:
const int  buttonPin = 2;    // the pin that the pushbutton is attached to

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);
  // initialize Speaker pin @ pin 9
  tmrpcm.speakerPin = 9;
// initialize serial communication:
  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)) {
  Serial.println("SD fail");
  return;

void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);
  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
 // if the state has changed, increment the counter
    if (buttonState == HIGH) {
 // if the current state is HIGH then the button went from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes:  ");
      Serial.println(buttonPushCounter);
    } 
    
    else 
    {
      // if the current state is LOW then the button wend from on to off:
      Serial.println("off");
    // Delay a little bit to avoid bouncing
    delay(50);
    }
          
  // save the current state as the last state,
  //for next time through the loop
  lastButtonState = buttonState;


  // turns on the LED every four button pushes by
  // checking the modulo of the button push counter.
  // the modulo function gives you the remainder of
  // the division of two numbers:
 if (buttonPushCounter % 4 == 0) 
 {
    digitalWrite(ledPin, HIGH);
    tmrpcm.setVolume(5);
    tmrpcm.play("3.wav");
    } else 
    {
    digitalWrite(ledPin, LOW);
  }
}
  }

I seem to be getting error code of the following when trying to comile the code:


/Users/johnhickey/Documents/Arduino/Soundspurt_beta/Soundspurt_beta.ino: In function 'void setup()':
Soundspurt_beta:31:13: error: a function-definition is not allowed here before '{' token
void loop() {
^
Soundspurt_beta:73:3: error: expected '}' at end of input
}
^
Soundspurt_beta:73:3: error: expected '}' at end of input
Multiple libraries were found for "SD.h"
Used: /Users/johnhickey/Documents/Arduino/libraries/SD
Not used: /Users/johnhickey/Desktop/Arduino.app/Contents/Java/libraries/SD
exit status 1
a function-definition is not allowed here before '{' token


the main goal with this is once the button is pressed to play a wav file , pausing the loop till the wav is played then once done continue the code as usual again. Thank you for the help

any ideas? Thank you

All functions must be defined within a { and } pair.
You have not got matching braces in the setup function, you are missing two at the end.

Tip - click on an opening { in the IDE and the matching closing } will have a small box round it.