我需要制作一个脚本,从txt文件中选择一个随机句子,并用随机语音说出每个单词,使用一组声音,说话速率调制和音调。
例如: 从txt文件中随机选择一句话:“铺床:仔细聆听:读一本书” 和{“make”,“a”,“bed”}由一个随机的声音逐字逐句地说:
say "make" using "Fred" speaking rate 43 modulation 40 pitch 11
say "a" using "Bruce" speaking rate 101 modulation 50 pitch 91
say "bed" using "Kathy" speaking rate 138 modulation 18 pitch 31
我可以使用一些建议,因为我是AppleScript的新手,感觉有些困难。 就我而言:
try
set myWordFile to (choose file with prompt "Select a file to read:" of type {"txt"})
open for access myWordFile
set wordContents to (read myWordFile)
close access myWordFile
set AppleScript's text item delimiters to ":"
set txtvar10 to words of wordContents
return txtvar10
end try
提前致谢: - )
答案 0 :(得分:3)
试试这个......
set theVoices to {"Alex", "Bruce", "Fred", "Kathy", "Vicki", "Victoria"}
set myWordFile to (choose file with prompt "Select a file to read:" of type {"txt"})
open for access myWordFile
set wordContents to (read myWordFile)
close access myWordFile
set AppleScript's text item delimiters to ":"
set theSentences to text items of wordContents
set AppleScript's text item delimiters to ""
set theSentence to some item of theSentences
set theWords to words of theSentence
repeat with aWord in theWords
set speakingRate to random number from 1 to 100
set theModulation to random number from 1 to 100
set thePitch to random number from 1 to 100
say aWord using (some item of theVoices) speaking rate speakingRate modulation theModulation pitch thePitch
end repeat