Spin the motor at a known RPM, eg, with an electric hand drill, and measure the voltage at the terminals.
Both types have an rpm of ~6400 at nominal voltage (12 or 24 V).
Example: If your hand drill has an RPM of 1500, the generated voltage will be either 1500/6400 x 12 V (~2.8 V) or 1500/6400 x 24 V (~5.6 V).