Skip to content

Instantly share code, notes, and snippets.

@susisu
Last active January 22, 2020 16:07
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susisu/c9b106745f94c85e482c to your computer and use it in GitHub Desktop.
Save susisu/c9b106745f94c85e482c to your computer and use it in GitHub Desktop.
非実用 say コマンド

非実用 say コマンド

おはようございます. @susisu2413 です. この記事は OUCC アドベントカレンダー 2014 1日目の記事です. が, 誰も登録されていなかったので急遽書くことになりました. しかたがないので適当な記事でハードルを下げつつお茶を濁そうと思います.

say コマンド

say コマンドをご存知でしょうか. Mac に標準で入っている音声読み上げコマンドです. 最近, レポート作成の疲れから say コマンドで遊んでみたら思いの外面白かったので記事にしてみました.

残念ながら Windows なんかでは使えそうにないので, 手元に Mac 環境がない人は友人知人のマカーと一緒に楽しむか, 好きな寿司ネタを私にリプライで送ってください.

手始め

まずはターミナル的なものを起動して以下のコマンドを打ち込んでみましょう.

say hello

Hello! 私の環境 (10.9.5) ではデフォルトで男性の声 (Alex) で読み上げられましたが, 環境によっては違うかもしれません.

音声の種類を変える

-v オプションをつけることで, 読み上げに使用する音声を変えることが出来ます.

# 例: 声を Alex に変える (たぶんデフォルト)
say -v Alex hello

使用できる声の種類は

say -v ?

で確認できます. 私の環境ではデフォルトで以下の音声が入っていました.

Agnes               en_US    # Isn't it nice to have a computer that will talk to you?
Albert              en_US    #  I have a frog in my throat. No, I mean a real frog!
Alex                en_US    # Most people recognize me by my voice.
Bad News            en_US    # The light you see at the end of the tunnel is the headlamp of a fast approaching train.
Bahh                en_US    # Do not pull the wool over my eyes.
Bells               en_US    # Time flies when you are having fun.
Boing               en_US    # Spring has sprung, fall has fell, winter's here and it's colder than usual.
Bruce               en_US    # I sure like being inside this fancy computer
Bubbles             en_US    # Pull the plug! I'm drowning!
Cellos              en_US    # Doo da doo da dum dee dee doodly doo dum dum dum doo da doo da doo da doo da doo da doo da doo
Deranged            en_US    # I need to go on a really long vacation.
Fred                en_US    # I sure like being inside this fancy computer
Good News           en_US    # Congratulations you just won the sweepstakes and you don't have to pay income tax again.
Hysterical          en_US    # Please stop tickling me!
Junior              en_US    # My favorite food is pizza.
Kathy               en_US    # Isn't it nice to have a computer that will talk to you?
Pipe Organ          en_US    # We must rejoice in this morbid voice.
Princess            en_US    # When I grow up I'm going to be a scientist.
Ralph               en_US    # The sum of the squares of the legs of a right triangle is equal to the square of the hypotenuse.
Trinoids            en_US    # We cannot communicate with these carbon units.
Vicki               en_US    # Isn't it nice to have a computer that will talk to you?
Victoria            en_US    # Isn't it nice to have a computer that will talk to you?
Whisper             en_US    # Pssssst, hey you, Yeah you, Who do ya think I'm talking to, the mouse?
Zarvox              en_US    # That looks like a peaceful planet.

これらは システム環境設定 > 音声入力と読み上げ から追加できます. 個人的には英語は Ava, 日本語では Kyoko, ロシア語では Milena なんかがおすすめなのですが, この記事ではそういうまともな読み上げをさせることについては触れません.

say コマンドに嵌るための第一歩

以下のコマンドを実行してみましょう. (私の感動を出来る限り当時のままお伝えするために, 音声を Alex にしてお届けしております. 本当はアヘ顔で say say say say とか適当に入力して遊んでました.)

say -v Alex say say say
# うなぎ
say -v Alex unagi

どうでしょうか. 意表を突かれて笑ってしまったら, もう沼から抜け出すことは出来ないでしょう. 定期的に say unagi をしたくなる体になってしまったはずです.

# おまけ
say -v Kyoko "人生"
say -v Ava "self harapan"

うたのじかん

先に挙げたデフォルトの音声ですが, いくつか特異な音声があります. なんと歌を歌ってくれるのです. それらは以下の 4 種類. この表, 情報が少なすぎる.

名前 曲名
Good News 威風堂々
Bad News 曲名知らない
Cellos 山の魔王の宮殿にて
Pipe Organ 曲名知らない

特に Good News と Bad News は多くの人が聞いたことのあるメロディーだと思います.

これらを用いて, いくつか楽しい読み上げ例を作ってみました.

say -v Good\ News shinchoku dowdeghska shinchku dowdeghska
say -v Bad\ News shinchoku dowdeghska shinchku dowdeghska
say -v Bad\ News Kgo mo ichi ni chi gamba lu zowi Kgo mo ichi ni chi gamba lu zowi

✌(’ω’✌ )三✌(’ω’)✌三( ✌’ω’)✌

おわり

もう say コマンドの正しい使い方がわかりましたね! さあ, あなただけの抱腹絶倒ソングを作りましょう (๑❛ᴗ❛๑)♡

say コマンドはこれらの音声をファイルに出力 (詳細忘れたので各自ググってください) することもできるので, 部室のマシンの起動音を Bad News「進捗どうですか」に勝手に変えました. 部員各位の進捗が出ることを祈っておりますが, よく「うるさい」と怒られています.

OUCC では私が say コマンドで意味不明な音声を読み上げさせていても怒らない人を募集しております.

明日は はるさめ氏 (@spring_raining) による OUCCの部室について です.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment