Change Speech to Text Rate via CMD line

Chuey
Contributor III

Hello all,

Testing in our K12 environment is coming up soon...Great!

For specific tests, speech to text is an available option to students. For younger kids I think the "normal" rate is too fast.

Does anyone have a script to change this setting under System Preferences > Dictation & Speech > Text To Speech > Speaking Rate. . . . I'm wondering if there is a command I can run to slow it down?

Any help is much appreciated,

Thank you in advance for any help.

4 REPLIES 4

roiegat
Contributor III

well in the command line I use the say command to make macs talk. If you want to have a good laugh just send the following command to all your macs:

say -v princess the boss is watching you

Lots of fun.

But looking at the say command you can change the rate using the -r option. So taking the top example:

say -v princess -r 10 the boss is watching you

would be really slow and

say -v princess -r 150 the boss is watching you

would be really fast

Chuey
Contributor III

@roiegat I'm actually trying to change the setting under System Preferences > Dictation & Speech > Text To Speech > Speaking Rate

Kids will be doing a test in a special application where they can enable / disable text to speech. It's using the settings from that System Preference area. . .

NoahRJ
Contributor II

Here's a one-liner that should do the trick for you (there's a long scroll with the formatting, so make sure you copy the whole thing):

plutil -convert json ~/Library/Preferences/com.apple.speech.voice.prefs.plist -o - | python -c 'import json, sys;d=json.load(sys.stdin);[x.__setitem__(-1, 87) for x in d["VoiceRateDataArray"]];json.dump(d, sys.stdout)' | plutil -convert binary1 -o ~/Library/Preferences/com.apple.speech.voice.prefs.plist -

I set the value for 87, since that's the slowest you can get from the slider when you change in the GUI, but you can set it slower if you'd like. Max value from the slider in System Prefs is 350, but of course, that can also go faster.

You can always check it from defaults read of the voice prefs plist, too:

defaults read ~/Library/Preferences/com.apple.speech.voice.prefs.plist VoiceRateDataArray

Last value returned should be the current rate on the machine you're looking at.

Chuey
Contributor III

@NoahRJ Since this is a user specific setting, how are you applying this? I did some testing and noticed if you have not changed the default values in Speech & Dictation for the rate/speed, that array does not exist.

Once I changed it manually, i could then issue the defaults read to see the array and run the command. It does indeed work.

So what I did was took the modified com.apple.speech.voice.prefs.plist file, created a package with a script that copies it into any existing user or user who logs in, Library/Preferences folder.

When I hit dictation and speech under sys prefs it fails to load with some error.