我試圖做一個非常簡單的applescript,但是我遇到了一個問題,無法從這裏前進。Applescript:用於保存WAV格式的「說」命令的shell腳本
我的程序應該做的很簡單。它讀取一個文本文件,將其內容分割成一個數組,然後執行shell腳本來利用mac終端的say命令來讀取文本並將其保存到.wav文件中。
在終端上,我可以用這個保存爲WAV格式的文件: say -o "hello.wav" [email protected] "hello world"
我試圖模仿我的AppleScript代碼無濟於事,這裏是代碼:
set theFile to (choose file with prompt "Select a file to read:" of type {"TXT"})
open for access theFile
set fileContents to (read theFile)
close access theFile
set everyLine to every paragraph of fileContents
repeat with theLine in everyLine
set thisOne to split(theLine, ";")
set fileName to item 1 of thisOne
do shell script "say -o" & item 1 of thisOne & ".wav [email protected] " & item 3 of thisOne
end repeat
to split(someText, delimiter)
set AppleScript's text item delimiters to delimiter
set someText to someText's text items
set AppleScript's text item delimiters to {""} --> restore delimiters to default value
return someText
end split
運行此代碼導致Opening output file failed: -43
。
即使是一個簡單的do shell script "say -o hello.aiff hello
也會返回相同的錯誤。 我非常感謝任何幫助,包括告訴我,我根本無法做到這一點,我應該學習適當的編程語言:)
非常感謝你,它就這麼簡單! –