How to find ranges for the 'rate' property of NSSpeechSynthesizer?
-
28-10-2019 - |
Question
I have an OS X app which uses the NSSpeechSynthesizer
class to read some text. I need to be able to set the speed of the reading, which is done using the rate
property of NSSpeechSynthesizer
. However, different voices have different baseline reading rates and different ranges as well. The problem is that I cannot find a way to get this range from the voice so that I know what values are acceptable for the voice. This is important since I want to be able to abstract from the difference in ranges and just let the user choose something like slow/normal/fast. But for a voice with a baseline of 180 words for a minute a value of 100 would be considered slow, which clearly is not the case for a voice with a baseline of 100 words per minute.
Is there a way of getting those ranges? I didn't find anything useful in the class reference for NSSpeechSynthesizer
.
Solution
You can get the rate of a voice before you change it, and you could estimate that the acceptable range is the default rate ± 50 WPM or something.
That said, if you're using this to set up a slider, I'd caution you against limiting the user to only “natural”-sounding ranges. Some people, including many blind people, deliberately crank it up as fast as they can stand in order to save listening time.
OTHER TIPS
Well, I know this isn't the answer you may have been looking for, but as far as I can tell, Apple hasn't made available to the public a way to change the baseline speed of an instance of NSSpeechSynthesizer object (which, as you said, has a 'rate' instance, but it cannot make constant rates for each distinct voice). For this, and I know you won't like it, you'll have to make the slower ones faster and the faster ones slower until they about match up. Sorry again, but as far as I know, Apple doesn't offer a way to change the baseline rate. Happy coding!
~Monkeyanator