我需要做一个脚本,从一个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提前感谢:-)
发布于 2010-09-06 04:00:08
试试这个。
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 repeathttps://stackoverflow.com/questions/3642712
复制相似问题