OS X 中有個指令叫 "say",他可以讓使用者在終端機下命令電腦唸出指定的英文內容,例如你輸入
"say Hello",他就會唸"Hello"。可是,如果你要他唸一段文章,裡面含有各種標點符號,他就會出現錯誤給你看:
say Porphyrias are a group of inherited or acquired disorders of certain enzymes in the heme biosynthetic pathway (also called porphyrin pathway). They are broadly classified as hepatic porphyrias or erythropoietic porphyrias, based on the site of the overproduction and mainly accumulation of the porphyrins (or their chemical precursors). They manifest with either skin problems or with neurological complications (or occasionally both).
Mac OS X 從 10.3(如果我沒記錯的話)開始,便強化了這個功能,加入了更多參數讓使用者"玩"這個指令。他多了下面這些指令參數:
say [-v voice] [-o out] [-f in | message] 所以,我們有兩個辦法可以解決上面的問題。
第一種,改用這個指令:
say "Porphyrias are a group of inherited or acquired disorders of certain enzymes in the heme biosynthetic pathway (also called porphyrin pathway). They are broadly classified as hepatic porphyrias or erythropoietic porphyrias, based on the site of the overproduction and mainly accumulation of the porphyrins (or their chemical precursors). They manifest with either skin problems or with neurological complications (or occasionally both)." 加上引號後他就可以正常的唸。當然,如果只能這樣玩就太遜了,他還可以唸 .txt 文字檔,然後直接輸出成聲音檔!
我們把剛剛那段文字存成 read.txt,放在桌面上(注意,只能是純文字檔,使用 rtf 之類的他還是會照唸,但是他會連你的格式語法代碼一起唸...),使用以下指令:
say -o ~/Desktop/say.aiff -f ~/Desktop/read.txt 你會發現他停住了!這可不是當機喔,使用 top 指令察看的話會發現他正在耗用大量的 CPU 資源,等一下下桌面上就會出現"say.aiff"這個聲音檔,打開來,會發現是剛剛那段文字的朗讀錄音。而且文章就算要唸十幾分鐘,他還是可以在兩三分中內產生出整個朗讀檔。
我沒有試過產生 MP3 或 AAC ,有興趣的人自己試試吧!我是用 iTunes 再轉成別的格式的。
|