2011-09-27 73 views
0
保存PDF文件的內容所講的音頻

我建立了一個簡單的腳本,它接受一個字符串,並將其轉換爲音頻文件:使用AppleScript

say "This is only a test." using "Fred" saving to file (((path to desktop) as string) & "audio.aiff"

我想編輯腳本因此,不使用字符串「這只是一個測試」,它將獲取PDF文檔並使用文檔中的文本創建音頻文件。

回答

1

Skim,一個免費的PDF查看器,可能是你感興趣的。它具有腳本功能,並具有AppleScript命令以從某些PDF頁面提取文本。一旦你下載了Skim,你可以運行這個腳本:

tell application "Skim" 
    open (POSIX file "/path/to/PDF/document.pdf") 
    set the stuff to (get text for page 1 of document 1) as string --change 'page 1' to whatever page number you need 
    --if you want all the pages, just use 'every page' 
end tell 
say the stuff using "Fred" saving to file (((path to desktop) as string) & "audio.aiff") 

快樂的編碼! :)