Tuesday 17 September 2019

macos - Speed Up Rate of Text To Speech via Terminal

I used to have my TTS custom set to read things back nice and fast, works better for me as I'm basically ADD & mildy dyslexic.


Now I'm not much of an expert like most of you on here, but I've just hunted as best I can... tracking back to what I must have posted in Terminal originally.


This seems like it's on the right track:


https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/SpeechSynthesisProgrammingGuide/FineTuning/FineTuning.html


Perhaps something like:


SetSpeechRate(_ chan: SpeechChannel, _ rate: Fixed) -> OSErr
SetSpeechRate(_ chan: Alex, _ rate: 600) -> OSErr

I remember the original string was longer though. Am I on the right track?


I also found this link:


https://groups.google.com/forum/#!msg/macvisionaries/HOR7NWxsDQA/15E4M_6zqLUJ


======================================================================


I found a potential solution. The slider only goes up to a max of 350 wpm, but the setting is stored in:
~/Library/Preferences/com.apple.speech.voice.prefs.plist
To see it, run from terminal:
defaults read com.apple.speech.voice.prefs VoiceRateDataArray
I get something like this:


( 
(
1835364215,
201,
350
)
)

We need to change the last element in each sub-array.
Back up that file, in case this fails. Then from terminal, run:


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, 500) for x in d["VoiceRateDataArray"]];json.dump(d, sys.stdout)' | plutil -convert binary1 -o ~/Library/Preferences/com.apple.speech.voice.prefs.plist - 

If it succeeds, reboot.
Only because I'm not sure how to get things to reload without it.
Once done, your system speech rate should be set to 500. Change that number as appropriate.
To reverse this, adjust the slider in the speech preferences.


==========================================


This didn't seem to work for me though:


I have no com.apple.speech.voice.prefs file on my computer. (Perhaps I can make one, and then modify it?)


Does it work for you?

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...