Why won't speaker or buzzer work on PWM signals?

In case you noticed, yeah this is like my 3rd post on audio in the past month so sorry about that, but I think I nearly got it working now. I managed to fix my problem where the SD card wasn't being read on the arduino with SPI library, but now the speaker or a tone buzzer will not make any sound. Please accept I'm not an expert on this stuff, I'm more of an enthusiast with not much experience. So I know it is outputting PWM signals, because I did analogRead on the pin, which gives the correct signals (I know this because I'm trying to play a siren, you can clearly see it is sending that). But for some reason there is no sound at all. Anyone help me with this? I have tried a piezo speaker which doesn't make any noise so I'm not too sure to be honest.

Oh yeah here is my code (sorry if there is an obvious problem, like I said I am still new to arduino).

#include <SPI.h>
#include <SD.h>
#include <TMRpcm.h>
const int chipSelect = 4;

TMRpcm audio;

void setup() {
   
   Serial.begin(9600);
   audio.speakerPin = 9;


   Serial.print("Initializing SD card...");

   // see if the card is present and can be initialized:
   if (!SD.begin(chipSelect)) {
     Serial.println("Card failed, or not present");
     // don't do anything more:
     return;
   }
   Serial.println("card initialized.");


  audio.play("1");
}
void loop() {

Serial.println(analogRead(2));
delay(100);
}

What is your setup?
Are you using an MP3 shield or wav shield like this one Adafruit Wave Shield for Arduino Kit [v1.1] : ID 94 : $22.00 : Adafruit Industries, Unique & fun DIY electronics and kits

Why won't speaker or buzzer work on PWM signals?

Because you are not telling any PWM pin to do anything.

I have an sd card shield connected to the arduino (no speaker or anything on it, just the sd cars slot) and arduino UNO. The outputpin is connected to the speaker, or piezo speaker.
@PaulS what do you mean? I thought the TMRpcm library took care of that?

I thought the TMRpcm library took care of that?

What does the TMRpcm library/shield have to do with the question you asked? It is highly unlikely that the TMRpcm library is using PWM to make sounds happen.

Did you follow the second (transistorized) circuit here for amplifying the signal?

This page is referenced by:

(I am assuming this is the library you are using, as you didn't provide a link)

There is also referenced this instructables:

You might also want to post a schematic and/or a picture of your current circuit.

Finally - have you tried using the tone() function (https://www.arduino.cc/en/Reference/Tone) as a sanity check on the Arduino end; to check the hardware (speaker) and remove the Arduino from the loop - wire up a 555 audio oscillator (or use some other method) to verify that the speaker is working.