A brushed DC machine can be modeled as

simulate this circuit – Schematic created using CircuitLab
- voltage source
- stator winding inductance
- stator winding resistance
The voltage source will have a voltage proportional to rotor velocity, the \$K_e\$ voltage constant: Volts per RPM (or rads depending on the datasheet). The faster the rotor rotates, the higher this value.
There will equally be voltage due to current flowing through the resistance and equally changing current will cause a voltage across the inductance.
Higher load --> more current draw --> more additional voltage due to the R.
As long as the load & speed is assumed constant (maybe not...) and as long as the PWM frequency is high enough, the L contribution could be ignored.
All this can be measured at the motor's terminals.
How to use PWM to determine speed? The minimum prerequisite is knowing the \$K_e\$ of the motor in use.
If the motor is UNLOADED and you are just energising it with a fixed PWM duty, the rotor velocity can be estimated via:
\$ \omega = V_{cc} * D * K_e \$
\$V_{cc}\$ being the voltage being PWM'ed onto the Motor's stator
D being the fixed duty
\$K_e\$ being the backEMF constant in \$V/\omega\$
If however some form of speed control is required (sensorless) some means to measure the terminal voltage is required.
You can then sample this DURING the off period's of the PWM so you are aware of the motor's terminal voltage.
How much you then compensate for iR (current sensing or ignore if unloaded) or wL (can it be argued its negligible for a DCmachine?) is down to your system considerations.

EXAGGERATED wL