Preserve voice parameters when changing between SAPI4/SAPI5 voices with synth settings ring (#17700)
Fixes #17693. Fixes #2320.
Summary of the issue:
When using the synth settings ring to switch to another SAPI4/SAPI5 voice, its parameters such as rate and volume will be reset to the default value.
This is because the synth driver destroys and re-creates the SAPI object when changing the voice, which resets all its parameters. Then the synth driver selects the correct voice, but other parameters are not preserved.
Changing the voice with the settings dialog works, because the settings dialog reads the property values and assigns them to the slider controls in order to display them, which triggers the event of the slider controls, which assigns the property values just read from the synth back to the synth, which refreshes the property values and therefore "fixes" the problem.
However, when using the synth settings ring, only the voice property is changed. Other properties are not refreshed, which makes the issue appear.
Description of user facing changes
The SAPI4/SAPI5 synthesizer will be able to preserve the settings when switching between voices.
Description of development approach
SAPI5:
In _set_voice, after using _initTts to re-create the SAPI5 object and select the voice, restore the rate and volume parameters to the value stored previously. Pitch does not need to be restored, as it is not a parameter of the SAPI5 object.
SAPI4:
For volume, the percentage is preserved, so that 80% volume is always 80% of the voice's volume range.
For rate and pitch, the difference (delta) between the current value and the default value is preserved. If the rate is set to be 50 WPM faster, when switched to another voice, the rate will also be 50 WPM faster.