GUIはこつこつやれば完成できるんだよね

 「ゆっくろいど」という音声合成ソフトでひたすら自動的に読み上げさせるAppleScriptを書いていました。

 使われる辞書のせいかこのソフトによる音声がいまのところ自分の用途には妥当な選択なようです。テキストファイルに書き連ねたものを読み上げさせて推敲したり、誤字を見つけたりということをしています。

 

 自分が情報系のヒトじゃないし、他のソースから流用したり端折ったりしてるので見難いコードですが、誰かのお役に立つかもしれないので載せておきます。

 このコードでは自分のディレクトリにあるカンマ区切りのvoice.txtから「発話速度,音量,声質,テキスト」を読み込んで処理するようになっています。

  * * * * *


set voFile to (path to home folder as string) & "voice.txt"

set vo_fp to open for access file voFile
set readData to (read vo_fp as «class utf8»)
close access vo_fp

set AppleScript's text item delimiters to (ASCII character 10)
set readList to every text item of (readData as «class utf8»)

tell application "Yukkuroid"
    run
end tell


set num to 0
repeat with ln in readList
    try
        set AppleScript's text item delimiters to ","
        set wkList to every text item of ln
        tell ln
            try
                set txValue to item 4 of wkList
            on error
                error
            end try
            try
                set adValue to item 3 of wkList
            on error
                set adValue to "aq_default"
            end try
            try
                set riValue to 1
            on error
                set riValue to 0
            end try
            try
                set spValue to item 1 of wkList
            on error
                set spValue to 100
            end try
            try
                set voValue to item 2 of wkList
            on error
                set voValue to 50
            end try
        end tell
        tell application "System Events"
            tell window 1 of process "Yukkuroid"
                set value of text area 1 of scroll area 1 to txValue
                tell button 4 to click
                if not (value of checkbox 1 = riValue as number) then tell checkbox 1 to click
                tell pop up button 1
                    if not (value = adValue) then
                        click
                        try
                            click menu item adValue of menu 1
                        end try
                    end if
                end tell
                set value of slider 1 to spValue as number
                set value of slider 2 to voValue as number
                tell button 6 to click --再生ボタン
                
                set du2 to value of static text 9
            end tell -- process
        end tell
        
        delay du2
    end try
    set num to num + 1

end repeat