How to load new voice for say function using AppleScript?

I am looking for a way to set different voices (2, to be precise) to the system settings. Voices - “Alex” for the English voice and “Thomas” for the French voice.

I tried the console directly, but failed, so I switched to the AppleScript language, but I never used that language.

The code that I have at the moment,

set osver to system version of (system info)
if osver is equal to "10.6.8" then
    display dialog ("Downloading voices is only available in OS X Lion and higher")
else
    tell application "System Preferences"
        activate
        reveal (pane id "com.apple.preference.speech")
    end tell

    try
        tell application "System Events"
            click radio button 2 of tab group 1 of window 1 of process "System Preferences"
            repeat until (exists pop up button of tab group 1 of window 1 of process "System Preferences")
                delay 2
            end repeat
            delay 2
            click pop up button 1 of tab group 1 of window 1 of process "System Preferences"
            delay 2
            click menu item -1 of menu 1 of pop up button of tab group 1 of window 1 of process "System Preferences"
            delay 2
        end tell
    on error
        display dialog ("An error happend")
    end try
end if

This program opens a voice box, but a display dialog box appears every time, regardless of the index that I put.

If you have another idea to upload voices, or if you can help me understand what is not working, I will be grateful.

0
source share
1 answer

This worked for me in 10.9:

tell application "System Preferences"
    reveal anchor "TTS" of pane id "com.apple.preference.speech"
    activate
end tell
tell application "System Events" to tell window 1 of process "System Preferences"
    tell pop up button 1 of tab group 1
        click
        click menu item "Customize..." of menu 1
    end tell
    delay 1
    repeat with r in UI element 1 of rows of table 1 of scroll area 1 of sheet 1
        if exists static text 1 of r then
            if {"Alex", "Thomas"} contains value of static text 1 of r then
                if value of checkbox 1 of r is 0 then click checkbox 1 of r
            end if
        end if
    end repeat
    click button "OK" of sheet 1
end tell

script .

0

Source: https://habr.com/ru/post/1533284/


All Articles