「ご主人様ご命令を!」OS Xでスクリプトスレ

このエントリーをはてなブックマークに追加
486名称未設定
10.2でスピーチをaiff出力してみる。
アプリケーションにしてテキストファイルをDnDで動くはず。
文書の最後に#Trinoidsとか入れると声が変わります。
ただし日本語ファイル名で出力すると落ちます。
なんでだろう。AS使ったの初めてだからわかりません(逃

on run
aif_exp(choose file with prompt "Choose text file")
end run

on open drop_item
set theFile to drop_item
set file_num to count (item of drop_item)
if file_num is 1 then
aif_exp(drop_item)
else
display dialog "Sorry, only 1 file can be handled."
end if
end open
487名称未設定:02/10/15 02:12 ID:aTvgDMMd
つづき。も少しスマートにまとめられそうなんだが……

on aif_exp(source_file)
set theInfo to info for source_file
set theName to (name of theInfo) & ".aiff"
open for access source_file
try
set theText to read source_file using delimiter ("#") as text
on error
set theSent to read source_file as text
end try
close access source_file
try
set theSent to item 1 of theText
set theVoice to item 2 of theText
end try
set theAif to (choose file name with prompt "Saving file..." default name theName)
try
say theSent using theVoice saving to theAif
on error
say theSent saving to theAif
end try
end aif_exp