I don't know if TMRpcm supports the ESP32 but the ESP32 has a DAC so you shouldn't be using TMRpcm (which isn't true analog).
I've never actually done this but WAV files are "simple". You read the samples and write them to the DAC at the correct sample rate (44,000 samples per second, etc.), and that's about it.
The complications are... You read bytes from a file and you may have 16 or 24-bit audio, or stereo, and the bytes have to be "re-assembled" correctly.
Once you have the samples they have to be re-scaled so the number of bits matches the actual DAC.
And since the DAC can't put-out negative voltages, the sample data has to be biased before it's sent to the DAC (except for 8-bit WAV files which use unsigned data which is already biased).
On the hardware side, the LM386 has way too much (voltage) gain so you'll need a voltage divider or volume control on the input. You do need the "power gain" to drive a regular speaker.
Another way to play WAV files on ESP32 - using it I2s digital audio output. To play digital sound you will need a I2s audio module, like a MAX98357A
Please see this tutorial: