Arduino voice recorder

Thank you both for your replies. Based on them, I decided to start fresh and build the project from scratch by removing the button and the LED and keeping only the microphone and the SD card.

I thought that by using the following code

#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>

#define SD_ChipSelectPin 10  

TMRpcm audio;   

void setup() {
  
   Serial.begin(115200);
  
  if (!SD.begin(SD_ChipSelectPin)) {  
    return;
  }else{
    Serial.println("SD OK"); 
  }
  
  audio.CSPin = SD_ChipSelectPin;
}


void loop() {
  
    if(Serial.available()){                        
      switch(Serial.read()){
        case 'r': audio.startRecording("testTMR.wav", 16000, A0); break;   
        case 's': audio.stopRecording("testTMR.wav"); break;              
      }
    }
}

I would be able to record one wav file of acceptable quality. Unfortunately, that wasn't the case. What I got is attached.

Any ideas what I'm doing wrong this time? Could it be a problem of the library (TMRpcm)?