How to use Defaults to set an element of an array of an array in a preference file?
WARNING: Although this will do what you're asking, it has shown to make the system speech synthesizer incredibly unstable and crash constantly, to the point of making it unusable. I'm posting this here for future reference in regard to setting nested arrays, but I do not recommend anyone actually tries what's shown here.
I've tried changing this setting manually, but it would seem that the speech synthesizer will not speak faster than 360. Here's how you can see this for yourself:
-
First, we have to get the "VoiceRateDataArray" key, in order to set the things that shouldn't change, back to their original values, when we make our modifications
defaults read com.apple.speech.voice.prefs VoiceRateDataArray
The output should look something like this:
-
Then, we can make our edits. First, we must construct the defaults command, containing the entry we don't wish to change, and the modified version of the entry we do. For this example, I will change the second entry. The basic syntax is
-array '(item1, item2, item3)' '(item1, item2, item3)'
. This creates an array, with two nested arrays inside it, based on my example:defaults write com.apple.speech.voice.prefs VoiceRateDataArray -array '( 1835364215, 200, 205 )' '( 1886745202, 184844493, 400 )'
As you can see, the last element of the second second array has changed from 271 to 400.
-
Now you have to restart the speech synthesizer:
killall com.apple.speech.speechsynthesisd