3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

bash for Windows で say したい

Last updated at Posted at 2020-11-01

WSH(Windows Script Host)を利用する。

手順

  1. WSH で読み上げプログラムを作成する
  2. 読み上げプログラムにエイリアスを設定する
  3. エイリアスを使って実行する

1. WSH で読み上げプログラムを作成する

巷でよく見かけるやつです。

/c/bin/say.js
var args = [];
for(var i = 0; i < WScript.Arguments.length; i++) args.push(WScript.Arguments.Item(i));

var sapi = new ActiveXObject('SAPI.SpVoice');
sapi.Speak(args.join(' '));

2. 読み上げプログラムにエイリアスを設定する

wscriptコマンドを利用すれば、bash から WSH が起動できます。

~/.bashrc
alias say="wscript /C/bin/say.js"

3. エイリアスを使って実行する

あとは通常のコマンドのように呼び出します。

say イエス

あくまで簡易的なものですが、Windows でも say コマンドが使えるようになりますね!

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?